Index: chrome/browser/browsing_data/cache_counter_browsertest.cc |
diff --git a/chrome/browser/browsing_data/cache_counter_browsertest.cc b/chrome/browser/browsing_data/cache_counter_browsertest.cc |
index 1b1b67954a194e7941e8e25de6df2ecd7b4153e6..8e23a78174d40552de28870618c6f9b9cf4795f9 100644 |
--- a/chrome/browser/browsing_data/cache_counter_browsertest.cc |
+++ b/chrome/browser/browsing_data/cache_counter_browsertest.cc |
@@ -11,10 +11,13 @@ |
#include "chrome/browser/browsing_data/cache_counter.h" |
#include "base/run_loop.h" |
+#include "chrome/browser/profiles/profile.h" |
#include "chrome/browser/ui/browser.h" |
#include "chrome/common/pref_names.h" |
#include "chrome/test/base/in_process_browser_test.h" |
#include "chrome/test/base/ui_test_utils.h" |
+#include "components/browsing_data/browsing_data_utils.h" |
+#include "components/browsing_data/pref_names.h" |
#include "components/browsing_data/storage_partition_http_cache_data_remover.h" |
#include "components/prefs/pref_service.h" |
#include "content/public/browser/storage_partition.h" |
@@ -32,16 +35,16 @@ class CacheCounterTest : public InProcessBrowserTest { |
public: |
void SetUpOnMainThread() override { |
SetCacheDeletionPref(true); |
- SetDeletionPeriodPref(BrowsingDataRemover::EVERYTHING); |
+ SetDeletionPeriodPref(browsing_data::EVERYTHING); |
} |
void SetCacheDeletionPref(bool value) { |
browser()->profile()->GetPrefs()->SetBoolean(prefs::kDeleteCache, value); |
} |
- void SetDeletionPeriodPref(BrowsingDataRemover::TimePeriod period) { |
+ void SetDeletionPeriodPref(browsing_data::TimePeriod period) { |
browser()->profile()->GetPrefs()->SetInteger( |
- prefs::kDeleteTimePeriod, static_cast<int>(period)); |
+ browsing_data::prefs::kDeleteTimePeriod, static_cast<int>(period)); |
} |
// One step in the process of creating a cache entry. Every step must be |
@@ -129,20 +132,23 @@ class CacheCounterTest : public InProcessBrowserTest { |
} |
// Callback from the counter. |
- void CountingCallback(std::unique_ptr<BrowsingDataCounter::Result> result) { |
+ void CountingCallback( |
+ std::unique_ptr<browsing_data::BrowsingDataCounter::Result> result) { |
DCHECK_CURRENTLY_ON(BrowserThread::UI); |
finished_ = result->Finished(); |
if (finished_) { |
- result_ = static_cast<BrowsingDataCounter::FinishedResult*>( |
- result.get())->Value(); |
+ result_ = |
+ static_cast<browsing_data::BrowsingDataCounter::FinishedResult*>( |
+ result.get()) |
+ ->Value(); |
} |
if (run_loop_ && finished_) |
run_loop_->Quit(); |
} |
- BrowsingDataCounter::ResultInt GetResult() { |
+ browsing_data::BrowsingDataCounter::ResultInt GetResult() { |
DCHECK(finished_); |
return result_; |
} |
@@ -162,15 +168,17 @@ class CacheCounterTest : public InProcessBrowserTest { |
std::unique_ptr<base::RunLoop> run_loop_; |
bool finished_; |
- BrowsingDataCounter::ResultInt result_; |
+ browsing_data::BrowsingDataCounter::ResultInt result_; |
}; |
// Tests that for the empty cache, the result is zero. |
IN_PROC_BROWSER_TEST_F(CacheCounterTest, Empty) { |
- CacheCounter counter; |
- counter.Init(browser()->profile(), |
- base::Bind(&CacheCounterTest::CountingCallback, |
- base::Unretained(this))); |
+ Profile* profile = browser()->profile(); |
+ |
+ CacheCounter counter(profile); |
+ counter.Init( |
+ profile->GetPrefs(), |
+ base::Bind(&CacheCounterTest::CountingCallback, base::Unretained(this))); |
counter.Restart(); |
WaitForIOThread(); |
@@ -181,10 +189,11 @@ IN_PROC_BROWSER_TEST_F(CacheCounterTest, Empty) { |
IN_PROC_BROWSER_TEST_F(CacheCounterTest, NonEmpty) { |
CreateCacheEntry(); |
- CacheCounter counter; |
- counter.Init(browser()->profile(), |
- base::Bind(&CacheCounterTest::CountingCallback, |
- base::Unretained(this))); |
+ Profile* profile = browser()->profile(); |
+ CacheCounter counter(profile); |
+ counter.Init( |
+ profile->GetPrefs(), |
+ base::Bind(&CacheCounterTest::CountingCallback, base::Unretained(this))); |
counter.Restart(); |
WaitForIOThread(); |
@@ -196,10 +205,11 @@ IN_PROC_BROWSER_TEST_F(CacheCounterTest, NonEmpty) { |
IN_PROC_BROWSER_TEST_F(CacheCounterTest, AfterDoom) { |
CreateCacheEntry(); |
- CacheCounter counter; |
- counter.Init(browser()->profile(), |
- base::Bind(&CacheCounterTest::CountingCallback, |
- base::Unretained(this))); |
+ Profile* profile = browser()->profile(); |
+ CacheCounter counter(profile); |
+ counter.Init( |
+ profile->GetPrefs(), |
+ base::Bind(&CacheCounterTest::CountingCallback, base::Unretained(this))); |
browsing_data::StoragePartitionHttpCacheDataRemover::CreateForRange( |
content::BrowserContext::GetDefaultStoragePartition(browser()->profile()), |
@@ -217,10 +227,11 @@ IN_PROC_BROWSER_TEST_F(CacheCounterTest, AfterDoom) { |
IN_PROC_BROWSER_TEST_F(CacheCounterTest, PrefChanged) { |
SetCacheDeletionPref(false); |
- CacheCounter counter; |
- counter.Init(browser()->profile(), |
- base::Bind(&CacheCounterTest::CountingCallback, |
- base::Unretained(this))); |
+ Profile* profile = browser()->profile(); |
+ CacheCounter counter(profile); |
+ counter.Init( |
+ profile->GetPrefs(), |
+ base::Bind(&CacheCounterTest::CountingCallback, base::Unretained(this))); |
SetCacheDeletionPref(true); |
WaitForIOThread(); |
@@ -231,10 +242,11 @@ IN_PROC_BROWSER_TEST_F(CacheCounterTest, PrefChanged) { |
IN_PROC_BROWSER_TEST_F(CacheCounterTest, PrefIsFalse) { |
SetCacheDeletionPref(false); |
- CacheCounter counter; |
- counter.Init(browser()->profile(), |
- base::Bind(&CacheCounterTest::CountingCallback, |
- base::Unretained(this))); |
+ Profile* profile = browser()->profile(); |
+ CacheCounter counter(profile); |
+ counter.Init( |
+ profile->GetPrefs(), |
+ base::Bind(&CacheCounterTest::CountingCallback, base::Unretained(this))); |
counter.Restart(); |
EXPECT_FALSE(counter.Pending()); |
@@ -247,28 +259,29 @@ IN_PROC_BROWSER_TEST_F(CacheCounterTest, PrefIsFalse) { |
IN_PROC_BROWSER_TEST_F(CacheCounterTest, PeriodChanged) { |
CreateCacheEntry(); |
- CacheCounter counter; |
- counter.Init(browser()->profile(), |
- base::Bind(&CacheCounterTest::CountingCallback, |
- base::Unretained(this))); |
+ Profile* profile = browser()->profile(); |
+ CacheCounter counter(profile); |
+ counter.Init( |
+ profile->GetPrefs(), |
+ base::Bind(&CacheCounterTest::CountingCallback, base::Unretained(this))); |
- SetDeletionPeriodPref(BrowsingDataRemover::LAST_HOUR); |
+ SetDeletionPeriodPref(browsing_data::LAST_HOUR); |
WaitForIOThread(); |
- BrowsingDataCounter::ResultInt result = GetResult(); |
+ browsing_data::BrowsingDataCounter::ResultInt result = GetResult(); |
- SetDeletionPeriodPref(BrowsingDataRemover::LAST_DAY); |
+ SetDeletionPeriodPref(browsing_data::LAST_DAY); |
WaitForIOThread(); |
EXPECT_EQ(result, GetResult()); |
- SetDeletionPeriodPref(BrowsingDataRemover::LAST_WEEK); |
+ SetDeletionPeriodPref(browsing_data::LAST_WEEK); |
WaitForIOThread(); |
EXPECT_EQ(result, GetResult()); |
- SetDeletionPeriodPref(BrowsingDataRemover::FOUR_WEEKS); |
+ SetDeletionPeriodPref(browsing_data::FOUR_WEEKS); |
WaitForIOThread(); |
EXPECT_EQ(result, GetResult()); |
- SetDeletionPeriodPref(BrowsingDataRemover::EVERYTHING); |
+ SetDeletionPeriodPref(browsing_data::EVERYTHING); |
WaitForIOThread(); |
EXPECT_EQ(result, GetResult()); |
} |