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

Unified Diff: content/browser/quota/quota_manager_unittest.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: fix 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/browser/quota/quota_database_unittest.cc ('k') | storage/browser/quota/quota_database.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/quota/quota_manager_unittest.cc
diff --git a/content/browser/quota/quota_manager_unittest.cc b/content/browser/quota/quota_manager_unittest.cc
index 6a7d1d9be47233e0d003b3de32aa77d5fac5385b..a2b3a425ade0c68236cfc7a76e968d0b5f0e4b27 100644
--- a/content/browser/quota/quota_manager_unittest.cc
+++ b/content/browser/quota/quota_manager_unittest.cc
@@ -1361,7 +1361,7 @@ TEST_F(QuotaManagerTest, EvictOriginData) {
}
TEST_F(QuotaManagerTest, EvictOriginDataHistogram) {
- const GURL kOrigin = GURL("http://foo.com");
+ const GURL kOrigin = GURL("http://foo.com/");
static const MockOriginData kData[] = {
{"http://foo.com/", kTemp, 1},
};
@@ -1374,31 +1374,52 @@ TEST_F(QuotaManagerTest, EvictOriginDataHistogram) {
GetGlobalUsage(kTemp);
base::RunLoop().RunUntilIdle();
- EvictOriginData(GURL("http://foo.com/"), kTemp);
+ EvictOriginData(kOrigin, kTemp);
base::RunLoop().RunUntilIdle();
+ // Ensure used count and time since access are recorded.
+ histograms.ExpectTotalCount(
+ QuotaManager::kEvictedOriginAccessedCountHistogram, 1);
+ histograms.ExpectBucketCount(
+ QuotaManager::kEvictedOriginAccessedCountHistogram, 0, 1);
+ histograms.ExpectTotalCount(
+ QuotaManager::kEvictedOriginTimeSinceAccessHistogram, 1);
+
// First eviction has no 'last' time to compare to.
histograms.ExpectTotalCount(
QuotaManager::kTimeBetweenRepeatedOriginEvictionsHistogram, 0);
- client->AddOriginAndNotify(GURL("http://foo.com"), kTemp, 100);
+ client->AddOriginAndNotify(kOrigin, kTemp, 100);
+
+ // Change the used count of the origin.
+ quota_manager()->NotifyStorageAccessed(QuotaClient::kUnknown, GURL(kOrigin),
+ kTemp);
+ base::RunLoop().RunUntilIdle();
GetGlobalUsage(kTemp);
base::RunLoop().RunUntilIdle();
- EvictOriginData(GURL("http://foo.com/"), kTemp);
+ EvictOriginData(kOrigin, kTemp);
base::RunLoop().RunUntilIdle();
- // Second eviction should log a histogram sample.
+ // The new used count should be logged.
+ histograms.ExpectTotalCount(
+ QuotaManager::kEvictedOriginAccessedCountHistogram, 2);
+ histograms.ExpectBucketCount(
+ QuotaManager::kEvictedOriginAccessedCountHistogram, 1, 1);
+ histograms.ExpectTotalCount(
+ QuotaManager::kEvictedOriginTimeSinceAccessHistogram, 2);
+
+ // Second eviction should log a 'time between repeated eviction' sample.
histograms.ExpectTotalCount(
QuotaManager::kTimeBetweenRepeatedOriginEvictionsHistogram, 1);
- client->AddOriginAndNotify(GURL("http://foo.com"), kTemp, 100);
+ client->AddOriginAndNotify(kOrigin, kTemp, 100);
GetGlobalUsage(kTemp);
base::RunLoop().RunUntilIdle();
- DeleteOriginFromDatabase(GURL("http://foo.com"), kTemp);
+ DeleteOriginFromDatabase(kOrigin, kTemp);
// Deletion from non-eviction source should not log a histogram sample.
histograms.ExpectTotalCount(
« no previous file with comments | « content/browser/quota/quota_database_unittest.cc ('k') | storage/browser/quota/quota_database.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698