OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 WEBKIT_DOM_STORAGE_DOM_STORAGE_CONTEXT_H_ | 5 #ifndef WEBKIT_DOM_STORAGE_DOM_STORAGE_CONTEXT_H_ |
6 #define WEBKIT_DOM_STORAGE_DOM_STORAGE_CONTEXT_H_ | 6 #define WEBKIT_DOM_STORAGE_DOM_STORAGE_CONTEXT_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <set> | 9 #include <set> |
10 #include <vector> | 10 #include <vector> |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 // internal consumption. | 61 // internal consumption. |
62 class WEBKIT_STORAGE_EXPORT DomStorageContext | 62 class WEBKIT_STORAGE_EXPORT DomStorageContext |
63 : public base::RefCountedThreadSafe<DomStorageContext> { | 63 : public base::RefCountedThreadSafe<DomStorageContext> { |
64 public: | 64 public: |
65 // An interface for observing Local and Session Storage events on the | 65 // An interface for observing Local and Session Storage events on the |
66 // background thread. | 66 // background thread. |
67 class EventObserver { | 67 class EventObserver { |
68 public: | 68 public: |
69 virtual void OnDomStorageItemSet( | 69 virtual void OnDomStorageItemSet( |
70 const DomStorageArea* area, | 70 const DomStorageArea* area, |
71 const string16& key, | 71 const base::string16& key, |
72 const string16& new_value, | 72 const base::string16& new_value, |
73 const NullableString16& old_value, // may be null on initial insert | 73 const NullableString16& old_value, // may be null on initial insert |
74 const GURL& page_url) = 0; | 74 const GURL& page_url) = 0; |
75 virtual void OnDomStorageItemRemoved( | 75 virtual void OnDomStorageItemRemoved( |
76 const DomStorageArea* area, | 76 const DomStorageArea* area, |
77 const string16& key, | 77 const base::string16& key, |
78 const string16& old_value, | 78 const base::string16& old_value, |
79 const GURL& page_url) = 0; | 79 const GURL& page_url) = 0; |
80 virtual void OnDomStorageAreaCleared( | 80 virtual void OnDomStorageAreaCleared( |
81 const DomStorageArea* area, | 81 const DomStorageArea* area, |
82 const GURL& page_url) = 0; | 82 const GURL& page_url) = 0; |
83 | 83 |
84 protected: | 84 protected: |
85 virtual ~EventObserver() {} | 85 virtual ~EventObserver() {} |
86 }; | 86 }; |
87 | 87 |
88 DomStorageContext( | 88 DomStorageContext( |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 // and keep data on disk per the content settings and special storage | 124 // and keep data on disk per the content settings and special storage |
125 // policies. Contained areas and namespaces will stop functioning after | 125 // policies. Contained areas and namespaces will stop functioning after |
126 // this method has been called. | 126 // this method has been called. |
127 void Shutdown(); | 127 void Shutdown(); |
128 | 128 |
129 // Methods to add, remove, and notify EventObservers. | 129 // Methods to add, remove, and notify EventObservers. |
130 void AddEventObserver(EventObserver* observer); | 130 void AddEventObserver(EventObserver* observer); |
131 void RemoveEventObserver(EventObserver* observer); | 131 void RemoveEventObserver(EventObserver* observer); |
132 void NotifyItemSet( | 132 void NotifyItemSet( |
133 const DomStorageArea* area, | 133 const DomStorageArea* area, |
134 const string16& key, | 134 const base::string16& key, |
135 const string16& new_value, | 135 const base::string16& new_value, |
136 const NullableString16& old_value, | 136 const NullableString16& old_value, |
137 const GURL& page_url); | 137 const GURL& page_url); |
138 void NotifyItemRemoved( | 138 void NotifyItemRemoved( |
139 const DomStorageArea* area, | 139 const DomStorageArea* area, |
140 const string16& key, | 140 const base::string16& key, |
141 const string16& old_value, | 141 const base::string16& old_value, |
142 const GURL& page_url); | 142 const GURL& page_url); |
143 void NotifyAreaCleared( | 143 void NotifyAreaCleared( |
144 const DomStorageArea* area, | 144 const DomStorageArea* area, |
145 const GURL& page_url); | 145 const GURL& page_url); |
146 | 146 |
147 // May be called on any thread. | 147 // May be called on any thread. |
148 int64 AllocateSessionId() { | 148 int64 AllocateSessionId() { |
149 return session_id_sequence_.GetNext(); | 149 return session_id_sequence_.GetNext(); |
150 } | 150 } |
151 | 151 |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 std::set<std::string> protected_persistent_session_ids_; | 221 std::set<std::string> protected_persistent_session_ids_; |
222 | 222 |
223 // Mapping between persistent namespace IDs and namespace IDs for | 223 // Mapping between persistent namespace IDs and namespace IDs for |
224 // sessionStorage. | 224 // sessionStorage. |
225 std::map<std::string, int64> persistent_namespace_id_to_namespace_id_; | 225 std::map<std::string, int64> persistent_namespace_id_to_namespace_id_; |
226 }; | 226 }; |
227 | 227 |
228 } // namespace dom_storage | 228 } // namespace dom_storage |
229 | 229 |
230 #endif // WEBKIT_DOM_STORAGE_DOM_STORAGE_CONTEXT_H_ | 230 #endif // WEBKIT_DOM_STORAGE_DOM_STORAGE_CONTEXT_H_ |
OLD | NEW |