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

Side by Side Diff: storage/browser/quota/quota_manager.cc

Issue 1424653002: Add access count and time-since-accessed histograms to temp storage eviction. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@quota_uma
Patch Set: add quota database test Created 5 years, 1 month 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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "storage/browser/quota/quota_manager.h" 5 #include "storage/browser/quota/quota_manager.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <functional> 8 #include <functional>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 // TODO(kinuko): This should be like 10% of the actual disk space. 69 // TODO(kinuko): This should be like 10% of the actual disk space.
70 // For now we simply use a constant as getting the disk size needs 70 // For now we simply use a constant as getting the disk size needs
71 // platform-dependent code. (http://crbug.com/178976) 71 // platform-dependent code. (http://crbug.com/178976)
72 int64 QuotaManager::kMinimumPreserveForSystem = 1024 * kMBytes; 72 int64 QuotaManager::kMinimumPreserveForSystem = 1024 * kMBytes;
73 73
74 const int QuotaManager::kEvictionIntervalInMilliSeconds = 74 const int QuotaManager::kEvictionIntervalInMilliSeconds =
75 30 * kMinutesInMilliSeconds; 75 30 * kMinutesInMilliSeconds;
76 76
77 const char QuotaManager::kTimeBetweenRepeatedOriginEvictionsHistogram[] = 77 const char QuotaManager::kTimeBetweenRepeatedOriginEvictionsHistogram[] =
78 "Quota.TimeBetweenRepeatedOriginEvictions"; 78 "Quota.TimeBetweenRepeatedOriginEvictions";
79 const char QuotaManager::kEvictedOriginAccessedCountHistogram[] =
80 "Quota.EvictedOriginAccessCount";
81 const char QuotaManager::kEvictedOriginTimeSinceAccessHistogram[] =
82 "Quota.EvictedOriginTimeSinceAccess";
79 83
80 // Heuristics: assuming average cloud server allows a few Gigs storage 84 // Heuristics: assuming average cloud server allows a few Gigs storage
81 // on the server side and the storage needs to be shared for user data 85 // on the server side and the storage needs to be shared for user data
82 // and by multiple apps. 86 // and by multiple apps.
83 int64 QuotaManager::kSyncableStorageDefaultHostQuota = 500 * kMBytes; 87 int64 QuotaManager::kSyncableStorageDefaultHostQuota = 500 * kMBytes;
84 88
85 namespace { 89 namespace {
86 90
87 void CountOriginType(const std::set<GURL>& origins, 91 void CountOriginType(const std::set<GURL>& origins,
88 SpecialStoragePolicy* policy, 92 SpecialStoragePolicy* policy,
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 DCHECK(database); 156 DCHECK(database);
153 database->GetLRUOrigin(type, exceptions, policy, url); 157 database->GetLRUOrigin(type, exceptions, policy, url);
154 return true; 158 return true;
155 } 159 }
156 160
157 bool DeleteOriginInfoOnDBThread(const GURL& origin, 161 bool DeleteOriginInfoOnDBThread(const GURL& origin,
158 StorageType type, 162 StorageType type,
159 bool is_eviction, 163 bool is_eviction,
160 QuotaDatabase* database) { 164 QuotaDatabase* database) {
161 DCHECK(database); 165 DCHECK(database);
166
167 QuotaDatabase::OriginInfoTableEntry entry;
168
169 base::Time now = base::Time::Now();
michaeln 2015/10/30 00:49:02 maybe swap lines |now| and |entry| are declared o
calamity 2015/11/02 06:27:44 Done.
170 if (database->GetOriginInfo(origin, type, &entry)) {
michaeln 2015/10/30 00:49:02 please add |is_eviction| to this condition too
calamity 2015/11/02 06:27:44 Done. Nice catch.
171 UMA_HISTOGRAM_COUNTS(QuotaManager::kEvictedOriginAccessedCountHistogram,
172 entry.used_count);
173 UMA_HISTOGRAM_LONG_TIMES(
174 QuotaManager::kEvictedOriginTimeSinceAccessHistogram,
175 now - entry.last_access_time);
176 }
177
162 if (!database->DeleteOriginInfo(origin, type)) 178 if (!database->DeleteOriginInfo(origin, type))
163 return false; 179 return false;
164 180
165 // If the deletion is not due to an eviction, delete the entry in the eviction 181 // If the deletion is not due to an eviction, delete the entry in the eviction
166 // table as well due to privacy concerns. 182 // table as well due to privacy concerns.
167 if (!is_eviction) 183 if (!is_eviction)
168 return database->DeleteOriginLastEvictionTime(origin, type); 184 return database->DeleteOriginLastEvictionTime(origin, type);
169 185
170 base::Time last_eviction_time; 186 base::Time last_eviction_time;
171 if (!database->GetOriginLastEvictionTime(origin, type, &last_eviction_time)) 187 if (!database->GetOriginLastEvictionTime(origin, type, &last_eviction_time))
172 return false; 188 return false;
173 189
174 base::Time now = base::Time::Now();
175 if (last_eviction_time != base::Time()) { 190 if (last_eviction_time != base::Time()) {
176 UMA_HISTOGRAM_LONG_TIMES( 191 UMA_HISTOGRAM_LONG_TIMES(
177 QuotaManager::kTimeBetweenRepeatedOriginEvictionsHistogram, 192 QuotaManager::kTimeBetweenRepeatedOriginEvictionsHistogram,
178 now - last_eviction_time); 193 now - last_eviction_time);
179 } 194 }
180 195
181 return database->SetOriginLastEvictionTime(origin, type, now); 196 return database->SetOriginLastEvictionTime(origin, type, now);
182 } 197 }
183 198
184 bool InitializeTemporaryOriginsInfoOnDBThread(const std::set<GURL>* origins, 199 bool InitializeTemporaryOriginsInfoOnDBThread(const std::set<GURL>* origins,
(...skipping 1547 matching lines...) Expand 10 before | Expand all | Expand 10 after
1732 // |database_|, therefore we can be sure that database_ is alive when this 1747 // |database_|, therefore we can be sure that database_ is alive when this
1733 // task runs. 1748 // task runs.
1734 base::PostTaskAndReplyWithResult( 1749 base::PostTaskAndReplyWithResult(
1735 db_thread_.get(), 1750 db_thread_.get(),
1736 from_here, 1751 from_here,
1737 base::Bind(task, base::Unretained(database_.get())), 1752 base::Bind(task, base::Unretained(database_.get())),
1738 reply); 1753 reply);
1739 } 1754 }
1740 1755
1741 } // namespace storage 1756 } // namespace storage
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698