| Index: storage/browser/quota/quota_manager.cc
|
| diff --git a/storage/browser/quota/quota_manager.cc b/storage/browser/quota/quota_manager.cc
|
| index 26e469a9264543b0008399cc9b11b0e4f2920860..ad23d41ec835b534f3dccd2a9d79f377282f810c 100644
|
| --- a/storage/browser/quota/quota_manager.cc
|
| +++ b/storage/browser/quota/quota_manager.cc
|
| @@ -19,6 +19,7 @@
|
| #include "base/files/file_util.h"
|
| #include "base/macros.h"
|
| #include "base/metrics/histogram.h"
|
| +#include "base/numerics/safe_conversions.h"
|
| #include "base/profiler/scoped_tracker.h"
|
| #include "base/sequenced_task_runner.h"
|
| #include "base/single_thread_task_runner.h"
|
| @@ -339,15 +340,15 @@ void DispatchUsageAndQuotaForWebApps(
|
| // We assume we can expose the actual disk size for them and cap the quota by
|
| // the available disk space.
|
| if (is_unlimited || can_query_disk_size) {
|
| - callback.Run(
|
| - status, usage,
|
| - CalculateQuotaWithDiskSpace(
|
| - usage_and_quota.available_disk_space,
|
| - usage, quota));
|
| - return;
|
| + quota = CalculateQuotaWithDiskSpace(
|
| + usage_and_quota.available_disk_space,
|
| + usage, quota);
|
| }
|
|
|
| callback.Run(status, usage, quota);
|
| +
|
| + if (type == kStorageTypeTemporary && !is_unlimited)
|
| + UMA_HISTOGRAM_MBYTES("Quota.QuotaForOrigin", quota);
|
| }
|
|
|
| } // namespace
|
| @@ -1477,14 +1478,11 @@ void QuotaManager::DeleteOriginDataInternal(const GURL& origin,
|
| }
|
|
|
| void QuotaManager::ReportHistogram() {
|
| + DCHECK(!is_incognito_);
|
| GetGlobalUsage(kStorageTypeTemporary,
|
| base::Bind(
|
| &QuotaManager::DidGetTemporaryGlobalUsageForHistogram,
|
| weak_factory_.GetWeakPtr()));
|
| - GetGlobalUsage(kStorageTypePersistent,
|
| - base::Bind(
|
| - &QuotaManager::DidGetPersistentGlobalUsageForHistogram,
|
| - weak_factory_.GetWeakPtr()));
|
| }
|
|
|
| void QuotaManager::DidGetTemporaryGlobalUsageForHistogram(
|
| @@ -1502,13 +1500,17 @@ void QuotaManager::DidGetTemporaryGlobalUsageForHistogram(
|
| special_storage_policy_.get(),
|
| &protected_origins,
|
| &unlimited_origins);
|
| -
|
| UMA_HISTOGRAM_COUNTS("Quota.NumberOfTemporaryStorageOrigins",
|
| num_origins);
|
| UMA_HISTOGRAM_COUNTS("Quota.NumberOfProtectedTemporaryStorageOrigins",
|
| protected_origins);
|
| UMA_HISTOGRAM_COUNTS("Quota.NumberOfUnlimitedTemporaryStorageOrigins",
|
| unlimited_origins);
|
| +
|
| + GetGlobalUsage(kStorageTypePersistent,
|
| + base::Bind(
|
| + &QuotaManager::DidGetPersistentGlobalUsageForHistogram,
|
| + weak_factory_.GetWeakPtr()));
|
| }
|
|
|
| void QuotaManager::DidGetPersistentGlobalUsageForHistogram(
|
| @@ -1526,13 +1528,46 @@ void QuotaManager::DidGetPersistentGlobalUsageForHistogram(
|
| special_storage_policy_.get(),
|
| &protected_origins,
|
| &unlimited_origins);
|
| -
|
| UMA_HISTOGRAM_COUNTS("Quota.NumberOfPersistentStorageOrigins",
|
| num_origins);
|
| UMA_HISTOGRAM_COUNTS("Quota.NumberOfProtectedPersistentStorageOrigins",
|
| protected_origins);
|
| UMA_HISTOGRAM_COUNTS("Quota.NumberOfUnlimitedPersistentStorageOrigins",
|
| unlimited_origins);
|
| +
|
| + // We DumpOriginInfoTable last to ensure the trackers caches are loaded.
|
| + DumpOriginInfoTable(
|
| + base::Bind(&QuotaManager::DidDumpOriginInfoTableForHistogram,
|
| + weak_factory_.GetWeakPtr()));
|
| +}
|
| +
|
| +void QuotaManager::DidDumpOriginInfoTableForHistogram(
|
| + const OriginInfoTableEntries& entries) {
|
| + using UsageMap = std::map<GURL, int64_t>;
|
| + UsageMap usage_map;
|
| + GetUsageTracker(kStorageTypeTemporary)->GetCachedOriginsUsage(&usage_map);
|
| + base::Time now = base::Time::Now();
|
| + for (const auto& info : entries) {
|
| + if (info.type != kStorageTypeTemporary)
|
| + continue;
|
| +
|
| + // Ignore stale database entries. If there is no map entry, the origin's
|
| + // data has been deleted.
|
| + UsageMap::const_iterator found = usage_map.find(info.origin);
|
| + if (found == usage_map.end() || found->second == 0)
|
| + continue;
|
| +
|
| + base::TimeDelta age = now - std::max(info.last_access_time,
|
| + info.last_modified_time);
|
| + UMA_HISTOGRAM_COUNTS_1000("Quota.AgeOfOriginInDays", age.InDays());
|
| +
|
| + int64_t kilobytes = std::max(found->second / INT64_C(1024), INT64_C(1));
|
| + base::Histogram::FactoryGet(
|
| + "Quota.AgeOfDataInDays", 1, 1000, 50,
|
| + base::HistogramBase::kUmaTargetedHistogramFlag)->
|
| + AddCount(age.InDays(),
|
| + base::saturated_cast<int>(kilobytes));
|
| + }
|
| }
|
|
|
| std::set<GURL> QuotaManager::GetEvictionOriginExceptions(
|
| @@ -1716,10 +1751,12 @@ void QuotaManager::DidInitialize(int64_t* temporary_quota_override,
|
| temporary_quota_initialized_ = true;
|
| DidDatabaseWork(success);
|
|
|
| - histogram_timer_.Start(FROM_HERE,
|
| - base::TimeDelta::FromMilliseconds(
|
| - kReportHistogramInterval),
|
| - this, &QuotaManager::ReportHistogram);
|
| + if (!is_incognito_) {
|
| + histogram_timer_.Start(FROM_HERE,
|
| + base::TimeDelta::FromMilliseconds(
|
| + kReportHistogramInterval),
|
| + this, &QuotaManager::ReportHistogram);
|
| + }
|
|
|
| db_initialization_callbacks_.Run();
|
| GetTemporaryGlobalQuota(
|
|
|