Change layout of app list items in experimental app list.
[chromium-blink-merge.git] / content / browser / dom_storage / dom_storage_session.h
blob5e126216c60cd4a8954bc99cf2f42c2e4512fdcd
1 // Copyright 2013 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.
5 #ifndef CONTENT_BROWSER_DOM_STORAGE_DOM_STORAGE_SESSION_H_
6 #define CONTENT_BROWSER_DOM_STORAGE_DOM_STORAGE_SESSION_H_
8 #include <string>
10 #include "base/basictypes.h"
11 #include "base/memory/ref_counted.h"
12 #include "content/browser/dom_storage/session_storage_namespace_impl.h"
13 #include "content/common/content_export.h"
15 namespace content {
17 class DOMStorageContextImpl;
19 // This refcounted class determines the lifetime of a session
20 // storage namespace and provides an interface to Clone() an
21 // existing session storage namespace. It may be used on any thread.
22 // See class comments for DOMStorageContextImpl for a larger overview.
23 class CONTENT_EXPORT DOMStorageSession
24 : public base::RefCountedThreadSafe<DOMStorageSession> {
25 public:
26 // Constructs a |DOMStorageSession| and allocates new IDs for it.
27 explicit DOMStorageSession(DOMStorageContextImpl* context);
29 // Constructs a |DOMStorageSession| and assigns |persistent_namespace_id|
30 // to it. Allocates a new non-persistent ID.
31 DOMStorageSession(DOMStorageContextImpl* context,
32 const std::string& persistent_namespace_id);
34 // Constructs a |DOMStorageSession| as an alias of
35 // |master_dom_storage_session|. Allocates a new non-persistent ID.
36 explicit DOMStorageSession(DOMStorageSession* master_dom_storage_session);
38 int64 namespace_id() const { return namespace_id_; }
39 const std::string& persistent_namespace_id() const {
40 return persistent_namespace_id_;
42 void SetShouldPersist(bool should_persist);
43 bool should_persist() const;
44 bool IsFromContext(DOMStorageContextImpl* context);
45 DOMStorageSession* Clone();
47 // Constructs a |DOMStorageSession| by cloning
48 // |namespace_id_to_clone|. Allocates new IDs for it.
49 static DOMStorageSession* CloneFrom(DOMStorageContextImpl* context,
50 int64 namepace_id_to_clone);
52 void AddTransactionLogProcessId(int process_id);
53 void RemoveTransactionLogProcessId(int process_id);
54 void Merge(bool actually_merge,
55 int process_id,
56 DOMStorageSession* other,
57 const SessionStorageNamespace::MergeResultCallback& callback);
59 private:
60 friend class base::RefCountedThreadSafe<DOMStorageSession>;
62 DOMStorageSession(DOMStorageContextImpl* context,
63 int64 namespace_id,
64 const std::string& persistent_namespace_id);
65 ~DOMStorageSession();
67 void ProcessMergeResult(
68 bool actually_merge,
69 const SessionStorageNamespace::MergeResultCallback& callback,
70 const std::string& new_persistent_namespace_id,
71 SessionStorageNamespace::MergeResult result);
73 scoped_refptr<DOMStorageContextImpl> context_;
74 int64 namespace_id_;
75 std::string persistent_namespace_id_;
76 bool should_persist_;
78 DISALLOW_IMPLICIT_CONSTRUCTORS(DOMStorageSession);
81 } // namespace content
83 #endif // CONTENT_BROWSER_DOM_STORAGE_DOM_STORAGE_SESSION_H_