• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef CONTENT_BROWSER_DOM_STORAGE_SESSION_STORAGE_NAMESPACE_IMPL_H_
6 #define CONTENT_BROWSER_DOM_STORAGE_SESSION_STORAGE_NAMESPACE_IMPL_H_
7 
8 #include "base/basictypes.h"
9 #include "base/memory/ref_counted.h"
10 #include "content/common/content_export.h"
11 #include "content/public/browser/session_storage_namespace.h"
12 
13 namespace content {
14 
15 class DOMStorageContextWrapper;
16 class DOMStorageSession;
17 
18 class SessionStorageNamespaceImpl
NON_EXPORTED_BASE(public SessionStorageNamespace)19     : NON_EXPORTED_BASE(public SessionStorageNamespace) {
20  public:
21   // Constructs a |SessionStorageNamespaceImpl| and allocates new IDs for it.
22   //
23   // The CONTENT_EXPORT allows TestRenderViewHost to instantiate these.
24   CONTENT_EXPORT explicit SessionStorageNamespaceImpl(
25       DOMStorageContextWrapper* context);
26 
27   // Constructs a |SessionStorageNamespaceImpl| by cloning
28   // |namespace_to_clone|. Allocates new IDs for it.
29   SessionStorageNamespaceImpl(DOMStorageContextWrapper* context,
30                               int64 namepace_id_to_clone);
31 
32   // Constructs a |SessionStorageNamespaceImpl| and assigns |persistent_id|
33   // to it. Allocates a new non-persistent ID.
34   SessionStorageNamespaceImpl(DOMStorageContextWrapper* context,
35                               const std::string& persistent_id);
36 
37   // Creates an alias of |master_session_storage_namespace|. This will allocate
38   // a new non-persistent ID.
39   explicit SessionStorageNamespaceImpl(
40       SessionStorageNamespaceImpl* master_session_storage_namespace);
41 
42   // SessionStorageNamespace implementation.
43   virtual int64 id() const OVERRIDE;
44   virtual const std::string& persistent_id() const OVERRIDE;
45   virtual void SetShouldPersist(bool should_persist) OVERRIDE;
46   virtual bool should_persist() const OVERRIDE;
47 
48   SessionStorageNamespaceImpl* Clone();
49   bool IsFromContext(DOMStorageContextWrapper* context);
50 
51   virtual void AddTransactionLogProcessId(int process_id) OVERRIDE;
52   virtual void RemoveTransactionLogProcessId(int process_id) OVERRIDE;
53   virtual void Merge(bool actually_merge,
54                      int process_id,
55                      SessionStorageNamespace* other,
56                      const MergeResultCallback& callback) OVERRIDE;
57   virtual bool IsAliasOf(SessionStorageNamespace* other) OVERRIDE;
58   virtual SessionStorageNamespace* CreateAlias() OVERRIDE;
59 
60  private:
61   explicit SessionStorageNamespaceImpl(DOMStorageSession* clone);
62   virtual ~SessionStorageNamespaceImpl();
63 
64   scoped_refptr<DOMStorageSession> session_;
65 
66   DISALLOW_COPY_AND_ASSIGN(SessionStorageNamespaceImpl);
67 };
68 
69 }  // namespace content
70 
71 #endif  // CONTENT_BROWSER_DOM_STORAGE_SESSION_STORAGE_NAMESPACE_IMPL_H_
72