| 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> |
| 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/file_path.h" | 14 #include "base/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.h" | 18 #include "base/time.h" |
| 19 #include "googleurl/src/gurl.h" | 19 #include "googleurl/src/gurl.h" |
| 20 #include "webkit/storage/webkit_storage_export.h" | 20 #include "webkit/storage/webkit_storage_export.h" |
| 21 | 21 |
| 22 class FilePath; | |
| 23 class NullableString16; | 22 class NullableString16; |
| 24 | 23 |
| 25 namespace base { | 24 namespace base { |
| 25 class FilePath; |
| 26 class Time; | 26 class Time; |
| 27 } | 27 } |
| 28 | 28 |
| 29 namespace quota { | 29 namespace quota { |
| 30 class SpecialStoragePolicy; | 30 class SpecialStoragePolicy; |
| 31 } | 31 } |
| 32 | 32 |
| 33 namespace dom_storage { | 33 namespace dom_storage { |
| 34 | 34 |
| 35 class DomStorageArea; | 35 class DomStorageArea; |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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( |
| 89 const FilePath& localstorage_directory, // empty for incognito profiles | 89 const base::FilePath& localstorage_directory, // empty for incognito prof
iles |
| 90 const FilePath& sessionstorage_directory, // empty for incognito profiles | 90 const base::FilePath& sessionstorage_directory, // empty for incognito pr
ofiles |
| 91 quota::SpecialStoragePolicy* special_storage_policy, | 91 quota::SpecialStoragePolicy* special_storage_policy, |
| 92 DomStorageTaskRunner* task_runner); | 92 DomStorageTaskRunner* task_runner); |
| 93 | 93 |
| 94 // Returns the directory path for localStorage, or an empty directory, if | 94 // Returns the directory path for localStorage, or an empty directory, if |
| 95 // there is no backing on disk. | 95 // there is no backing on disk. |
| 96 const FilePath& localstorage_directory() { return localstorage_directory_; } | 96 const base::FilePath& localstorage_directory() { return localstorage_directory
_; } |
| 97 | 97 |
| 98 // Returns the directory path for sessionStorage, or an empty directory, if | 98 // Returns the directory path for sessionStorage, or an empty directory, if |
| 99 // there is no backing on disk. | 99 // there is no backing on disk. |
| 100 const FilePath& sessionstorage_directory() { | 100 const base::FilePath& sessionstorage_directory() { |
| 101 return sessionstorage_directory_; | 101 return sessionstorage_directory_; |
| 102 } | 102 } |
| 103 | 103 |
| 104 DomStorageTaskRunner* task_runner() const { return task_runner_; } | 104 DomStorageTaskRunner* task_runner() const { return task_runner_; } |
| 105 DomStorageNamespace* GetStorageNamespace(int64 namespace_id); | 105 DomStorageNamespace* GetStorageNamespace(int64 namespace_id); |
| 106 | 106 |
| 107 void GetLocalStorageUsage(std::vector<LocalStorageUsageInfo>* infos, | 107 void GetLocalStorageUsage(std::vector<LocalStorageUsageInfo>* infos, |
| 108 bool include_file_info); | 108 bool include_file_info); |
| 109 void GetSessionStorageUsage(std::vector<SessionStorageUsageInfo>* infos); | 109 void GetSessionStorageUsage(std::vector<SessionStorageUsageInfo>* infos); |
| 110 void DeleteLocalStorage(const GURL& origin); | 110 void DeleteLocalStorage(const GURL& origin); |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 void FindUnusedNamespacesInCommitSequence( | 183 void FindUnusedNamespacesInCommitSequence( |
| 184 const std::set<std::string>& namespace_ids_in_use, | 184 const std::set<std::string>& namespace_ids_in_use, |
| 185 const std::set<std::string>& protected_persistent_session_ids); | 185 const std::set<std::string>& protected_persistent_session_ids); |
| 186 void DeleteNextUnusedNamespace(); | 186 void DeleteNextUnusedNamespace(); |
| 187 void DeleteNextUnusedNamespaceInCommitSequence(); | 187 void DeleteNextUnusedNamespaceInCommitSequence(); |
| 188 | 188 |
| 189 // Collection of namespaces keyed by id. | 189 // Collection of namespaces keyed by id. |
| 190 StorageNamespaceMap namespaces_; | 190 StorageNamespaceMap namespaces_; |
| 191 | 191 |
| 192 // Where localstorage data is stored, maybe empty for the incognito use case. | 192 // Where localstorage data is stored, maybe empty for the incognito use case. |
| 193 FilePath localstorage_directory_; | 193 base::FilePath localstorage_directory_; |
| 194 | 194 |
| 195 // Where sessionstorage data is stored, maybe empty for the incognito use | 195 // Where sessionstorage data is stored, maybe empty for the incognito use |
| 196 // case. Always empty until the file-backed session storage feature is | 196 // case. Always empty until the file-backed session storage feature is |
| 197 // implemented. | 197 // implemented. |
| 198 FilePath sessionstorage_directory_; | 198 base::FilePath sessionstorage_directory_; |
| 199 | 199 |
| 200 // Used to schedule sequenced background tasks. | 200 // Used to schedule sequenced background tasks. |
| 201 scoped_refptr<DomStorageTaskRunner> task_runner_; | 201 scoped_refptr<DomStorageTaskRunner> task_runner_; |
| 202 | 202 |
| 203 // List of objects observing local storage events. | 203 // List of objects observing local storage events. |
| 204 ObserverList<EventObserver> event_observers_; | 204 ObserverList<EventObserver> event_observers_; |
| 205 | 205 |
| 206 // We use a 32 bit identifier for per tab storage sessions. | 206 // We use a 32 bit identifier for per tab storage sessions. |
| 207 // At a tab per second, this range is large enough for 68 years. | 207 // At a tab per second, this range is large enough for 68 years. |
| 208 base::AtomicSequenceNumber session_id_sequence_; | 208 base::AtomicSequenceNumber session_id_sequence_; |
| (...skipping 12 matching lines...) Expand all 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 |