| Index: content/browser/dom_storage/dom_storage_context_impl.cc
|
| diff --git a/content/browser/dom_storage/dom_storage_context_impl.cc b/content/browser/dom_storage/dom_storage_context_impl.cc
|
| index 11b8ca5f4f33545b4d4f8952eb2cf75e65479f9d..3ef365c2bb045af1bd4c4f3931d2fc9d5f7a5da9 100644
|
| --- a/content/browser/dom_storage/dom_storage_context_impl.cc
|
| +++ b/content/browser/dom_storage/dom_storage_context_impl.cc
|
| @@ -440,15 +440,21 @@ void DOMStorageContextImpl::PurgeMemory(PurgeOption purge_option) {
|
| initial_stats.total_cache_size / 1024, 1, 100000,
|
| 50);
|
|
|
| + const char* purge_reason = nullptr;
|
| if (purge_option == PURGE_IF_NEEDED) {
|
| // Purging is done based on the cache sizes without including the database
|
| // size since it can be expensive trying to estimate the sqlite usage for
|
| // all databases. For low end devices purge all inactive areas.
|
| - bool should_purge =
|
| - initial_stats.inactive_area_count &&
|
| - (is_low_end_device_ || initial_stats.total_cache_size > kMaxCacheSize ||
|
| - initial_stats.total_area_count > kMaxStorageAreaCount);
|
| - if (!should_purge)
|
| + if (!initial_stats.inactive_area_count)
|
| + return;
|
| +
|
| + if (initial_stats.total_cache_size > kMaxCacheSize)
|
| + purge_reason = "SizeLimitExceeded";
|
| + else if (initial_stats.total_area_count > kMaxStorageAreaCount)
|
| + purge_reason = "AreaCountLimitExceeded";
|
| + else if (is_low_end_device_)
|
| + purge_reason = "InactiveOnLowEndDevice";
|
| + if (!purge_reason)
|
| return;
|
|
|
| purge_option = PURGE_UNOPENED;
|
| @@ -459,12 +465,26 @@ void DOMStorageContextImpl::PurgeMemory(PurgeOption purge_option) {
|
| it.second->PurgeMemory(aggressively);
|
|
|
| // Track the size of cache purged.
|
| - UMA_HISTOGRAM_CUSTOM_COUNTS(
|
| - "LocalStorage.BrowserLocalStorageCachePurgedInKB",
|
| + if (!purge_reason) {
|
| + if (purge_option == PURGE_AGGRESSIVE)
|
| + purge_reason = "AggressivePurgeTriggered";
|
| + else
|
| + purge_reason = "ModeratePurgeTriggered";
|
| + }
|
| + size_t purged_size_kib =
|
| (initial_stats.total_cache_size -
|
| GetTotalNamespaceStatistics(namespaces_).total_cache_size) /
|
| - 1024,
|
| - 1, 100000, 50);
|
| + 1024;
|
| + std::string full_histogram_name =
|
| + std::string("LocalStorage.BrowserLocalStorageCachePurgedInKB.") +
|
| + purge_reason;
|
| + base::HistogramBase* histogram = base::Histogram::FactoryGet(
|
| + full_histogram_name, 1, 100000, 50,
|
| + base::HistogramBase::kUmaTargetedHistogramFlag);
|
| + if (histogram)
|
| + histogram->Add(purged_size_kib);
|
| + UMA_HISTOGRAM_CUSTOM_COUNTS("LocalStorage.BrowserLocalStorageCachePurgedInKB",
|
| + purged_size_kib, 1, 100000, 50);
|
| }
|
|
|
| bool DOMStorageContextImpl::OnMemoryDump(
|
|
|