Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(27)

Side by Side Diff: webkit/dom_storage/dom_storage_context.h

Issue 12398008: Purge in-memory localStorage areas if the # of areas exceeds the limit (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: update Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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>
(...skipping 15 matching lines...) Expand all
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;
36 class DomStorageHost;
36 class DomStorageNamespace; 37 class DomStorageNamespace;
37 class DomStorageSession; 38 class DomStorageSession;
38 class DomStorageTaskRunner; 39 class DomStorageTaskRunner;
39 class SessionStorageDatabase; 40 class SessionStorageDatabase;
40 struct LocalStorageUsageInfo; 41 struct LocalStorageUsageInfo;
41 struct SessionStorageUsageInfo; 42 struct SessionStorageUsageInfo;
42 43
43 // The Context is the root of an object containment hierachy for 44 // The Context is the root of an object containment hierachy for
44 // Namespaces and Areas related to the owning profile. 45 // Namespaces and Areas related to the owning profile.
45 // One instance is allocated in the main process for each profile, 46 // One instance is allocated in the main process for each profile,
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 161
161 // Starts backing sessionStorage on disk. This function must be called right 162 // Starts backing sessionStorage on disk. This function must be called right
162 // after DomStorageContext is created, before it's used. 163 // after DomStorageContext is created, before it's used.
163 void SetSaveSessionStorageOnDisk(); 164 void SetSaveSessionStorageOnDisk();
164 165
165 // Deletes all namespaces which don't have an associated DomStorageNamespace 166 // Deletes all namespaces which don't have an associated DomStorageNamespace
166 // alive. This function is used for deleting possible leftover data after an 167 // alive. This function is used for deleting possible leftover data after an
167 // unclean exit. 168 // unclean exit.
168 void StartScavengingUnusedSessionStorage(); 169 void StartScavengingUnusedSessionStorage();
169 170
171 // Performs a quick check to see if the given item (of |key| and |value|
172 // fits in the cache/storage.
173 // This may trigger aggressive memory purge if the in-memory cache is
174 // getting tight.
175 bool CanSetItem(DomStorageHost* host,
176 int connection_id,
177 const string16& key,
178 const string16& value);
179
170 private: 180 private:
171 friend class DomStorageContextTest; 181 friend class DomStorageContextTest;
172 FRIEND_TEST_ALL_PREFIXES(DomStorageContextTest, Basics); 182 FRIEND_TEST_ALL_PREFIXES(DomStorageContextTest, Basics);
173 friend class base::RefCountedThreadSafe<DomStorageContext>; 183 friend class base::RefCountedThreadSafe<DomStorageContext>;
174 typedef std::map<int64, scoped_refptr<DomStorageNamespace> > 184 typedef std::map<int64, scoped_refptr<DomStorageNamespace> >
175 StorageNamespaceMap; 185 StorageNamespaceMap;
176 186
177 ~DomStorageContext(); 187 ~DomStorageContext();
178 188
179 void ClearSessionOnlyOrigins(); 189 void ClearSessionOnlyOrigins();
180 190
181 // For scavenging unused sessionStorages. 191 // For scavenging unused sessionStorages.
182 void FindUnusedNamespaces(); 192 void FindUnusedNamespaces();
183 void FindUnusedNamespacesInCommitSequence( 193 void FindUnusedNamespacesInCommitSequence(
184 const std::set<std::string>& namespace_ids_in_use, 194 const std::set<std::string>& namespace_ids_in_use,
185 const std::set<std::string>& protected_persistent_session_ids); 195 const std::set<std::string>& protected_persistent_session_ids);
186 void DeleteNextUnusedNamespace(); 196 void DeleteNextUnusedNamespace();
187 void DeleteNextUnusedNamespaceInCommitSequence(); 197 void DeleteNextUnusedNamespaceInCommitSequence();
188 198
199 // This forces the context to re-calculate the total area size next time
200 // GetInMemoryAreaSize() is called.
201 void InvalidateInMemoryAreaSize() {
202 total_area_size_ = -1;
203 }
204 int64 GetRemainingCacheSize();
205
189 // Collection of namespaces keyed by id. 206 // Collection of namespaces keyed by id.
190 StorageNamespaceMap namespaces_; 207 StorageNamespaceMap namespaces_;
191 208
192 // Where localstorage data is stored, maybe empty for the incognito use case. 209 // Where localstorage data is stored, maybe empty for the incognito use case.
193 base::FilePath localstorage_directory_; 210 base::FilePath localstorage_directory_;
194 211
195 // Where sessionstorage data is stored, maybe empty for the incognito use 212 // Where sessionstorage data is stored, maybe empty for the incognito use
196 // case. Always empty until the file-backed session storage feature is 213 // case. Always empty until the file-backed session storage feature is
197 // implemented. 214 // implemented.
198 base::FilePath sessionstorage_directory_; 215 base::FilePath sessionstorage_directory_;
(...skipping 17 matching lines...) Expand all
216 bool scavenging_started_; 233 bool scavenging_started_;
217 std::vector<std::string> deletable_persistent_namespace_ids_; 234 std::vector<std::string> deletable_persistent_namespace_ids_;
218 235
219 // Persistent namespace IDs to protect from gradual deletion (they will 236 // Persistent namespace IDs to protect from gradual deletion (they will
220 // be needed for session restore). 237 // be needed for session restore).
221 std::set<std::string> protected_persistent_session_ids_; 238 std::set<std::string> protected_persistent_session_ids_;
222 239
223 // Mapping between persistent namespace IDs and namespace IDs for 240 // Mapping between persistent namespace IDs and namespace IDs for
224 // sessionStorage. 241 // sessionStorage.
225 std::map<std::string, int64> persistent_namespace_id_to_namespace_id_; 242 std::map<std::string, int64> persistent_namespace_id_to_namespace_id_;
243
244 // Total in-memory map size.
245 int64 total_area_size_;
226 }; 246 };
227 247
228 } // namespace dom_storage 248 } // namespace dom_storage
229 249
230 #endif // WEBKIT_DOM_STORAGE_DOM_STORAGE_CONTEXT_H_ 250 #endif // WEBKIT_DOM_STORAGE_DOM_STORAGE_CONTEXT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698