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_) |