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 CONTENT_BROWSER_DOM_STORAGE_DOM_STORAGE_CONTEXT_IMPL_H_ | 5 #ifndef CONTENT_BROWSER_DOM_STORAGE_DOM_STORAGE_CONTEXT_IMPL_H_ |
6 #define CONTENT_BROWSER_DOM_STORAGE_DOM_STORAGE_CONTEXT_IMPL_H_ | 6 #define CONTENT_BROWSER_DOM_STORAGE_DOM_STORAGE_CONTEXT_IMPL_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <set> | 9 #include <set> |
10 #include <vector> | 10 #include <vector> |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 void NotifyItemRemoved( | 140 void NotifyItemRemoved( |
141 const DOMStorageArea* area, | 141 const DOMStorageArea* area, |
142 const base::string16& key, | 142 const base::string16& key, |
143 const base::string16& old_value, | 143 const base::string16& old_value, |
144 const GURL& page_url); | 144 const GURL& page_url); |
145 void NotifyAreaCleared( | 145 void NotifyAreaCleared( |
146 const DOMStorageArea* area, | 146 const DOMStorageArea* area, |
147 const GURL& page_url); | 147 const GURL& page_url); |
148 | 148 |
149 // May be called on any thread. | 149 // May be called on any thread. |
150 int64 AllocateSessionId() { | 150 int64 AllocateSessionId(); |
151 return session_id_sequence_.GetNext(); | |
152 } | |
153 | |
154 std::string AllocatePersistentSessionId(); | 151 std::string AllocatePersistentSessionId(); |
155 | 152 |
156 // Must be called on the background thread. | 153 // Must be called on the background thread. |
157 void CreateSessionNamespace(int64 namespace_id, | 154 void CreateSessionNamespace(int64 namespace_id, |
158 const std::string& persistent_namespace_id); | 155 const std::string& persistent_namespace_id); |
159 void DeleteSessionNamespace(int64 namespace_id, bool should_persist_data); | 156 void DeleteSessionNamespace(int64 namespace_id, bool should_persist_data); |
160 void CloneSessionNamespace(int64 existing_id, int64 new_id, | 157 void CloneSessionNamespace(int64 existing_id, int64 new_id, |
161 const std::string& new_persistent_id); | 158 const std::string& new_persistent_id); |
162 | 159 |
163 // Starts backing sessionStorage on disk. This function must be called right | 160 // Starts backing sessionStorage on disk. This function must be called right |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 base::FilePath sessionstorage_directory_; | 197 base::FilePath sessionstorage_directory_; |
201 | 198 |
202 // Used to schedule sequenced background tasks. | 199 // Used to schedule sequenced background tasks. |
203 scoped_refptr<DOMStorageTaskRunner> task_runner_; | 200 scoped_refptr<DOMStorageTaskRunner> task_runner_; |
204 | 201 |
205 // List of objects observing local storage events. | 202 // List of objects observing local storage events. |
206 ObserverList<EventObserver> event_observers_; | 203 ObserverList<EventObserver> event_observers_; |
207 | 204 |
208 // We use a 32 bit identifier for per tab storage sessions. | 205 // We use a 32 bit identifier for per tab storage sessions. |
209 // At a tab per second, this range is large enough for 68 years. | 206 // At a tab per second, this range is large enough for 68 years. |
| 207 // The offset is to more quickly detect the error condition where |
| 208 // an id related to one context is mistakenly used in another. |
210 base::AtomicSequenceNumber session_id_sequence_; | 209 base::AtomicSequenceNumber session_id_sequence_; |
| 210 const int session_id_offset_; |
211 | 211 |
212 bool is_shutdown_; | 212 bool is_shutdown_; |
213 bool force_keep_session_state_; | 213 bool force_keep_session_state_; |
214 scoped_refptr<storage::SpecialStoragePolicy> special_storage_policy_; | 214 scoped_refptr<storage::SpecialStoragePolicy> special_storage_policy_; |
215 scoped_refptr<SessionStorageDatabase> session_storage_database_; | 215 scoped_refptr<SessionStorageDatabase> session_storage_database_; |
216 | 216 |
217 // For cleaning up unused namespaces gradually. | 217 // For cleaning up unused namespaces gradually. |
218 bool scavenging_started_; | 218 bool scavenging_started_; |
219 std::vector<std::string> deletable_persistent_namespace_ids_; | 219 std::vector<std::string> deletable_persistent_namespace_ids_; |
220 | 220 |
221 // Persistent namespace IDs to protect from gradual deletion (they will | 221 // Persistent namespace IDs to protect from gradual deletion (they will |
222 // be needed for session restore). | 222 // be needed for session restore). |
223 std::set<std::string> protected_persistent_session_ids_; | 223 std::set<std::string> protected_persistent_session_ids_; |
224 | 224 |
225 // Mapping between persistent namespace IDs and namespace IDs for | 225 // Mapping between persistent namespace IDs and namespace IDs for |
226 // sessionStorage. | 226 // sessionStorage. |
227 std::map<std::string, int64> persistent_namespace_id_to_namespace_id_; | 227 std::map<std::string, int64> persistent_namespace_id_to_namespace_id_; |
228 }; | 228 }; |
229 | 229 |
230 } // namespace content | 230 } // namespace content |
231 | 231 |
232 #endif // CONTENT_BROWSER_DOM_STORAGE_DOM_STORAGE_CONTEXT_IMPL_H_ | 232 #endif // CONTENT_BROWSER_DOM_STORAGE_DOM_STORAGE_CONTEXT_IMPL_H_ |
OLD | NEW |