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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/browsing_data/mock_browsing_data_cache_storage_helper.h "
6
7 #include "base/callback.h"
8 #include "base/logging.h"
9 #include "chrome/browser/profiles/profile.h"
10 #include "content/public/browser/browser_context.h"
11 #include "content/public/browser/storage_partition.h"
12 #include "testing/gtest/include/gtest/gtest.h"
13
14 MockBrowsingDataCacheStorageHelper::MockBrowsingDataCacheStorageHelper(
15 Profile* profile)
16 : BrowsingDataCacheStorageHelper(
17 content::BrowserContext::GetDefaultStoragePartition(profile)
18 ->GetCacheStorageContext()) {}
19
20 MockBrowsingDataCacheStorageHelper::~MockBrowsingDataCacheStorageHelper() {}
21
22 void MockBrowsingDataCacheStorageHelper::StartFetching(
23 const base::Callback<
24 void(const std::list<content::CacheStorageUsageInfo>&)>& callback) {
25 ASSERT_FALSE(callback.is_null());
26 ASSERT_TRUE(callback_.is_null());
27 callback_ = callback;
28 }
29
30 void MockBrowsingDataCacheStorageHelper::DeleteCacheStorage(
31 const GURL& origin) {
32 ASSERT_FALSE(callback_.is_null());
33 ASSERT_TRUE(origins_.find(origin) != origins_.end());
34 origins_[origin] = false;
35 }
36
37 void MockBrowsingDataCacheStorageHelper::AddCacheStorageSamples() {
38 const GURL kOrigin1("https://cshost1:1/");
39 const GURL kOrigin2("https://cshost2:2/");
40 content::CacheStorageUsageInfo info1(kOrigin1, 1, base::Time());
41 response_.push_back(info1);
42 origins_[kOrigin1] = true;
43 content::CacheStorageUsageInfo info2(kOrigin2, 2, base::Time());
44 response_.push_back(info2);
45 origins_[kOrigin2] = true;
46 }
47
48 void MockBrowsingDataCacheStorageHelper::Notify() {
49 callback_.Run(response_);
50 }
51
52 void MockBrowsingDataCacheStorageHelper::Reset() {
53 for (auto& pair : origins_)
54 pair.second = true;
55 }
56
57 bool MockBrowsingDataCacheStorageHelper::AllDeleted() {
58 for (const auto& pair : origins_) {
59 if (pair.second)
60 return false;
61 }
62 return true;
63 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698