| 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> |
| 11 | 11 |
| 12 #include "base/atomic_sequence_num.h" | 12 #include "base/atomic_sequence_num.h" |
| 13 #include "base/basictypes.h" | 13 #include "base/basictypes.h" |
| 14 #include "base/files/file_path.h" | 14 #include "base/files/file_path.h" |
| 15 #include "base/gtest_prod_util.h" | 15 #include "base/gtest_prod_util.h" |
| 16 #include "base/memory/ref_counted.h" | 16 #include "base/memory/ref_counted.h" |
| 17 #include "base/observer_list.h" | 17 #include "base/observer_list.h" |
| 18 #include "base/time/time.h" | 18 #include "base/time/time.h" |
| 19 #include "content/browser/dom_storage/dom_storage_namespace.h" | 19 #include "content/browser/dom_storage/dom_storage_namespace.h" |
| 20 #include "content/common/content_export.h" | 20 #include "content/common/content_export.h" |
| 21 #include "content/public/browser/session_storage_namespace.h" | 21 #include "content/public/browser/session_storage_namespace.h" |
| 22 #include "url/gurl.h" | 22 #include "url/gurl.h" |
| 23 | 23 |
| 24 namespace base { | 24 namespace base { |
| 25 class FilePath; | 25 class FilePath; |
| 26 class NullableString16; | 26 class NullableString16; |
| 27 class Time; | 27 class Time; |
| 28 } | 28 } |
| 29 | 29 |
| 30 namespace quota { | 30 namespace storage { |
| 31 class SpecialStoragePolicy; | 31 class SpecialStoragePolicy; |
| 32 } | 32 } |
| 33 | 33 |
| 34 namespace content { | 34 namespace content { |
| 35 | 35 |
| 36 class DOMStorageArea; | 36 class DOMStorageArea; |
| 37 class DOMStorageSession; | 37 class DOMStorageSession; |
| 38 class DOMStorageTaskRunner; | 38 class DOMStorageTaskRunner; |
| 39 class SessionStorageDatabase; | 39 class SessionStorageDatabase; |
| 40 struct LocalStorageUsageInfo; | 40 struct LocalStorageUsageInfo; |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 // Indicates that cached values of the DOM Storage provided must be | 84 // Indicates that cached values of the DOM Storage provided must be |
| 85 // cleared and retrieved again. | 85 // cleared and retrieved again. |
| 86 virtual void OnDOMSessionStorageReset(int64 namespace_id) = 0; | 86 virtual void OnDOMSessionStorageReset(int64 namespace_id) = 0; |
| 87 | 87 |
| 88 protected: | 88 protected: |
| 89 virtual ~EventObserver() {} | 89 virtual ~EventObserver() {} |
| 90 }; | 90 }; |
| 91 | 91 |
| 92 // |localstorage_directory| and |sessionstorage_directory| may be empty | 92 // |localstorage_directory| and |sessionstorage_directory| may be empty |
| 93 // for incognito browser contexts. | 93 // for incognito browser contexts. |
| 94 DOMStorageContextImpl( | 94 DOMStorageContextImpl(const base::FilePath& localstorage_directory, |
| 95 const base::FilePath& localstorage_directory, | 95 const base::FilePath& sessionstorage_directory, |
| 96 const base::FilePath& sessionstorage_directory, | 96 storage::SpecialStoragePolicy* special_storage_policy, |
| 97 quota::SpecialStoragePolicy* special_storage_policy, | 97 DOMStorageTaskRunner* task_runner); |
| 98 DOMStorageTaskRunner* task_runner); | |
| 99 | 98 |
| 100 // Returns the directory path for localStorage, or an empty directory, if | 99 // Returns the directory path for localStorage, or an empty directory, if |
| 101 // there is no backing on disk. | 100 // there is no backing on disk. |
| 102 const base::FilePath& localstorage_directory() { | 101 const base::FilePath& localstorage_directory() { |
| 103 return localstorage_directory_; | 102 return localstorage_directory_; |
| 104 } | 103 } |
| 105 | 104 |
| 106 // Returns the directory path for sessionStorage, or an empty directory, if | 105 // Returns the directory path for sessionStorage, or an empty directory, if |
| 107 // there is no backing on disk. | 106 // there is no backing on disk. |
| 108 const base::FilePath& sessionstorage_directory() { | 107 const base::FilePath& sessionstorage_directory() { |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 | 223 |
| 225 // List of objects observing local storage events. | 224 // List of objects observing local storage events. |
| 226 ObserverList<EventObserver> event_observers_; | 225 ObserverList<EventObserver> event_observers_; |
| 227 | 226 |
| 228 // We use a 32 bit identifier for per tab storage sessions. | 227 // We use a 32 bit identifier for per tab storage sessions. |
| 229 // At a tab per second, this range is large enough for 68 years. | 228 // At a tab per second, this range is large enough for 68 years. |
| 230 base::AtomicSequenceNumber session_id_sequence_; | 229 base::AtomicSequenceNumber session_id_sequence_; |
| 231 | 230 |
| 232 bool is_shutdown_; | 231 bool is_shutdown_; |
| 233 bool force_keep_session_state_; | 232 bool force_keep_session_state_; |
| 234 scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy_; | 233 scoped_refptr<storage::SpecialStoragePolicy> special_storage_policy_; |
| 235 scoped_refptr<SessionStorageDatabase> session_storage_database_; | 234 scoped_refptr<SessionStorageDatabase> session_storage_database_; |
| 236 | 235 |
| 237 // For cleaning up unused namespaces gradually. | 236 // For cleaning up unused namespaces gradually. |
| 238 bool scavenging_started_; | 237 bool scavenging_started_; |
| 239 std::vector<std::string> deletable_persistent_namespace_ids_; | 238 std::vector<std::string> deletable_persistent_namespace_ids_; |
| 240 | 239 |
| 241 // Persistent namespace IDs to protect from gradual deletion (they will | 240 // Persistent namespace IDs to protect from gradual deletion (they will |
| 242 // be needed for session restore). | 241 // be needed for session restore). |
| 243 std::set<std::string> protected_persistent_session_ids_; | 242 std::set<std::string> protected_persistent_session_ids_; |
| 244 | 243 |
| 245 // Mapping between persistent namespace IDs and namespace IDs for | 244 // Mapping between persistent namespace IDs and namespace IDs for |
| 246 // sessionStorage. | 245 // sessionStorage. |
| 247 std::map<std::string, int64> persistent_namespace_id_to_namespace_id_; | 246 std::map<std::string, int64> persistent_namespace_id_to_namespace_id_; |
| 248 }; | 247 }; |
| 249 | 248 |
| 250 } // namespace content | 249 } // namespace content |
| 251 | 250 |
| 252 #endif // CONTENT_BROWSER_DOM_STORAGE_DOM_STORAGE_CONTEXT_IMPL_H_ | 251 #endif // CONTENT_BROWSER_DOM_STORAGE_DOM_STORAGE_CONTEXT_IMPL_H_ |
| OLD | NEW |