Chromium Code Reviews| 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..840bab02ed26e9739c4e280a3c7d2f72ec7ca647 100644 |
| --- a/storage/browser/quota/quota_manager.cc |
| +++ b/storage/browser/quota/quota_manager.cc |
| @@ -331,6 +331,7 @@ void DispatchUsageAndQuotaForWebApps( |
| if (is_incognito) { |
| quota = std::min(quota, QuotaManager::kIncognitoDefaultQuotaLimit); |
| callback.Run(status, usage, quota); |
| + UMA_HISTOGRAM_MBYTES("Quota.QuotaForOriginIncognito", quota); |
|
Ilya Sherman
2016/05/19 04:06:01
It's worth double-checking with the privacy team,
michaeln
2016/05/19 19:09:15
hmmm... i see many metrics that are specific to 'i
Ilya Sherman
2016/05/19 22:31:16
I'd recommend removing this for now, and checking
michaeln
2016/05/19 22:56:30
Done.
|
| return; |
| } |
| @@ -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,71 @@ 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); |
| + |
| + int64_t usage_day_old = 0; |
| + int64_t usage_week_old = 0; |
| + int64_t usage_month_old = 0; |
| + int64_t usage_three_month_old = 0; |
| + int64_t usage_six_month_old = 0; |
| + int64_t usage_year_old = 0; |
| + int64_t usage_over_year_old = 0; |
| + 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.OriginAgeInDays", age.InDays()); |
| + |
| + if (age < base::TimeDelta::FromDays(1)) |
| + usage_day_old += found->second; |
| + else if (age < base::TimeDelta::FromDays(7)) |
| + usage_week_old += found->second; |
| + else if (age < base::TimeDelta::FromDays(30)) |
| + usage_month_old += found->second; |
| + else if (age < base::TimeDelta::FromDays(90)) |
| + usage_three_month_old += found->second; |
| + else if (age < base::TimeDelta::FromDays(180)) |
| + usage_six_month_old += found->second; |
| + else if (age < base::TimeDelta::FromDays(365)) |
| + usage_year_old += found->second; |
| + else |
| + usage_over_year_old += found->second; |
| + } |
| + |
| + UMA_HISTOGRAM_MBYTES("Quota.AmountDayOldData", usage_day_old); |
| + UMA_HISTOGRAM_MBYTES("Quota.AmountWeekOldData", usage_week_old); |
| + UMA_HISTOGRAM_MBYTES("Quota.AmountMonthOldData", usage_month_old); |
| + UMA_HISTOGRAM_MBYTES("Quota.AmountThreeMonthOldData", usage_three_month_old); |
| + UMA_HISTOGRAM_MBYTES("Quota.AmountSixMonthOldData", usage_six_month_old); |
| + UMA_HISTOGRAM_MBYTES("Quota.AmountYearOldData", usage_year_old); |
| + UMA_HISTOGRAM_MBYTES("Quota.AmountOverYearOldData", usage_over_year_old); |
|
Ilya Sherman
2016/05/19 04:06:01
This is a fairly significant number of similar his
michaeln
2016/05/19 19:09:15
Two reasons for the granularity.
- to get a sense
michaeln
2016/05/19 19:51:24
Oh... I'll redo these to use a single histogram wi
Ilya Sherman
2016/05/19 22:31:16
Yep, that's a reasonable approach, as long as you'
michaeln
2016/05/19 22:56:30
Done
|
| } |
| std::set<GURL> QuotaManager::GetEvictionOriginExceptions( |
| @@ -1716,10 +1776,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( |