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

Unified Diff: webkit/dom_storage/dom_storage_host.cc

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: 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 side-by-side diff with in-line comments
Download patch
Index: webkit/dom_storage/dom_storage_host.cc
diff --git a/webkit/dom_storage/dom_storage_host.cc b/webkit/dom_storage/dom_storage_host.cc
index a8637e0641bb9224623ef5c2e84f5bdf1a597e1c..1883d8aff9b232a3514975cef509fef65d6f1b4c 100644
--- a/webkit/dom_storage/dom_storage_host.cc
+++ b/webkit/dom_storage/dom_storage_host.cc
@@ -61,6 +61,15 @@ bool DomStorageHost::ExtractAreaValues(
// for sending a bad message.
return true;
}
+ if (!area->IsLoadedInMemory()) {
+ DomStorageNamespace* ns = GetNamespace(connection_id);
+ DCHECK(!ns);
+ if (ns->CountInMemoryAreas() > kMaxInMemoryAreas) {
+ ns->PurgeUnopenedAreas();
+ if (ns->CountInMemoryAreas() > kMaxInMemoryAreas)
+ ns->PurgeMemory();
+ }
+ }
area->ExtractValues(map);
return true;
}
@@ -146,6 +155,13 @@ DomStorageArea* DomStorageHost::GetOpenArea(int connection_id) {
return found->second.area_;
}
+DomStorageNamespace* DomStorageHost::GetNamespace(int connection_id) {
+ AreaMap::iterator found = connections_.find(connection_id);
+ if (found == connections_.end())
+ return NULL;
+ return found->second.namespace_;
+}
+
// NamespaceAndArea
DomStorageHost::NamespaceAndArea::NamespaceAndArea() {}

Powered by Google App Engine
This is Rietveld 408576698