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

Unified Diff: chrome/browser/browsing_data/mock_browsing_data_cache_storage_helper.cc

Issue 1297093002: Cache Storage API: Hook up to chrome://settings/cookies (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase onto https://codereview.chromium.org/1297023004 Created 5 years, 4 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
Index: chrome/browser/browsing_data/mock_browsing_data_cache_storage_helper.cc
diff --git a/chrome/browser/browsing_data/mock_browsing_data_cache_storage_helper.cc b/chrome/browser/browsing_data/mock_browsing_data_cache_storage_helper.cc
new file mode 100644
index 0000000000000000000000000000000000000000..68c9b1b57258f2ac3df484159eb93a4ff9b5b2ab
--- /dev/null
+++ b/chrome/browser/browsing_data/mock_browsing_data_cache_storage_helper.cc
@@ -0,0 +1,63 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/browsing_data/mock_browsing_data_cache_storage_helper.h"
+
+#include "base/callback.h"
+#include "base/logging.h"
+#include "chrome/browser/profiles/profile.h"
+#include "content/public/browser/browser_context.h"
+#include "content/public/browser/storage_partition.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+MockBrowsingDataCacheStorageHelper::MockBrowsingDataCacheStorageHelper(
+ Profile* profile)
+ : BrowsingDataCacheStorageHelper(
+ content::BrowserContext::GetDefaultStoragePartition(profile)
+ ->GetCacheStorageContext()) {}
+
+MockBrowsingDataCacheStorageHelper::~MockBrowsingDataCacheStorageHelper() {}
+
+void MockBrowsingDataCacheStorageHelper::StartFetching(
+ const base::Callback<
+ void(const std::list<content::CacheStorageUsageInfo>&)>& callback) {
+ ASSERT_FALSE(callback.is_null());
+ ASSERT_TRUE(callback_.is_null());
+ callback_ = callback;
+}
+
+void MockBrowsingDataCacheStorageHelper::DeleteCacheStorage(
+ const GURL& origin) {
+ ASSERT_FALSE(callback_.is_null());
+ ASSERT_TRUE(origins_.find(origin) != origins_.end());
+ origins_[origin] = false;
+}
+
+void MockBrowsingDataCacheStorageHelper::AddCacheStorageSamples() {
+ const GURL kOrigin1("https://cshost1:1/");
+ const GURL kOrigin2("https://cshost2:2/");
+ content::CacheStorageUsageInfo info1(kOrigin1, 1, base::Time());
+ response_.push_back(info1);
+ origins_[kOrigin1] = true;
+ content::CacheStorageUsageInfo info2(kOrigin2, 2, base::Time());
+ response_.push_back(info2);
+ origins_[kOrigin2] = true;
+}
+
+void MockBrowsingDataCacheStorageHelper::Notify() {
+ callback_.Run(response_);
+}
+
+void MockBrowsingDataCacheStorageHelper::Reset() {
+ for (auto& pair : origins_)
+ pair.second = true;
+}
+
+bool MockBrowsingDataCacheStorageHelper::AllDeleted() {
+ for (const auto& pair : origins_) {
+ if (pair.second)
+ return false;
+ }
+ return true;
+}

Powered by Google App Engine
This is Rietveld 408576698