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

Unified Diff: content/browser/dom_storage/dom_storage_namespace.cc

Issue 1953703004: Purge browser cache for dom storage in a smarter way (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@dom_storage
Patch Set: Fix limit and description for UMA. Created 4 years, 7 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
« no previous file with comments | « content/browser/dom_storage/dom_storage_namespace.h ('k') | content/common/dom_storage/dom_storage_types.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/dom_storage/dom_storage_namespace.cc
diff --git a/content/browser/dom_storage/dom_storage_namespace.cc b/content/browser/dom_storage/dom_storage_namespace.cc
index 6f976f0d50158c387456251c8094c0ae19f9cb81..9aba4238b0e0360bd13de8125bfe9328deff930c 100644
--- a/content/browser/dom_storage/dom_storage_namespace.cc
+++ b/content/browser/dom_storage/dom_storage_namespace.cc
@@ -117,9 +117,10 @@ void DOMStorageNamespace::DeleteSessionStorageOrigin(const GURL& origin) {
CloseStorageArea(area);
}
-void DOMStorageNamespace::PurgeMemory(PurgeOption option) {
+void DOMStorageNamespace::PurgeMemory(bool aggressively) {
if (directory_.empty())
return; // We can't purge w/o backing on disk.
+
AreaMap::iterator it = areas_.begin();
while (it != areas_.end()) {
const AreaHolder& holder = it->second;
@@ -143,7 +144,7 @@ void DOMStorageNamespace::PurgeMemory(PurgeOption option) {
continue;
}
- if (option == PURGE_AGGRESSIVE) {
+ if (aggressively) {
// If aggressive is true, we clear caches and such
// for opened areas.
holder.area_->PurgeMemory();
@@ -167,13 +168,18 @@ void DOMStorageNamespace::Flush() {
}
}
-unsigned int DOMStorageNamespace::CountInMemoryAreas() const {
- unsigned int area_count = 0;
+DOMStorageNamespace::UsageStatistics DOMStorageNamespace::GetUsageStatistics()
+ const {
+ UsageStatistics stats = {0};
for (AreaMap::const_iterator it = areas_.begin(); it != areas_.end(); ++it) {
- if (it->second.area_->IsLoadedInMemory())
- ++area_count;
+ if (it->second.area_->IsLoadedInMemory()) {
+ stats.total_cache_size += it->second.area_->map_usage_in_bytes();
+ ++stats.total_area_count;
+ if (it->second.open_count_ == 0)
+ ++stats.inactive_area_count;
+ }
}
- return area_count;
+ return stats;
}
void DOMStorageNamespace::OnMemoryDump(
« no previous file with comments | « content/browser/dom_storage/dom_storage_namespace.h ('k') | content/common/dom_storage/dom_storage_types.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698