OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CONTENT_BROWSER_DOM_STORAGE_DOM_STORAGE_SESSION_H_ | 5 #ifndef CONTENT_BROWSER_DOM_STORAGE_DOM_STORAGE_SESSION_H_ |
6 #define CONTENT_BROWSER_DOM_STORAGE_DOM_STORAGE_SESSION_H_ | 6 #define CONTENT_BROWSER_DOM_STORAGE_DOM_STORAGE_SESSION_H_ |
7 | 7 |
| 8 #include <stdint.h> |
| 9 |
8 #include <string> | 10 #include <string> |
9 | 11 |
10 #include "base/basictypes.h" | 12 #include "base/macros.h" |
11 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
12 #include "content/common/content_export.h" | 14 #include "content/common/content_export.h" |
13 | 15 |
14 namespace content { | 16 namespace content { |
15 | 17 |
16 class DOMStorageContextImpl; | 18 class DOMStorageContextImpl; |
17 | 19 |
18 // This refcounted class determines the lifetime of a session | 20 // This refcounted class determines the lifetime of a session |
19 // storage namespace and provides an interface to Clone() an | 21 // storage namespace and provides an interface to Clone() an |
20 // existing session storage namespace. It may be used on any thread. | 22 // existing session storage namespace. It may be used on any thread. |
21 // See class comments for DOMStorageContextImpl for a larger overview. | 23 // See class comments for DOMStorageContextImpl for a larger overview. |
22 class CONTENT_EXPORT DOMStorageSession | 24 class CONTENT_EXPORT DOMStorageSession |
23 : public base::RefCountedThreadSafe<DOMStorageSession> { | 25 : public base::RefCountedThreadSafe<DOMStorageSession> { |
24 public: | 26 public: |
25 // Constructs a |DOMStorageSession| and allocates new IDs for it. | 27 // Constructs a |DOMStorageSession| and allocates new IDs for it. |
26 explicit DOMStorageSession(DOMStorageContextImpl* context); | 28 explicit DOMStorageSession(DOMStorageContextImpl* context); |
27 | 29 |
28 // Constructs a |DOMStorageSession| and assigns |persistent_namespace_id| | 30 // Constructs a |DOMStorageSession| and assigns |persistent_namespace_id| |
29 // to it. Allocates a new non-persistent ID. | 31 // to it. Allocates a new non-persistent ID. |
30 DOMStorageSession(DOMStorageContextImpl* context, | 32 DOMStorageSession(DOMStorageContextImpl* context, |
31 const std::string& persistent_namespace_id); | 33 const std::string& persistent_namespace_id); |
32 | 34 |
33 int64 namespace_id() const { return namespace_id_; } | 35 int64_t namespace_id() const { return namespace_id_; } |
34 const std::string& persistent_namespace_id() const { | 36 const std::string& persistent_namespace_id() const { |
35 return persistent_namespace_id_; | 37 return persistent_namespace_id_; |
36 } | 38 } |
37 void SetShouldPersist(bool should_persist); | 39 void SetShouldPersist(bool should_persist); |
38 bool should_persist() const; | 40 bool should_persist() const; |
39 bool IsFromContext(DOMStorageContextImpl* context); | 41 bool IsFromContext(DOMStorageContextImpl* context); |
40 DOMStorageSession* Clone(); | 42 DOMStorageSession* Clone(); |
41 | 43 |
42 // Constructs a |DOMStorageSession| by cloning | 44 // Constructs a |DOMStorageSession| by cloning |
43 // |namespace_id_to_clone|. Allocates new IDs for it. | 45 // |namespace_id_to_clone|. Allocates new IDs for it. |
44 static DOMStorageSession* CloneFrom(DOMStorageContextImpl* context, | 46 static DOMStorageSession* CloneFrom(DOMStorageContextImpl* context, |
45 int64 namepace_id_to_clone); | 47 int64_t namepace_id_to_clone); |
46 | 48 |
47 private: | 49 private: |
48 friend class base::RefCountedThreadSafe<DOMStorageSession>; | 50 friend class base::RefCountedThreadSafe<DOMStorageSession>; |
49 | 51 |
50 DOMStorageSession(DOMStorageContextImpl* context, | 52 DOMStorageSession(DOMStorageContextImpl* context, |
51 int64 namespace_id, | 53 int64_t namespace_id, |
52 const std::string& persistent_namespace_id); | 54 const std::string& persistent_namespace_id); |
53 ~DOMStorageSession(); | 55 ~DOMStorageSession(); |
54 | 56 |
55 scoped_refptr<DOMStorageContextImpl> context_; | 57 scoped_refptr<DOMStorageContextImpl> context_; |
56 int64 namespace_id_; | 58 int64_t namespace_id_; |
57 std::string persistent_namespace_id_; | 59 std::string persistent_namespace_id_; |
58 bool should_persist_; | 60 bool should_persist_; |
59 | 61 |
60 DISALLOW_IMPLICIT_CONSTRUCTORS(DOMStorageSession); | 62 DISALLOW_IMPLICIT_CONSTRUCTORS(DOMStorageSession); |
61 }; | 63 }; |
62 | 64 |
63 } // namespace content | 65 } // namespace content |
64 | 66 |
65 #endif // CONTENT_BROWSER_DOM_STORAGE_DOM_STORAGE_SESSION_H_ | 67 #endif // CONTENT_BROWSER_DOM_STORAGE_DOM_STORAGE_SESSION_H_ |
OLD | NEW |