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

Unified Diff: webkit/dom_storage/dom_storage_context.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, 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.cc
diff --git a/webkit/dom_storage/dom_storage_context.cc b/webkit/dom_storage/dom_storage_context.cc
index 45aae747639668a2513e63450d27ca46a8f0064e..170c58383258c98523f8b35a7d7e724355d5b48a 100644
--- a/webkit/dom_storage/dom_storage_context.cc
+++ b/webkit/dom_storage/dom_storage_context.cc
@@ -352,6 +352,28 @@ void DomStorageContext::StartScavengingUnusedSessionStorage() {
}
}
+int64 DomStorageContext::GetInMemoryStorageSize() const {
+ // TODO(kinuko): Cache this!!
+ int64 total_size = 0;
+ // Naively add-up the area size for each connection.
+ std::set<DomStorageArea*> visited_areas;
+ for (StorageNamespaceMap::const_iterator itr = namespaces_.begin();
+ itr != namespaces_.end(); ++itr) {
+ const DomStorageNamespace::AreaMap& map = itr->second->GetAreaMap();
+ for (DomStorageNamespace::AreaMap::const_iterator map_itr = map.begin();
+ map_itr != map.end(); ++map_itr) {
+ // We don't care open_count_ here, since we want to limit the
+ // memory usage.
+ DomStorageArea* area = map_itr->second.area_;
+ DCHECK(area);
+ if (visited_areas.insert(area).second) {
+ total_size += area->GetMapSize();
+ }
+ }
+ }
+ return total_size;
+}
+
void DomStorageContext::FindUnusedNamespaces() {
DCHECK(session_storage_database_.get());
if (scavenging_started_)

Powered by Google App Engine
This is Rietveld 408576698