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 <stdint.h> |
| 9 |
8 #include <map> | 10 #include <map> |
9 #include <set> | 11 #include <set> |
10 #include <string> | 12 #include <string> |
11 #include <vector> | 13 #include <vector> |
12 | 14 |
13 #include "base/atomic_sequence_num.h" | 15 #include "base/atomic_sequence_num.h" |
14 #include "base/basictypes.h" | |
15 #include "base/files/file_path.h" | 16 #include "base/files/file_path.h" |
16 #include "base/gtest_prod_util.h" | 17 #include "base/gtest_prod_util.h" |
17 #include "base/memory/ref_counted.h" | 18 #include "base/memory/ref_counted.h" |
18 #include "base/observer_list.h" | 19 #include "base/observer_list.h" |
19 #include "base/time/time.h" | 20 #include "base/time/time.h" |
20 #include "content/common/content_export.h" | 21 #include "content/common/content_export.h" |
21 #include "url/gurl.h" | 22 #include "url/gurl.h" |
22 | 23 |
23 namespace base { | 24 namespace base { |
24 class FilePath; | 25 class FilePath; |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 return localstorage_directory_; | 100 return localstorage_directory_; |
100 } | 101 } |
101 | 102 |
102 // Returns the directory path for sessionStorage, or an empty directory, if | 103 // Returns the directory path for sessionStorage, or an empty directory, if |
103 // there is no backing on disk. | 104 // there is no backing on disk. |
104 const base::FilePath& sessionstorage_directory() { | 105 const base::FilePath& sessionstorage_directory() { |
105 return sessionstorage_directory_; | 106 return sessionstorage_directory_; |
106 } | 107 } |
107 | 108 |
108 DOMStorageTaskRunner* task_runner() const { return task_runner_.get(); } | 109 DOMStorageTaskRunner* task_runner() const { return task_runner_.get(); } |
109 DOMStorageNamespace* GetStorageNamespace(int64 namespace_id); | 110 DOMStorageNamespace* GetStorageNamespace(int64_t namespace_id); |
110 | 111 |
111 void GetLocalStorageUsage(std::vector<LocalStorageUsageInfo>* infos, | 112 void GetLocalStorageUsage(std::vector<LocalStorageUsageInfo>* infos, |
112 bool include_file_info); | 113 bool include_file_info); |
113 void GetSessionStorageUsage(std::vector<SessionStorageUsageInfo>* infos); | 114 void GetSessionStorageUsage(std::vector<SessionStorageUsageInfo>* infos); |
114 void DeleteLocalStorage(const GURL& origin); | 115 void DeleteLocalStorage(const GURL& origin); |
115 void DeleteSessionStorage(const SessionStorageUsageInfo& usage_info); | 116 void DeleteSessionStorage(const SessionStorageUsageInfo& usage_info); |
116 | 117 |
117 // Used by content settings to alter the behavior around | 118 // Used by content settings to alter the behavior around |
118 // what data to keep and what data to discard at shutdown. | 119 // what data to keep and what data to discard at shutdown. |
119 // The policy is not so straight forward to describe, see | 120 // The policy is not so straight forward to describe, see |
(...skipping 25 matching lines...) Expand all Loading... |
145 void NotifyItemRemoved( | 146 void NotifyItemRemoved( |
146 const DOMStorageArea* area, | 147 const DOMStorageArea* area, |
147 const base::string16& key, | 148 const base::string16& key, |
148 const base::string16& old_value, | 149 const base::string16& old_value, |
149 const GURL& page_url); | 150 const GURL& page_url); |
150 void NotifyAreaCleared( | 151 void NotifyAreaCleared( |
151 const DOMStorageArea* area, | 152 const DOMStorageArea* area, |
152 const GURL& page_url); | 153 const GURL& page_url); |
153 | 154 |
154 // May be called on any thread. | 155 // May be called on any thread. |
155 int64 AllocateSessionId(); | 156 int64_t AllocateSessionId(); |
156 std::string AllocatePersistentSessionId(); | 157 std::string AllocatePersistentSessionId(); |
157 | 158 |
158 // Must be called on the background thread. | 159 // Must be called on the background thread. |
159 void CreateSessionNamespace(int64 namespace_id, | 160 void CreateSessionNamespace(int64_t namespace_id, |
160 const std::string& persistent_namespace_id); | 161 const std::string& persistent_namespace_id); |
161 void DeleteSessionNamespace(int64 namespace_id, bool should_persist_data); | 162 void DeleteSessionNamespace(int64_t namespace_id, bool should_persist_data); |
162 void CloneSessionNamespace(int64 existing_id, int64 new_id, | 163 void CloneSessionNamespace(int64_t existing_id, |
| 164 int64_t new_id, |
163 const std::string& new_persistent_id); | 165 const std::string& new_persistent_id); |
164 | 166 |
165 // Starts backing sessionStorage on disk. This function must be called right | 167 // Starts backing sessionStorage on disk. This function must be called right |
166 // after DOMStorageContextImpl is created, before it's used. | 168 // after DOMStorageContextImpl is created, before it's used. |
167 void SetSaveSessionStorageOnDisk(); | 169 void SetSaveSessionStorageOnDisk(); |
168 | 170 |
169 // Deletes all namespaces which don't have an associated DOMStorageNamespace | 171 // Deletes all namespaces which don't have an associated DOMStorageNamespace |
170 // alive. This function is used for deleting possible leftover data after an | 172 // alive. This function is used for deleting possible leftover data after an |
171 // unclean exit. | 173 // unclean exit. |
172 void StartScavengingUnusedSessionStorage(); | 174 void StartScavengingUnusedSessionStorage(); |
173 | 175 |
174 private: | 176 private: |
175 friend class DOMStorageContextImplTest; | 177 friend class DOMStorageContextImplTest; |
176 FRIEND_TEST_ALL_PREFIXES(DOMStorageContextImplTest, Basics); | 178 FRIEND_TEST_ALL_PREFIXES(DOMStorageContextImplTest, Basics); |
177 friend class base::RefCountedThreadSafe<DOMStorageContextImpl>; | 179 friend class base::RefCountedThreadSafe<DOMStorageContextImpl>; |
178 typedef std::map<int64, scoped_refptr<DOMStorageNamespace> > | 180 typedef std::map<int64_t, scoped_refptr<DOMStorageNamespace>> |
179 StorageNamespaceMap; | 181 StorageNamespaceMap; |
180 | 182 |
181 ~DOMStorageContextImpl(); | 183 ~DOMStorageContextImpl(); |
182 | 184 |
183 void ClearSessionOnlyOrigins(); | 185 void ClearSessionOnlyOrigins(); |
184 | 186 |
185 // For scavenging unused sessionStorages. | 187 // For scavenging unused sessionStorages. |
186 void FindUnusedNamespaces(); | 188 void FindUnusedNamespaces(); |
187 void FindUnusedNamespacesInCommitSequence( | 189 void FindUnusedNamespacesInCommitSequence( |
188 const std::set<std::string>& namespace_ids_in_use, | 190 const std::set<std::string>& namespace_ids_in_use, |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
222 // For cleaning up unused namespaces gradually. | 224 // For cleaning up unused namespaces gradually. |
223 bool scavenging_started_; | 225 bool scavenging_started_; |
224 std::vector<std::string> deletable_persistent_namespace_ids_; | 226 std::vector<std::string> deletable_persistent_namespace_ids_; |
225 | 227 |
226 // Persistent namespace IDs to protect from gradual deletion (they will | 228 // Persistent namespace IDs to protect from gradual deletion (they will |
227 // be needed for session restore). | 229 // be needed for session restore). |
228 std::set<std::string> protected_persistent_session_ids_; | 230 std::set<std::string> protected_persistent_session_ids_; |
229 | 231 |
230 // Mapping between persistent namespace IDs and namespace IDs for | 232 // Mapping between persistent namespace IDs and namespace IDs for |
231 // sessionStorage. | 233 // sessionStorage. |
232 std::map<std::string, int64> persistent_namespace_id_to_namespace_id_; | 234 std::map<std::string, int64_t> persistent_namespace_id_to_namespace_id_; |
233 }; | 235 }; |
234 | 236 |
235 } // namespace content | 237 } // namespace content |
236 | 238 |
237 #endif // CONTENT_BROWSER_DOM_STORAGE_DOM_STORAGE_CONTEXT_IMPL_H_ | 239 #endif // CONTENT_BROWSER_DOM_STORAGE_DOM_STORAGE_CONTEXT_IMPL_H_ |
OLD | NEW |