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 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <map> | 9 #include <map> |
10 #include <set> | |
10 #include <vector> | 11 #include <vector> |
11 | 12 |
12 #include "base/atomic_sequence_num.h" | 13 #include "base/atomic_sequence_num.h" |
13 #include "base/basictypes.h" | 14 #include "base/basictypes.h" |
14 #include "base/file_path.h" | 15 #include "base/file_path.h" |
15 #include "base/gtest_prod_util.h" | 16 #include "base/gtest_prod_util.h" |
16 #include "base/memory/ref_counted.h" | 17 #include "base/memory/ref_counted.h" |
17 #include "base/observer_list.h" | 18 #include "base/observer_list.h" |
18 #include "base/time.h" | 19 #include "base/time.h" |
19 #include "googleurl/src/gurl.h" | 20 #include "googleurl/src/gurl.h" |
20 | 21 |
21 class FilePath; | 22 class FilePath; |
22 class NullableString16; | 23 class NullableString16; |
23 | 24 |
24 namespace base { | 25 namespace base { |
25 class Time; | 26 class Time; |
26 } | 27 } |
27 | 28 |
28 namespace quota { | 29 namespace quota { |
29 class SpecialStoragePolicy; | 30 class SpecialStoragePolicy; |
30 } | 31 } |
31 | 32 |
32 namespace dom_storage { | 33 namespace dom_storage { |
33 | 34 |
34 class DomStorageArea; | 35 class DomStorageArea; |
35 class DomStorageNamespace; | 36 class DomStorageNamespace; |
36 class DomStorageSession; | 37 class DomStorageSession; |
37 class DomStorageTaskRunner; | 38 class DomStorageTaskRunner; |
39 class SessionStorageDatabase; | |
38 | 40 |
39 // The Context is the root of an object containment hierachy for | 41 // The Context is the root of an object containment hierachy for |
40 // Namespaces and Areas related to the owning profile. | 42 // Namespaces and Areas related to the owning profile. |
41 // One instance is allocated in the main process for each profile, | 43 // One instance is allocated in the main process for each profile, |
42 // instance methods should be called serially in the background as | 44 // instance methods should be called serially in the background as |
43 // determined by the task_runner. Specifcally not on chrome's non-blocking | 45 // determined by the task_runner. Specifcally not on chrome's non-blocking |
44 // IO thread since these methods can result in blocking file io. | 46 // IO thread since these methods can result in blocking file io. |
45 // | 47 // |
46 // In general terms, the DomStorage object relationships are... | 48 // In general terms, the DomStorage object relationships are... |
47 // Contexts (per-profile) own Namespaces which own Areas which share Maps. | 49 // Contexts (per-profile) own Namespaces which own Areas which share Maps. |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
146 const GURL& page_url); | 148 const GURL& page_url); |
147 void NotifyAreaCleared( | 149 void NotifyAreaCleared( |
148 const DomStorageArea* area, | 150 const DomStorageArea* area, |
149 const GURL& page_url); | 151 const GURL& page_url); |
150 | 152 |
151 // May be called on any thread. | 153 // May be called on any thread. |
152 int64 AllocateSessionId() { | 154 int64 AllocateSessionId() { |
153 return session_id_sequence_.GetNext(); | 155 return session_id_sequence_.GetNext(); |
154 } | 156 } |
155 | 157 |
158 std::string AllocatePersistentSessionId(); | |
159 | |
156 // Must be called on the background thread. | 160 // Must be called on the background thread. |
157 void CreateSessionNamespace(int64 namespace_id); | 161 void CreateSessionNamespace(int64 namespace_id, |
162 const std::string& persistent_namespace_id); | |
158 void DeleteSessionNamespace(int64 namespace_id); | 163 void DeleteSessionNamespace(int64 namespace_id); |
159 void CloneSessionNamespace(int64 existing_id, int64 new_id); | 164 void CloneSessionNamespace(int64 existing_id, int64 new_id, |
165 const std::string& new_persistent_id); | |
166 | |
167 void DoomSessionStorage(int64 namespace_id); | |
160 | 168 |
161 private: | 169 private: |
162 friend class DomStorageContextTest; | 170 friend class DomStorageContextTest; |
163 FRIEND_TEST_ALL_PREFIXES(DomStorageContextTest, Basics); | 171 FRIEND_TEST_ALL_PREFIXES(DomStorageContextTest, Basics); |
164 friend class base::RefCountedThreadSafe<DomStorageContext>; | 172 friend class base::RefCountedThreadSafe<DomStorageContext>; |
165 typedef std::map<int64, scoped_refptr<DomStorageNamespace> > | 173 typedef std::map<int64, scoped_refptr<DomStorageNamespace> > |
166 StorageNamespaceMap; | 174 StorageNamespaceMap; |
167 | 175 |
168 ~DomStorageContext(); | 176 ~DomStorageContext(); |
169 | 177 |
170 void ClearLocalStateInCommitSequence(); | 178 void ClearLocalStateInCommitSequence(); |
171 | 179 |
180 void DeleteLeftoverDataInCommitSequence(); | |
181 | |
172 // Collection of namespaces keyed by id. | 182 // Collection of namespaces keyed by id. |
173 StorageNamespaceMap namespaces_; | 183 StorageNamespaceMap namespaces_; |
174 | 184 |
175 // Where localstorage data is stored, maybe empty for the incognito use case. | 185 // Where localstorage data is stored, maybe empty for the incognito use case. |
176 FilePath localstorage_directory_; | 186 FilePath localstorage_directory_; |
177 | 187 |
178 // Where sessionstorage data is stored, maybe empty for the incognito use | 188 // Where sessionstorage data is stored, maybe empty for the incognito use |
179 // case. Always empty until the file-backed session storage feature is | 189 // case. Always empty until the file-backed session storage feature is |
180 // implemented. | 190 // implemented. |
181 FilePath sessionstorage_directory_; | 191 FilePath sessionstorage_directory_; |
182 | 192 |
183 // Used to schedule sequenced background tasks. | 193 // Used to schedule sequenced background tasks. |
184 scoped_refptr<DomStorageTaskRunner> task_runner_; | 194 scoped_refptr<DomStorageTaskRunner> task_runner_; |
185 | 195 |
186 // List of objects observing local storage events. | 196 // List of objects observing local storage events. |
187 ObserverList<EventObserver> event_observers_; | 197 ObserverList<EventObserver> event_observers_; |
188 | 198 |
189 // We use a 32 bit identifier for per tab storage sessions. | 199 // We use a 32 bit identifier for per tab storage sessions. |
190 // At a tab per second, this range is large enough for 68 years. | 200 // At a tab per second, this range is large enough for 68 years. |
191 base::AtomicSequenceNumber session_id_sequence_; | 201 base::AtomicSequenceNumber session_id_sequence_; |
192 | 202 |
193 bool is_shutdown_; | 203 bool is_shutdown_; |
194 bool clear_local_state_; | 204 bool clear_local_state_; |
195 bool save_session_state_; | 205 bool save_session_state_; |
196 scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy_; | 206 scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy_; |
207 scoped_refptr<SessionStorageDatabase> session_storage_database_; | |
208 | |
209 // Namespace IDs for sessionStorages which won't be needed for session | |
210 // restore. | |
211 std::set<int64> deletable_session_storages_; | |
michaeln
2012/06/05 01:41:07
would doomed_session_ids_ work as a name? i think
marja
2012/06/06 13:37:10
Changed to "doomed_persistent_session_ids_".
| |
212 | |
213 // Persistent namespace IDs to protect from leftover data deletion (they will | |
214 // be needed for session restore). | |
215 std::set<std::string> protected_session_storages_; | |
197 }; | 216 }; |
198 | 217 |
199 } // namespace dom_storage | 218 } // namespace dom_storage |
200 | 219 |
201 #endif // WEBKIT_DOM_STORAGE_DOM_STORAGE_CONTEXT_H_ | 220 #endif // WEBKIT_DOM_STORAGE_DOM_STORAGE_CONTEXT_H_ |
OLD | NEW |