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

Unified Diff: content/browser/quota/quota_manager_unittest.cc

Issue 1403673002: Add Quota.TimeSinceOriginEvicted UMA histogram. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 5 years, 2 months 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 56cfba41cea29d2d64c457d11e4e2d5f37fe6455..b316648ae15f08009b5b0427fff5d2384376b7df 100644
--- a/content/browser/quota/quota_manager_unittest.cc
+++ b/content/browser/quota/quota_manager_unittest.cc
@@ -15,6 +15,7 @@
#include "base/run_loop.h"
#include "base/stl_util.h"
#include "base/sys_info.h"
+#include "base/test/histogram_tester.h"
#include "base/thread_task_runner_handle.h"
#include "base/time/time.h"
#include "content/public/test/mock_special_storage_policy.h"
@@ -291,7 +292,7 @@ class QuotaManagerTest : public testing::Test {
}
void DeleteOriginFromDatabase(const GURL& origin, StorageType type) {
- quota_manager_->DeleteOriginFromDatabase(origin, type);
+ quota_manager_->DeleteOriginFromDatabase(origin, type, false);
}
void GetEvictionOrigin(StorageType type) {
@@ -1358,6 +1359,51 @@ TEST_F(QuotaManagerTest, EvictOriginData) {
EXPECT_EQ(predelete_host_pers, usage());
}
+TEST_F(QuotaManagerTest, EvictOriginDataHistogram) {
+ const GURL kOrigin = GURL("http://foo.com");
+ static const MockOriginData kData[] = {
+ {"http://foo.com/", kTemp, 1},
+ };
+
+ base::HistogramTester histograms;
+ MockStorageClient* client =
+ CreateClient(kData, arraysize(kData), QuotaClient::kFileSystem);
+ RegisterClient(client);
+
+ GetGlobalUsage(kTemp);
+ base::RunLoop().RunUntilIdle();
+
+ EvictOriginData(GURL("http://foo.com/"), kTemp);
+ base::RunLoop().RunUntilIdle();
+
+ // First eviction has no 'last' time to compare to.
+ histograms.ExpectTotalCount(
+ QuotaManager::kTimeBetweenRepeatedOriginEvictionsHistogram, 0);
+
+ client->AddOriginAndNotify(GURL("http://foo.com"), kTemp, 100);
+
+ GetGlobalUsage(kTemp);
+ base::RunLoop().RunUntilIdle();
+
+ EvictOriginData(GURL("http://foo.com/"), kTemp);
+ base::RunLoop().RunUntilIdle();
+
+ // Second eviction should log a histogram sample.
+ histograms.ExpectTotalCount(
+ QuotaManager::kTimeBetweenRepeatedOriginEvictionsHistogram, 1);
+
+ client->AddOriginAndNotify(GURL("http://foo.com"), kTemp, 100);
+
+ GetGlobalUsage(kTemp);
+ base::RunLoop().RunUntilIdle();
+
+ DeleteOriginFromDatabase(GURL("http://foo.com"), kTemp);
+
+ // Deletion from non-eviction source should not log a histogram sample.
+ histograms.ExpectTotalCount(
+ QuotaManager::kTimeBetweenRepeatedOriginEvictionsHistogram, 1);
+}
+
TEST_F(QuotaManagerTest, EvictOriginDataWithDeletionError) {
static const MockOriginData kData[] = {
{ "http://foo.com/", kTemp, 1 },
« 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