summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorajwong@chromium.org <ajwong@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-12-28 06:51:42 +0000
committerajwong@chromium.org <ajwong@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-12-28 06:51:42 +0000
commit5ff8b2aa66ed64f18794cfb130284bb54eb00ce4 (patch)
treee411d23a1b3144aad9819741adb7154ef2b0ac3c
parent3945dcb435eb9ebcad8ba582663fd50cb8a59126 (diff)
downloadchromium_src-5ff8b2aa66ed64f18794cfb130284bb54eb00ce4.zip
chromium_src-5ff8b2aa66ed64f18794cfb130284bb54eb00ce4.tar.gz
chromium_src-5ff8b2aa66ed64f18794cfb130284bb54eb00ce4.tar.bz2
Cleanup storage_partition_impl_unittest.cc.
Removes: - unnecessary casts - unnecessary conversions to pointers - unnecessary wrapper over RunLoop. It also removes stack-based creation of the StoragePartition and temp directories. This was fragile and unnecessary. The TestBrowserContext itself already created a default one. The stack-based version was actually coopting contexts that were created in the default partition to create a partial stub. This unfortunately also avoided most of the initialization code and checks in the StoragePartitionImpl::Create() function leading to more fragility. Now, each test case only has one default StoragePartition which is correctly tied to the containing BrowserContext. The contexts in this partition are also no longer shared by the stubs. TBR=boliu BUG=none Review URL: https://codereview.chromium.org/101423007 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@242675 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--android_webview/native/aw_quota_manager_bridge_impl.cc2
-rw-r--r--chrome/browser/browsing_data/browsing_data_remover.cc2
-rw-r--r--chrome/browser/browsing_data/browsing_data_remover_unittest.cc5
-rw-r--r--chrome/browser/guestview/webview/webview_guest.cc2
-rw-r--r--content/browser/storage_partition_impl.cc49
-rw-r--r--content/browser/storage_partition_impl.h4
-rw-r--r--content/browser/storage_partition_impl_map.cc2
-rw-r--r--content/browser/storage_partition_impl_unittest.cc416
-rw-r--r--content/public/browser/storage_partition.h2
9 files changed, 225 insertions, 259 deletions
diff --git a/android_webview/native/aw_quota_manager_bridge_impl.cc b/android_webview/native/aw_quota_manager_bridge_impl.cc
index f672f8b..4821732 100644
--- a/android_webview/native/aw_quota_manager_bridge_impl.cc
+++ b/android_webview/native/aw_quota_manager_bridge_impl.cc
@@ -215,7 +215,7 @@ void AwQuotaManagerBridgeImpl::DeleteAllDataOnUiThread() {
StoragePartition::REMOVE_DATA_MASK_LOCAL_STORAGE |
StoragePartition::REMOVE_DATA_MASK_WEBSQL,
StoragePartition::QUOTA_MANAGED_STORAGE_MASK_TEMPORARY,
- NULL, StoragePartition::OriginMatcherFunction(),
+ GURL(), StoragePartition::OriginMatcherFunction(),
base::Time(), base::Time::Max(), base::Bind(&base::DoNothing));
}
diff --git a/chrome/browser/browsing_data/browsing_data_remover.cc b/chrome/browser/browsing_data/browsing_data_remover.cc
index 22785dc..b0511ee 100644
--- a/chrome/browser/browsing_data/browsing_data_remover.cc
+++ b/chrome/browser/browsing_data/browsing_data_remover.cc
@@ -591,7 +591,7 @@ void BrowsingDataRemover::RemoveImpl(int remove_mask,
storage_partition->ClearData(
storage_partition_remove_mask,
quota_storage_remove_mask,
- &remove_origin_,
+ remove_origin_,
base::Bind(&DoesOriginMatchMask, origin_set_mask_),
delete_begin_,
delete_end_,
diff --git a/chrome/browser/browsing_data/browsing_data_remover_unittest.cc b/chrome/browser/browsing_data/browsing_data_remover_unittest.cc
index 5c9c7e7..09b1002 100644
--- a/chrome/browser/browsing_data/browsing_data_remover_unittest.cc
+++ b/chrome/browser/browsing_data/browsing_data_remover_unittest.cc
@@ -195,7 +195,7 @@ class TestStoragePartition : public StoragePartition {
virtual void ClearData(uint32 remove_mask,
uint32 quota_storage_remove_mask,
- const GURL* storage_origin,
+ const GURL& storage_origin,
const OriginMatcherFunction& origin_matcher,
const base::Time begin,
const base::Time end,
@@ -204,8 +204,7 @@ class TestStoragePartition : public StoragePartition {
storage_partition_removal_data_.remove_mask = remove_mask;
storage_partition_removal_data_.quota_storage_remove_mask =
quota_storage_remove_mask;
- storage_partition_removal_data_.remove_origin =
- storage_origin ? *storage_origin : GURL();
+ storage_partition_removal_data_.remove_origin = storage_origin;
storage_partition_removal_data_.remove_begin = begin;
storage_partition_removal_data_.remove_end = end;
storage_partition_removal_data_.origin_matcher = origin_matcher;
diff --git a/chrome/browser/guestview/webview/webview_guest.cc b/chrome/browser/guestview/webview/webview_guest.cc
index 9a99061..01be30e 100644
--- a/chrome/browser/guestview/webview/webview_guest.cc
+++ b/chrome/browser/guestview/webview/webview_guest.cc
@@ -552,7 +552,7 @@ bool WebViewGuest::ClearData(const base::Time remove_since,
partition->ClearData(
removal_mask,
content::StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL,
- NULL,
+ GURL(),
content::StoragePartition::OriginMatcherFunction(),
remove_since,
base::Time::Now(),
diff --git a/content/browser/storage_partition_impl.cc b/content/browser/storage_partition_impl.cc
index 5b9de73..ef446bd 100644
--- a/content/browser/storage_partition_impl.cc
+++ b/content/browser/storage_partition_impl.cc
@@ -44,12 +44,12 @@ void ClearCookiesOnIOThread(
const scoped_refptr<net::URLRequestContextGetter>& rq_context,
const base::Time begin,
const base::Time end,
- const GURL& remove_origin,
+ const GURL& storage_origin,
const base::Closure& callback) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
net::CookieStore* cookie_store = rq_context->
GetURLRequestContext()->cookie_store();
- if (remove_origin.is_empty()) {
+ if (storage_origin.is_empty()) {
cookie_store->DeleteAllCreatedBetweenAsync(
begin,
end,
@@ -58,7 +58,7 @@ void ClearCookiesOnIOThread(
cookie_store->DeleteAllCreatedBetweenForHostAsync(
begin,
end,
- remove_origin, base::Bind(&OnClearedCookies, callback));
+ storage_origin, base::Bind(&OnClearedCookies, callback));
}
}
@@ -153,18 +153,18 @@ void ClearLocalStorageOnUIThread(
const scoped_refptr<DOMStorageContextWrapper>& dom_storage_context,
const scoped_refptr<quota::SpecialStoragePolicy>& special_storage_policy,
const StoragePartition::OriginMatcherFunction& origin_matcher,
- const GURL& remove_origin,
+ const GURL& storage_origin,
const base::Time begin,
const base::Time end,
const base::Closure& callback) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- if (!remove_origin.is_empty()) {
+ if (!storage_origin.is_empty()) {
bool can_delete = origin_matcher.is_null() ||
- origin_matcher.Run(remove_origin,
+ origin_matcher.Run(storage_origin,
special_storage_policy.get());
if (can_delete)
- dom_storage_context->DeleteLocalStorage(remove_origin);
+ dom_storage_context->DeleteLocalStorage(storage_origin);
callback.Run();
return;
@@ -213,11 +213,11 @@ int StoragePartitionImpl::GenerateQuotaClientMask(uint32 remove_mask) {
struct StoragePartitionImpl::QuotaManagedDataDeletionHelper {
QuotaManagedDataDeletionHelper(uint32 remove_mask,
uint32 quota_storage_remove_mask,
- const GURL& remove_origin,
+ const GURL& storage_origin,
const base::Closure& callback)
: remove_mask(remove_mask),
quota_storage_remove_mask(quota_storage_remove_mask),
- remove_origin(remove_origin),
+ storage_origin(storage_origin),
callback(callback),
task_count(0) {
}
@@ -242,7 +242,7 @@ struct StoragePartitionImpl::QuotaManagedDataDeletionHelper {
// All of these data are accessed on IO thread.
uint32 remove_mask;
uint32 quota_storage_remove_mask;
- GURL remove_origin;
+ GURL storage_origin;
const base::Closure callback;
int task_count;
};
@@ -270,7 +270,7 @@ struct StoragePartitionImpl::DataDeletionHelper {
void IncrementTaskCountOnUI();
void DecrementTaskCountOnUI();
- void ClearDataOnUIThread(const GURL* remove_origin,
+ void ClearDataOnUIThread(const GURL& storage_origin,
const OriginMatcherFunction& origin_matcher,
const base::FilePath& path,
net::URLRequestContextGetter* rq_context,
@@ -284,7 +284,7 @@ struct StoragePartitionImpl::DataDeletionHelper {
void ClearQuotaManagedDataOnIOThread(
const scoped_refptr<quota::QuotaManager>& quota_manager,
const base::Time begin,
- const GURL& remove_origin,
+ const GURL& storage_origin,
const scoped_refptr<quota::SpecialStoragePolicy>& special_storage_policy,
const StoragePartition::OriginMatcherFunction& origin_matcher,
const base::Closure& callback);
@@ -301,7 +301,7 @@ struct StoragePartitionImpl::DataDeletionHelper {
void StoragePartitionImpl::DataDeletionHelper::ClearQuotaManagedDataOnIOThread(
const scoped_refptr<quota::QuotaManager>& quota_manager,
const base::Time begin,
- const GURL& remove_origin,
+ const GURL& storage_origin,
const scoped_refptr<quota::SpecialStoragePolicy>& special_storage_policy,
const StoragePartition::OriginMatcherFunction& origin_matcher,
const base::Closure& callback) {
@@ -311,7 +311,7 @@ void StoragePartitionImpl::DataDeletionHelper::ClearQuotaManagedDataOnIOThread(
new StoragePartitionImpl::QuotaManagedDataDeletionHelper(
remove_mask,
quota_storage_remove_mask,
- remove_origin,
+ storage_origin,
callback);
helper->ClearDataOnIOThread(quota_manager, begin, special_storage_policy,
origin_matcher);
@@ -484,7 +484,7 @@ ServiceWorkerContextWrapper* StoragePartitionImpl::GetServiceWorkerContext() {
void StoragePartitionImpl::ClearDataImpl(
uint32 remove_mask,
uint32 quota_storage_remove_mask,
- const GURL* remove_origin,
+ const GURL& storage_origin,
const OriginMatcherFunction& origin_matcher,
net::URLRequestContextGetter* rq_context,
const base::Time begin,
@@ -496,7 +496,7 @@ void StoragePartitionImpl::ClearDataImpl(
callback);
// |helper| deletes itself when done in
// DataDeletionHelper::DecrementTaskCountOnUI().
- helper->ClearDataOnUIThread(remove_origin, origin_matcher, GetPath(),
+ helper->ClearDataOnUIThread(storage_origin, origin_matcher, GetPath(),
rq_context, dom_storage_context_, quota_manager_,
special_storage_policy_.get(),
webrtc_identity_store_, begin, end);
@@ -597,7 +597,7 @@ void StoragePartitionImpl::
for (std::set<GURL>::const_iterator origin = origins.begin();
origin != origins.end(); ++origin) {
// TODO(mkwst): Clean this up, it's slow. http://crbug.com/130746
- if (!remove_origin.is_empty() && origin->GetOrigin() != remove_origin)
+ if (!storage_origin.is_empty() && origin->GetOrigin() != storage_origin)
continue;
if (!origin_matcher.is_null() &&
@@ -640,7 +640,7 @@ void StoragePartitionImpl::DataDeletionHelper::DecrementTaskCountOnUI() {
}
void StoragePartitionImpl::DataDeletionHelper::ClearDataOnUIThread(
- const GURL* remove_origin,
+ const GURL& storage_origin,
const OriginMatcherFunction& origin_matcher,
const base::FilePath& path,
net::URLRequestContextGetter* rq_context,
@@ -657,14 +657,13 @@ void StoragePartitionImpl::DataDeletionHelper::ClearDataOnUIThread(
base::Closure decrement_callback = base::Bind(
&DataDeletionHelper::DecrementTaskCountOnUI, base::Unretained(this));
- GURL origin = remove_origin ? *remove_origin : GURL();
if (remove_mask & REMOVE_DATA_MASK_COOKIES) {
// Handle the cookies.
IncrementTaskCountOnUI();
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
base::Bind(&ClearCookiesOnIOThread,
- make_scoped_refptr(rq_context), begin, end, origin,
+ make_scoped_refptr(rq_context), begin, end, storage_origin,
decrement_callback));
}
@@ -679,7 +678,7 @@ void StoragePartitionImpl::DataDeletionHelper::ClearDataOnUIThread(
base::Unretained(this),
make_scoped_refptr(quota_manager),
begin,
- origin,
+ storage_origin,
make_scoped_refptr(special_storage_policy),
origin_matcher,
decrement_callback));
@@ -691,13 +690,13 @@ void StoragePartitionImpl::DataDeletionHelper::ClearDataOnUIThread(
make_scoped_refptr(dom_storage_context),
make_scoped_refptr(special_storage_policy),
origin_matcher,
- origin, begin, end,
+ storage_origin, begin, end,
decrement_callback);
// ClearDataImpl cannot clear session storage data when a particular origin
// is specified. Therefore we ignore clearing session storage in this case.
// TODO(lazyboy): Fix.
- if (origin.is_empty()) {
+ if (storage_origin.is_empty()) {
IncrementTaskCountOnUI();
ClearSessionStorageOnUIThread(
make_scoped_refptr(dom_storage_context),
@@ -737,7 +736,7 @@ void StoragePartitionImpl::ClearDataForOrigin(
const GURL& storage_origin,
net::URLRequestContextGetter* request_context_getter) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- ClearDataImpl(remove_mask, quota_storage_remove_mask, &storage_origin,
+ ClearDataImpl(remove_mask, quota_storage_remove_mask, storage_origin,
OriginMatcherFunction(), request_context_getter,
base::Time(), base::Time::Max(), base::Bind(&base::DoNothing));
}
@@ -745,7 +744,7 @@ void StoragePartitionImpl::ClearDataForOrigin(
void StoragePartitionImpl::ClearData(
uint32 remove_mask,
uint32 quota_storage_remove_mask,
- const GURL* storage_origin,
+ const GURL& storage_origin,
const OriginMatcherFunction& origin_matcher,
const base::Time begin,
const base::Time end,
diff --git a/content/browser/storage_partition_impl.h b/content/browser/storage_partition_impl.h
index 4edf474..ab48b04 100644
--- a/content/browser/storage_partition_impl.h
+++ b/content/browser/storage_partition_impl.h
@@ -50,7 +50,7 @@ class StoragePartitionImpl : public StoragePartition {
net::URLRequestContextGetter* request_context_getter) OVERRIDE;
virtual void ClearData(uint32 remove_mask,
uint32 quota_storage_remove_mask,
- const GURL* storage_origin,
+ const GURL& storage_origin,
const OriginMatcherFunction& origin_matcher,
const base::Time begin,
const base::Time end,
@@ -121,7 +121,7 @@ class StoragePartitionImpl : public StoragePartition {
void ClearDataImpl(uint32 remove_mask,
uint32 quota_storage_remove_mask,
- const GURL* remove_origin,
+ const GURL& remove_origin,
const OriginMatcherFunction& origin_matcher,
net::URLRequestContextGetter* rq_context,
const base::Time begin,
diff --git a/content/browser/storage_partition_impl_map.cc b/content/browser/storage_partition_impl_map.cc
index 333b8b8..fef284f 100644
--- a/content/browser/storage_partition_impl_map.cc
+++ b/content/browser/storage_partition_impl_map.cc
@@ -465,7 +465,7 @@ void StoragePartitionImplMap::AsyncObliterate(
StoragePartition::REMOVE_DATA_MASK_ALL &
(~StoragePartition::REMOVE_DATA_MASK_SHADER_CACHE),
StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL,
- NULL,
+ GURL(),
StoragePartition::OriginMatcherFunction(),
base::Time(), base::Time::Max(),
base::Bind(&base::DoNothing));
diff --git a/content/browser/storage_partition_impl_unittest.cc b/content/browser/storage_partition_impl_unittest.cc
index ef3b679..9a5c35f 100644
--- a/content/browser/storage_partition_impl_unittest.cc
+++ b/content/browser/storage_partition_impl_unittest.cc
@@ -3,7 +3,6 @@
// found in the LICENSE file.
#include "base/file_util.h"
-#include "base/files/scoped_temp_dir.h"
#include "base/message_loop/message_loop_proxy.h"
#include "base/run_loop.h"
#include "base/threading/thread.h"
@@ -61,31 +60,6 @@ const uint32 kAllQuotaRemoveMask =
StoragePartition::REMOVE_DATA_MASK_FILE_SYSTEMS |
StoragePartition::REMOVE_DATA_MASK_APPCACHE;
-class TestClosureCallback {
- public:
- TestClosureCallback()
- : callback_(base::Bind(
- &TestClosureCallback::StopWaiting, base::Unretained(this))) {
- }
-
- void WaitForResult() {
- wait_run_loop_.reset(new base::RunLoop());
- wait_run_loop_->Run();
- }
-
- const base::Closure& callback() { return callback_; }
-
- private:
- void StopWaiting() {
- wait_run_loop_->Quit();
- }
-
- base::Closure callback_;
- scoped_ptr<base::RunLoop> wait_run_loop_;
-
- DISALLOW_COPY_AND_ASSIGN(TestClosureCallback);
-};
-
class AwaitCompletionHelper {
public:
AwaitCompletionHelper() : start_(false), already_quit_(false) {}
@@ -270,70 +244,82 @@ bool DoesOriginMatchUnprotected(
return origin.GetOrigin().scheme() != kOriginDevTools.scheme();
}
-void ClearQuotaData(content::StoragePartition* storage_partition,
- const base::Closure& cb) {
- storage_partition->ClearData(
+void ClearQuotaData(content::StoragePartition* partition,
+ base::RunLoop* loop_to_quit) {
+ partition->ClearData(
kAllQuotaRemoveMask,
StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL,
- NULL, StoragePartition::OriginMatcherFunction(),
- base::Time(), base::Time::Max(), cb);
+ GURL(), StoragePartition::OriginMatcherFunction(),
+ base::Time(), base::Time::Max(), loop_to_quit->QuitClosure());
}
void ClearQuotaDataWithOriginMatcher(
- content::StoragePartition* storage_partition,
+ content::StoragePartition* partition,
const GURL& remove_origin,
const StoragePartition::OriginMatcherFunction& origin_matcher,
const base::Time delete_begin,
- const base::Closure& cb) {
- storage_partition->ClearData(kAllQuotaRemoveMask,
- StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL,
- &remove_origin, origin_matcher, delete_begin,
- base::Time::Max(), cb);
+ base::RunLoop* loop_to_quit) {
+ partition->ClearData(kAllQuotaRemoveMask,
+ StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL,
+ remove_origin, origin_matcher, delete_begin,
+ base::Time::Max(), loop_to_quit->QuitClosure());
}
void ClearQuotaDataForOrigin(
- content::StoragePartition* storage_partition,
+ content::StoragePartition* partition,
const GURL& remove_origin,
const base::Time delete_begin,
- const base::Closure& cb) {
+ base::RunLoop* loop_to_quit) {
ClearQuotaDataWithOriginMatcher(
- storage_partition, remove_origin,
- StoragePartition::OriginMatcherFunction(), delete_begin, cb);
+ partition, remove_origin,
+ StoragePartition::OriginMatcherFunction(), delete_begin,
+ loop_to_quit);
}
void ClearQuotaDataForNonPersistent(
- content::StoragePartition* storage_partition,
+ content::StoragePartition* partition,
const base::Time delete_begin,
- const base::Closure& cb) {
+ base::RunLoop* loop_to_quit) {
uint32 quota_storage_remove_mask_no_persistent =
StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL &
~StoragePartition::QUOTA_MANAGED_STORAGE_MASK_PERSISTENT;
- storage_partition->ClearData(
+ partition->ClearData(
kAllQuotaRemoveMask, quota_storage_remove_mask_no_persistent,
- NULL, StoragePartition::OriginMatcherFunction(),
- delete_begin, base::Time::Max(), cb);
+ GURL(), StoragePartition::OriginMatcherFunction(),
+ delete_begin, base::Time::Max(), loop_to_quit->QuitClosure());
}
-void ClearCookies(content::StoragePartition* storage_partition,
+void ClearCookies(content::StoragePartition* partition,
const base::Time delete_begin,
const base::Time delete_end,
- const base::Closure& cb) {
- storage_partition->ClearData(
+ base::RunLoop* run_loop) {
+ partition->ClearData(
StoragePartition::REMOVE_DATA_MASK_COOKIES,
StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL,
- NULL, StoragePartition::OriginMatcherFunction(),
- delete_begin, delete_end, cb);
+ GURL(), StoragePartition::OriginMatcherFunction(),
+ delete_begin, delete_end, run_loop->QuitClosure());
}
void ClearStuff(uint32 remove_mask,
- content::StoragePartition* storage_partition,
+ content::StoragePartition* partition,
const base::Time delete_begin,
const base::Time delete_end,
const StoragePartition::OriginMatcherFunction& origin_matcher,
- const base::Closure& cb) {
- storage_partition->ClearData(
+ base::RunLoop* run_loop) {
+ partition->ClearData(
remove_mask, StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL,
- NULL, origin_matcher, delete_begin, delete_end, cb);
+ GURL(), origin_matcher, delete_begin, delete_end,
+ run_loop->QuitClosure());
+}
+
+void ClearData(content::StoragePartition* partition,
+ base::RunLoop* run_loop) {
+ base::Time time;
+ partition->ClearData(
+ StoragePartition::REMOVE_DATA_MASK_SHADER_CACHE,
+ StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL,
+ GURL(), StoragePartition::OriginMatcherFunction(),
+ time, time, run_loop->QuitClosure());
}
} // namespace
@@ -341,10 +327,9 @@ void ClearStuff(uint32 remove_mask,
class StoragePartitionImplTest : public testing::Test {
public:
StoragePartitionImplTest()
- : browser_context_(new TestBrowserContext()),
- thread_bundle_(content::TestBrowserThreadBundle::IO_MAINLOOP) {
+ : thread_bundle_(content::TestBrowserThreadBundle::IO_MAINLOOP),
+ browser_context_(new TestBrowserContext()) {
}
- virtual ~StoragePartitionImplTest() {}
quota::MockQuotaManager* GetMockManager() {
if (!quota_manager_.get()) {
@@ -358,14 +343,14 @@ class StoragePartitionImplTest : public testing::Test {
return quota_manager_.get();
}
- TestBrowserContext* GetBrowserContext() {
+ TestBrowserContext* browser_context() {
return browser_context_.get();
}
private:
+ content::TestBrowserThreadBundle thread_bundle_;
scoped_ptr<TestBrowserContext> browser_context_;
scoped_refptr<quota::MockQuotaManager> quota_manager_;
- content::TestBrowserThreadBundle thread_bundle_;
DISALLOW_COPY_AND_ASSIGN(StoragePartitionImplTest);
};
@@ -373,20 +358,18 @@ class StoragePartitionImplTest : public testing::Test {
class StoragePartitionShaderClearTest : public testing::Test {
public:
StoragePartitionShaderClearTest()
- : thread_bundle_(content::TestBrowserThreadBundle::IO_MAINLOOP) {
+ : thread_bundle_(content::TestBrowserThreadBundle::IO_MAINLOOP),
+ browser_context_(new TestBrowserContext()) {
+ ShaderCacheFactory::GetInstance()->SetCacheInfo(
+ kDefaultClientId,
+ BrowserContext::GetDefaultStoragePartition(
+ browser_context())->GetPath());
+ cache_ = ShaderCacheFactory::GetInstance()->Get(kDefaultClientId);
}
- virtual ~StoragePartitionShaderClearTest() {}
-
- const base::FilePath& cache_path() { return temp_dir_.path(); }
-
- virtual void SetUp() OVERRIDE {
- ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
- ShaderCacheFactory::GetInstance()->SetCacheInfo(kDefaultClientId,
- cache_path());
-
- cache_ = ShaderCacheFactory::GetInstance()->Get(kDefaultClientId);
- ASSERT_TRUE(cache_.get() != NULL);
+ virtual ~StoragePartitionShaderClearTest() {
+ cache_ = NULL;
+ ShaderCacheFactory::GetInstance()->RemoveCacheInfo(kDefaultClientId);
}
void InitCache() {
@@ -405,41 +388,30 @@ class StoragePartitionShaderClearTest : public testing::Test {
size_t Size() { return cache_->Size(); }
- private:
- virtual void TearDown() OVERRIDE {
- cache_ = NULL;
- ShaderCacheFactory::GetInstance()->RemoveCacheInfo(kDefaultClientId);
+ TestBrowserContext* browser_context() {
+ return browser_context_.get();
}
- base::ScopedTempDir temp_dir_;
+ private:
content::TestBrowserThreadBundle thread_bundle_;
+ scoped_ptr<TestBrowserContext> browser_context_;
scoped_refptr<ShaderDiskCache> cache_;
};
-void ClearData(content::StoragePartitionImpl* sp,
- const base::Closure& cb) {
- base::Time time;
- sp->ClearData(
- StoragePartition::REMOVE_DATA_MASK_SHADER_CACHE,
- StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL,
- NULL, StoragePartition::OriginMatcherFunction(),
- time, time, cb);
-}
-
// Tests ---------------------------------------------------------------------
TEST_F(StoragePartitionShaderClearTest, ClearShaderCache) {
InitCache();
EXPECT_EQ(1u, Size());
- TestClosureCallback clear_cb;
- StoragePartitionImpl storage_partition(
- cache_path(), NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
+ base::RunLoop run_loop;
base::MessageLoop::current()->PostTask(
- FROM_HERE, base::Bind(&ClearData, &storage_partition,
- clear_cb.callback()));
- clear_cb.WaitForResult();
+ FROM_HERE, base::Bind(
+ &ClearData,
+ BrowserContext::GetDefaultStoragePartition(browser_context()),
+ &run_loop));
+ run_loop.Run();
EXPECT_EQ(0u, Size());
}
@@ -504,14 +476,15 @@ void PopulateTestQuotaManagedNonBrowsingData(quota::MockQuotaManager* manager) {
TEST_F(StoragePartitionImplTest, RemoveQuotaManagedDataForeverBoth) {
PopulateTestQuotaManagedData(GetMockManager());
- TestClosureCallback clear_cb;
- StoragePartitionImpl sp(
- base::FilePath(), NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
- static_cast<StoragePartitionImpl*>(&sp)->OverrideQuotaManagerForTesting(
+ StoragePartitionImpl* partition = static_cast<StoragePartitionImpl*>(
+ BrowserContext::GetDefaultStoragePartition(browser_context()));
+ partition->OverrideQuotaManagerForTesting(
GetMockManager());
+
+ base::RunLoop run_loop;
base::MessageLoop::current()->PostTask(
- FROM_HERE, base::Bind(&ClearQuotaData, &sp, clear_cb.callback()));
- clear_cb.WaitForResult();
+ FROM_HERE, base::Bind(&ClearQuotaData, partition, &run_loop));
+ run_loop.Run();
EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin1, kTemporary,
kClientFile));
@@ -530,14 +503,15 @@ TEST_F(StoragePartitionImplTest, RemoveQuotaManagedDataForeverBoth) {
TEST_F(StoragePartitionImplTest, RemoveQuotaManagedDataForeverOnlyTemporary) {
PopulateTestQuotaManagedTemporaryData(GetMockManager());
- TestClosureCallback clear_cb;
- StoragePartitionImpl sp(
- base::FilePath(), NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
- static_cast<StoragePartitionImpl*>(&sp)->OverrideQuotaManagerForTesting(
+ StoragePartitionImpl* partition = static_cast<StoragePartitionImpl*>(
+ BrowserContext::GetDefaultStoragePartition(browser_context()));
+ partition->OverrideQuotaManagerForTesting(
GetMockManager());
+
+ base::RunLoop run_loop;
base::MessageLoop::current()->PostTask(
- FROM_HERE, base::Bind(&ClearQuotaData, &sp, clear_cb.callback()));
- clear_cb.WaitForResult();
+ FROM_HERE, base::Bind(&ClearQuotaData, partition, &run_loop));
+ run_loop.Run();
EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin1, kTemporary,
kClientFile));
@@ -556,14 +530,15 @@ TEST_F(StoragePartitionImplTest, RemoveQuotaManagedDataForeverOnlyTemporary) {
TEST_F(StoragePartitionImplTest, RemoveQuotaManagedDataForeverOnlyPersistent) {
PopulateTestQuotaManagedPersistentData(GetMockManager());
- TestClosureCallback clear_cb;
- StoragePartitionImpl sp(
- base::FilePath(), NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
- static_cast<StoragePartitionImpl*>(&sp)->OverrideQuotaManagerForTesting(
+ StoragePartitionImpl* partition = static_cast<StoragePartitionImpl*>(
+ BrowserContext::GetDefaultStoragePartition(browser_context()));
+ partition->OverrideQuotaManagerForTesting(
GetMockManager());
+
+ base::RunLoop run_loop;
base::MessageLoop::current()->PostTask(
- FROM_HERE, base::Bind(&ClearQuotaData, &sp, clear_cb.callback()));
- clear_cb.WaitForResult();
+ FROM_HERE, base::Bind(&ClearQuotaData, partition, &run_loop));
+ run_loop.Run();
EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin1, kTemporary,
kClientFile));
@@ -580,14 +555,15 @@ TEST_F(StoragePartitionImplTest, RemoveQuotaManagedDataForeverOnlyPersistent) {
}
TEST_F(StoragePartitionImplTest, RemoveQuotaManagedDataForeverNeither) {
- TestClosureCallback clear_cb;
- StoragePartitionImpl sp(
- base::FilePath(), NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
- static_cast<StoragePartitionImpl*>(&sp)->OverrideQuotaManagerForTesting(
+ StoragePartitionImpl* partition = static_cast<StoragePartitionImpl*>(
+ BrowserContext::GetDefaultStoragePartition(browser_context()));
+ partition->OverrideQuotaManagerForTesting(
GetMockManager());
+
+ base::RunLoop run_loop;
base::MessageLoop::current()->PostTask(
- FROM_HERE, base::Bind(&ClearQuotaData, &sp, clear_cb.callback()));
- clear_cb.WaitForResult();
+ FROM_HERE, base::Bind(&ClearQuotaData, partition, &run_loop));
+ run_loop.Run();
EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin1, kTemporary,
kClientFile));
@@ -606,15 +582,17 @@ TEST_F(StoragePartitionImplTest, RemoveQuotaManagedDataForeverNeither) {
TEST_F(StoragePartitionImplTest, RemoveQuotaManagedDataForeverSpecificOrigin) {
PopulateTestQuotaManagedData(GetMockManager());
- TestClosureCallback clear_cb;
- StoragePartitionImpl sp(
- base::FilePath(), NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
- static_cast<StoragePartitionImpl*>(&sp)->OverrideQuotaManagerForTesting(
+ StoragePartitionImpl* partition = static_cast<StoragePartitionImpl*>(
+ BrowserContext::GetDefaultStoragePartition(browser_context()));
+ partition->OverrideQuotaManagerForTesting(
GetMockManager());
+
+ base::RunLoop run_loop;
base::MessageLoop::current()->PostTask(
FROM_HERE, base::Bind(&ClearQuotaDataForOrigin,
- &sp, kOrigin1, base::Time(), clear_cb.callback()));
- clear_cb.WaitForResult();
+ partition, kOrigin1, base::Time(),
+ &run_loop));
+ run_loop.Run();
EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin1, kTemporary,
kClientFile));
@@ -633,17 +611,18 @@ TEST_F(StoragePartitionImplTest, RemoveQuotaManagedDataForeverSpecificOrigin) {
TEST_F(StoragePartitionImplTest, RemoveQuotaManagedDataForLastHour) {
PopulateTestQuotaManagedData(GetMockManager());
- TestClosureCallback clear_cb;
- StoragePartitionImpl sp(
- base::FilePath(), NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
- static_cast<StoragePartitionImpl*>(&sp)->OverrideQuotaManagerForTesting(
+ StoragePartitionImpl* partition = static_cast<StoragePartitionImpl*>(
+ BrowserContext::GetDefaultStoragePartition(browser_context()));
+ partition->OverrideQuotaManagerForTesting(
GetMockManager());
+
+ base::RunLoop run_loop;
base::MessageLoop::current()->PostTask(
FROM_HERE, base::Bind(&ClearQuotaDataForOrigin,
- &sp, GURL(),
+ partition, GURL(),
base::Time::Now() - base::TimeDelta::FromHours(1),
- clear_cb.callback()));
- clear_cb.WaitForResult();
+ &run_loop));
+ run_loop.Run();
EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin1, kTemporary,
kClientFile));
@@ -662,17 +641,17 @@ TEST_F(StoragePartitionImplTest, RemoveQuotaManagedDataForLastHour) {
TEST_F(StoragePartitionImplTest, RemoveQuotaManagedDataForLastWeek) {
PopulateTestQuotaManagedData(GetMockManager());
- TestClosureCallback clear_cb;
- StoragePartitionImpl sp(
- base::FilePath(), NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
- static_cast<StoragePartitionImpl*>(&sp)->OverrideQuotaManagerForTesting(
+ base::RunLoop run_loop;
+ StoragePartitionImpl* partition = static_cast<StoragePartitionImpl*>(
+ BrowserContext::GetDefaultStoragePartition(browser_context()));
+ partition->OverrideQuotaManagerForTesting(
GetMockManager());
base::MessageLoop::current()->PostTask(
FROM_HERE, base::Bind(&ClearQuotaDataForNonPersistent,
- &sp,
+ partition,
base::Time::Now() - base::TimeDelta::FromDays(7),
- clear_cb.callback()));
- clear_cb.WaitForResult();
+ &run_loop));
+ run_loop.Run();
EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin1, kTemporary,
kClientFile));
@@ -696,19 +675,19 @@ TEST_F(StoragePartitionImplTest, RemoveQuotaManagedUnprotectedOrigins) {
PopulateTestQuotaManagedData(GetMockManager());
- TestClosureCallback clear_cb;
- StoragePartitionImpl sp(
- base::FilePath(), NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
- static_cast<StoragePartitionImpl*>(&sp)->OverrideQuotaManagerForTesting(
+ StoragePartitionImpl* partition = static_cast<StoragePartitionImpl*>(
+ BrowserContext::GetDefaultStoragePartition(browser_context()));
+ partition->OverrideQuotaManagerForTesting(
GetMockManager());
- static_cast<StoragePartitionImpl*>(
- &sp)->OverrideSpecialStoragePolicyForTesting(mock_policy);
+ partition->OverrideSpecialStoragePolicyForTesting(mock_policy);
+
+ base::RunLoop run_loop;
base::MessageLoop::current()->PostTask(
FROM_HERE, base::Bind(&ClearQuotaDataWithOriginMatcher,
- &sp, GURL(),
+ partition, GURL(),
base::Bind(&DoesOriginMatchForUnprotectedWeb),
- base::Time(), clear_cb.callback()));
- clear_cb.WaitForResult();
+ base::Time(), &run_loop));
+ run_loop.Run();
EXPECT_TRUE(GetMockManager()->OriginHasData(kOrigin1, kTemporary,
kClientFile));
@@ -732,21 +711,20 @@ TEST_F(StoragePartitionImplTest, RemoveQuotaManagedProtectedSpecificOrigin) {
PopulateTestQuotaManagedData(GetMockManager());
- TestClosureCallback clear_cb;
- StoragePartitionImpl sp(
- base::FilePath(), NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
- static_cast<StoragePartitionImpl*>(&sp)->OverrideQuotaManagerForTesting(
+ StoragePartitionImpl* partition = static_cast<StoragePartitionImpl*>(
+ BrowserContext::GetDefaultStoragePartition(browser_context()));
+ partition->OverrideQuotaManagerForTesting(
GetMockManager());
- static_cast<StoragePartitionImpl*>(
- &sp)->OverrideSpecialStoragePolicyForTesting(mock_policy);
+ partition->OverrideSpecialStoragePolicyForTesting(mock_policy);
// Try to remove kOrigin1. Expect failure.
+ base::RunLoop run_loop;
base::MessageLoop::current()->PostTask(
FROM_HERE, base::Bind(&ClearQuotaDataWithOriginMatcher,
- &sp, kOrigin1,
+ partition, kOrigin1,
base::Bind(&DoesOriginMatchForUnprotectedWeb),
- base::Time(), clear_cb.callback()));
- clear_cb.WaitForResult();
+ base::Time(), &run_loop));
+ run_loop.Run();
EXPECT_TRUE(GetMockManager()->OriginHasData(kOrigin1, kTemporary,
kClientFile));
@@ -771,20 +749,19 @@ TEST_F(StoragePartitionImplTest, RemoveQuotaManagedProtectedOrigins) {
PopulateTestQuotaManagedData(GetMockManager());
// Try to remove kOrigin1. Expect success.
- TestClosureCallback clear_cb;
- StoragePartitionImpl sp(
- base::FilePath(), NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
- static_cast<StoragePartitionImpl*>(&sp)->OverrideQuotaManagerForTesting(
+ base::RunLoop run_loop;
+ StoragePartitionImpl* partition = static_cast<StoragePartitionImpl*>(
+ BrowserContext::GetDefaultStoragePartition(browser_context()));
+ partition->OverrideQuotaManagerForTesting(
GetMockManager());
- static_cast<StoragePartitionImpl*>(
- &sp)->OverrideSpecialStoragePolicyForTesting(mock_policy);
+ partition->OverrideSpecialStoragePolicyForTesting(mock_policy);
base::MessageLoop::current()->PostTask(
FROM_HERE,
base::Bind(&ClearQuotaDataWithOriginMatcher,
- &sp, GURL(),
+ partition, GURL(),
base::Bind(&DoesOriginMatchForBothProtectedAndUnprotectedWeb),
- base::Time(), clear_cb.callback()));
- clear_cb.WaitForResult();
+ base::Time(), &run_loop));
+ run_loop.Run();
EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin1, kTemporary,
kClientFile));
@@ -803,17 +780,17 @@ TEST_F(StoragePartitionImplTest, RemoveQuotaManagedProtectedOrigins) {
TEST_F(StoragePartitionImplTest, RemoveQuotaManagedIgnoreDevTools) {
PopulateTestQuotaManagedNonBrowsingData(GetMockManager());
- TestClosureCallback clear_cb;
- StoragePartitionImpl sp(
- base::FilePath(), NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
- static_cast<StoragePartitionImpl*>(&sp)->OverrideQuotaManagerForTesting(
+ base::RunLoop run_loop;
+ StoragePartitionImpl* partition = static_cast<StoragePartitionImpl*>(
+ BrowserContext::GetDefaultStoragePartition(browser_context()));
+ partition->OverrideQuotaManagerForTesting(
GetMockManager());
base::MessageLoop::current()->PostTask(
FROM_HERE, base::Bind(&ClearQuotaDataWithOriginMatcher,
- &sp, GURL(),
+ partition, GURL(),
base::Bind(&DoesOriginMatchUnprotected),
- base::Time(), clear_cb.callback()));
- clear_cb.WaitForResult();
+ base::Time(), &run_loop));
+ run_loop.Run();
// Check that devtools data isn't removed.
EXPECT_TRUE(GetMockManager()->OriginHasData(kOriginDevTools, kTemporary,
@@ -823,40 +800,42 @@ TEST_F(StoragePartitionImplTest, RemoveQuotaManagedIgnoreDevTools) {
}
TEST_F(StoragePartitionImplTest, RemoveCookieForever) {
- RemoveCookieTester tester(GetBrowserContext());
+ RemoveCookieTester tester(browser_context());
tester.AddCookie();
ASSERT_TRUE(tester.ContainsCookie());
- TestClosureCallback clear_cb;
- StoragePartitionImpl sp(
- base::FilePath(), NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
- sp.SetURLRequestContext(GetBrowserContext()->GetRequestContext());
+ StoragePartitionImpl* partition = static_cast<StoragePartitionImpl*>(
+ BrowserContext::GetDefaultStoragePartition(browser_context()));
+ partition->SetURLRequestContext(browser_context()->GetRequestContext());
+
+ base::RunLoop run_loop;
base::MessageLoop::current()->PostTask(
FROM_HERE, base::Bind(&ClearCookies,
- &sp, base::Time(), base::Time::Max(),
- clear_cb.callback()));
- clear_cb.WaitForResult();
+ partition, base::Time(), base::Time::Max(),
+ &run_loop));
+ run_loop.Run();
EXPECT_FALSE(tester.ContainsCookie());
}
TEST_F(StoragePartitionImplTest, RemoveCookieLastHour) {
- RemoveCookieTester tester(GetBrowserContext());
+ RemoveCookieTester tester(browser_context());
tester.AddCookie();
ASSERT_TRUE(tester.ContainsCookie());
- TestClosureCallback clear_cb;
- StoragePartitionImpl sp(
- base::FilePath(), NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
+ StoragePartitionImpl* partition = static_cast<StoragePartitionImpl*>(
+ BrowserContext::GetDefaultStoragePartition(browser_context()));
base::Time an_hour_ago = base::Time::Now() - base::TimeDelta::FromHours(1);
- sp.SetURLRequestContext(GetBrowserContext()->GetRequestContext());
+ partition->SetURLRequestContext(browser_context()->GetRequestContext());
+
+ base::RunLoop run_loop;
base::MessageLoop::current()->PostTask(
FROM_HERE, base::Bind(&ClearCookies,
- &sp, an_hour_ago, base::Time::Max(),
- clear_cb.callback()));
- clear_cb.WaitForResult();
+ partition, an_hour_ago, base::Time::Max(),
+ &run_loop));
+ run_loop.Run();
EXPECT_FALSE(tester.ContainsCookie());
}
@@ -867,30 +846,26 @@ TEST_F(StoragePartitionImplTest, RemoveUnprotectedLocalStorageForever) {
new quota::MockSpecialStoragePolicy;
mock_policy->AddProtected(kOrigin1.GetOrigin());
- RemoveLocalStorageTester tester(GetBrowserContext());
+ RemoveLocalStorageTester tester(browser_context());
tester.AddDOMStorageTestData();
EXPECT_TRUE(tester.DOMStorageExistsForOrigin(kOrigin1));
EXPECT_TRUE(tester.DOMStorageExistsForOrigin(kOrigin2));
EXPECT_TRUE(tester.DOMStorageExistsForOrigin(kOrigin3));
- TestClosureCallback clear_cb;
- DOMStorageContextWrapper* dom_storage_context =
- static_cast<DOMStorageContextWrapper*>(
- content::BrowserContext::GetDefaultStoragePartition(
- GetBrowserContext())->GetDOMStorageContext());
- StoragePartitionImpl sp(base::FilePath(), NULL, NULL, NULL, NULL,
- dom_storage_context, NULL, NULL, NULL, NULL);
- static_cast<StoragePartitionImpl*>(
- &sp)->OverrideSpecialStoragePolicyForTesting(mock_policy);
+ StoragePartitionImpl* partition = static_cast<StoragePartitionImpl*>(
+ BrowserContext::GetDefaultStoragePartition(browser_context()));
+ partition->OverrideSpecialStoragePolicyForTesting(mock_policy);
+
+ base::RunLoop run_loop;
base::MessageLoop::current()->PostTask(
FROM_HERE,
base::Bind(&ClearStuff,
StoragePartitionImpl::REMOVE_DATA_MASK_LOCAL_STORAGE,
- &sp, base::Time(), base::Time::Max(),
+ partition, base::Time(), base::Time::Max(),
base::Bind(&DoesOriginMatchForUnprotectedWeb),
- clear_cb.callback()));
- clear_cb.WaitForResult();
+ &run_loop));
+ run_loop.Run();
EXPECT_TRUE(tester.DOMStorageExistsForOrigin(kOrigin1));
EXPECT_FALSE(tester.DOMStorageExistsForOrigin(kOrigin2));
@@ -903,30 +878,26 @@ TEST_F(StoragePartitionImplTest, RemoveProtectedLocalStorageForever) {
new quota::MockSpecialStoragePolicy;
mock_policy->AddProtected(kOrigin1.GetOrigin());
- RemoveLocalStorageTester tester(GetBrowserContext());
+ RemoveLocalStorageTester tester(browser_context());
tester.AddDOMStorageTestData();
EXPECT_TRUE(tester.DOMStorageExistsForOrigin(kOrigin1));
EXPECT_TRUE(tester.DOMStorageExistsForOrigin(kOrigin2));
EXPECT_TRUE(tester.DOMStorageExistsForOrigin(kOrigin3));
- TestClosureCallback clear_cb;
- DOMStorageContextWrapper* dom_storage_context =
- static_cast<DOMStorageContextWrapper*>(
- content::BrowserContext::GetDefaultStoragePartition(
- GetBrowserContext())->GetDOMStorageContext());
- StoragePartitionImpl sp(base::FilePath(), NULL, NULL, NULL, NULL,
- dom_storage_context, NULL, NULL, NULL, NULL);
- static_cast<StoragePartitionImpl*>(
- &sp)->OverrideSpecialStoragePolicyForTesting(mock_policy);
+ StoragePartitionImpl* partition = static_cast<StoragePartitionImpl*>(
+ BrowserContext::GetDefaultStoragePartition(browser_context()));
+ partition->OverrideSpecialStoragePolicyForTesting(mock_policy);
+
+ base::RunLoop run_loop;
base::MessageLoop::current()->PostTask(
FROM_HERE,
base::Bind(&ClearStuff,
StoragePartitionImpl::REMOVE_DATA_MASK_LOCAL_STORAGE,
- &sp, base::Time(), base::Time::Max(),
+ partition, base::Time(), base::Time::Max(),
base::Bind(&DoesOriginMatchForBothProtectedAndUnprotectedWeb),
- clear_cb.callback()));
- clear_cb.WaitForResult();
+ &run_loop));
+ run_loop.Run();
// Even if kOrigin1 is protected, it will be deleted since we specify
// ClearData to delete protected data.
@@ -936,29 +907,26 @@ TEST_F(StoragePartitionImplTest, RemoveProtectedLocalStorageForever) {
}
TEST_F(StoragePartitionImplTest, RemoveLocalStorageForLastWeek) {
- RemoveLocalStorageTester tester(GetBrowserContext());
+ RemoveLocalStorageTester tester(browser_context());
tester.AddDOMStorageTestData();
EXPECT_TRUE(tester.DOMStorageExistsForOrigin(kOrigin1));
EXPECT_TRUE(tester.DOMStorageExistsForOrigin(kOrigin2));
EXPECT_TRUE(tester.DOMStorageExistsForOrigin(kOrigin3));
- TestClosureCallback clear_cb;
- DOMStorageContextWrapper* dom_storage_context =
- static_cast<DOMStorageContextWrapper*>(
- content::BrowserContext::GetDefaultStoragePartition(
- GetBrowserContext())->GetDOMStorageContext());
- StoragePartitionImpl sp(base::FilePath(), NULL, NULL, NULL, NULL,
- dom_storage_context, NULL, NULL, NULL, NULL);
+ StoragePartitionImpl* partition = static_cast<StoragePartitionImpl*>(
+ BrowserContext::GetDefaultStoragePartition(browser_context()));
base::Time a_week_ago = base::Time::Now() - base::TimeDelta::FromDays(7);
+
+ base::RunLoop run_loop;
base::MessageLoop::current()->PostTask(
FROM_HERE,
base::Bind(&ClearStuff,
StoragePartitionImpl::REMOVE_DATA_MASK_LOCAL_STORAGE,
- &sp, a_week_ago, base::Time::Max(),
+ partition, a_week_ago, base::Time::Max(),
base::Bind(&DoesOriginMatchForBothProtectedAndUnprotectedWeb),
- clear_cb.callback()));
- clear_cb.WaitForResult();
+ &run_loop));
+ run_loop.Run();
// kOrigin1 and kOrigin2 do not have age more than a week.
EXPECT_FALSE(tester.DOMStorageExistsForOrigin(kOrigin1));
diff --git a/content/public/browser/storage_partition.h b/content/public/browser/storage_partition.h
index 579ccbc..1674a57 100644
--- a/content/public/browser/storage_partition.h
+++ b/content/public/browser/storage_partition.h
@@ -113,7 +113,7 @@ class StoragePartition {
// scheduled.
virtual void ClearData(uint32 remove_mask,
uint32 quota_storage_remove_mask,
- const GURL* storage_origin,
+ const GURL& storage_origin,
const OriginMatcherFunction& origin_matcher,
const base::Time begin,
const base::Time end,