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

Unified 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, 10 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 side-by-side diff with in-line comments
Download patch
Index: webkit/dom_storage/dom_storage_context.h
diff --git a/webkit/dom_storage/dom_storage_context.h b/webkit/dom_storage/dom_storage_context.h
index 20ae0ed7fbf740a9dcc3339cfce2e2d498e2482c..b2f7332b8aaa628ebda723e303bc3645350744fd 100644
--- a/webkit/dom_storage/dom_storage_context.h
+++ b/webkit/dom_storage/dom_storage_context.h
@@ -33,6 +33,7 @@ class SpecialStoragePolicy;
namespace dom_storage {
class DomStorageArea;
+class DomStorageHost;
class DomStorageNamespace;
class DomStorageSession;
class DomStorageTaskRunner;
@@ -167,6 +168,15 @@ class WEBKIT_STORAGE_EXPORT DomStorageContext
// unclean exit.
void StartScavengingUnusedSessionStorage();
+ // Performs a quick check to see if the given item (of |key| and |value|
+ // fits in the cache/storage.
+ // This may trigger aggressive memory purge if the in-memory cache is
+ // getting tight.
+ bool CanSetItem(DomStorageHost* host,
+ int connection_id,
+ const string16& key,
+ const string16& value);
+
private:
friend class DomStorageContextTest;
FRIEND_TEST_ALL_PREFIXES(DomStorageContextTest, Basics);
@@ -186,6 +196,13 @@ class WEBKIT_STORAGE_EXPORT DomStorageContext
void DeleteNextUnusedNamespace();
void DeleteNextUnusedNamespaceInCommitSequence();
+ // This forces the context to re-calculate the total area size next time
+ // GetInMemoryAreaSize() is called.
+ void InvalidateInMemoryAreaSize() {
+ total_area_size_ = -1;
+ }
+ int64 GetRemainingCacheSize();
+
// Collection of namespaces keyed by id.
StorageNamespaceMap namespaces_;
@@ -223,6 +240,9 @@ class WEBKIT_STORAGE_EXPORT DomStorageContext
// Mapping between persistent namespace IDs and namespace IDs for
// sessionStorage.
std::map<std::string, int64> persistent_namespace_id_to_namespace_id_;
+
+ // Total in-memory map size.
+ int64 total_area_size_;
};
} // namespace dom_storage

Powered by Google App Engine
This is Rietveld 408576698