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

Side by Side Diff: chrome/browser/browsing_data/mock_browsing_data_database_helper.cc

Issue 459233002: Browsing Data Deletion: Style fixes (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Re-apply comment tweaks Created 6 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/browsing_data/mock_browsing_data_database_helper.h" 5 #include "chrome/browser/browsing_data/mock_browsing_data_database_helper.h"
6 6
7 #include "base/callback.h" 7 #include "base/callback.h"
8 #include "testing/gtest/include/gtest/gtest.h"
8 9
9 MockBrowsingDataDatabaseHelper::MockBrowsingDataDatabaseHelper( 10 MockBrowsingDataDatabaseHelper::MockBrowsingDataDatabaseHelper(
10 Profile* profile) 11 Profile* profile)
11 : BrowsingDataDatabaseHelper(profile) { 12 : BrowsingDataDatabaseHelper(profile) {
12 } 13 }
13 14
14 MockBrowsingDataDatabaseHelper::~MockBrowsingDataDatabaseHelper() { 15 MockBrowsingDataDatabaseHelper::~MockBrowsingDataDatabaseHelper() {
15 } 16 }
16 17
17 void MockBrowsingDataDatabaseHelper::StartFetching( 18 void MockBrowsingDataDatabaseHelper::StartFetching(
18 const base::Callback<void(const std::list<DatabaseInfo>&)>& callback) { 19 const base::Callback<void(const std::list<DatabaseInfo>&)>& callback) {
20 ASSERT_FALSE(callback.is_null());
21 ASSERT_TRUE(callback_.is_null());
19 callback_ = callback; 22 callback_ = callback;
20 } 23 }
21 24
22 void MockBrowsingDataDatabaseHelper::DeleteDatabase( 25 void MockBrowsingDataDatabaseHelper::DeleteDatabase(
23 const std::string& origin, 26 const std::string& origin,
24 const std::string& name) { 27 const std::string& name) {
28 ASSERT_FALSE(callback_.is_null());
25 std::string key = origin + ":" + name; 29 std::string key = origin + ":" + name;
26 CHECK(databases_.find(key) != databases_.end()); 30 ASSERT_TRUE(databases_.find(key) != databases_.end());
27 last_deleted_origin_ = origin; 31 last_deleted_origin_ = origin;
28 last_deleted_db_ = name; 32 last_deleted_db_ = name;
29 databases_[key] = false; 33 databases_[key] = false;
30 } 34 }
31 35
32 void MockBrowsingDataDatabaseHelper::AddDatabaseSamples() { 36 void MockBrowsingDataDatabaseHelper::AddDatabaseSamples() {
33 webkit_database::DatabaseIdentifier id1 = 37 webkit_database::DatabaseIdentifier id1 =
34 webkit_database::DatabaseIdentifier::Parse("http_gdbhost1_1"); 38 webkit_database::DatabaseIdentifier::Parse("http_gdbhost1_1");
35 response_.push_back(BrowsingDataDatabaseHelper::DatabaseInfo( 39 response_.push_back(BrowsingDataDatabaseHelper::DatabaseInfo(
36 id1, "db1", "description 1", 1, base::Time())); 40 id1, "db1", "description 1", 1, base::Time()));
37 databases_["http_gdbhost1_1:db1"] = true; 41 databases_["http_gdbhost1_1:db1"] = true;
38 webkit_database::DatabaseIdentifier id2 = 42 webkit_database::DatabaseIdentifier id2 =
39 webkit_database::DatabaseIdentifier::Parse("http_gdbhost2_2"); 43 webkit_database::DatabaseIdentifier::Parse("http_gdbhost2_2");
40 response_.push_back(BrowsingDataDatabaseHelper::DatabaseInfo( 44 response_.push_back(BrowsingDataDatabaseHelper::DatabaseInfo(
41 id2, "db2", "description 2", 2, base::Time())); 45 id2, "db2", "description 2", 2, base::Time()));
42 databases_["http_gdbhost2_2:db2"] = true; 46 databases_["http_gdbhost2_2:db2"] = true;
43 } 47 }
44 48
45 void MockBrowsingDataDatabaseHelper::Notify() { 49 void MockBrowsingDataDatabaseHelper::Notify() {
46 CHECK_EQ(false, callback_.is_null());
47 callback_.Run(response_); 50 callback_.Run(response_);
48 } 51 }
49 52
50 void MockBrowsingDataDatabaseHelper::Reset() { 53 void MockBrowsingDataDatabaseHelper::Reset() {
51 for (std::map<const std::string, bool>::iterator i = databases_.begin(); 54 for (std::map<const std::string, bool>::iterator i = databases_.begin();
52 i != databases_.end(); ++i) 55 i != databases_.end(); ++i)
53 i->second = true; 56 i->second = true;
54 } 57 }
55 58
56 bool MockBrowsingDataDatabaseHelper::AllDeleted() { 59 bool MockBrowsingDataDatabaseHelper::AllDeleted() {
57 for (std::map<const std::string, bool>::const_iterator i = databases_.begin(); 60 for (std::map<const std::string, bool>::const_iterator i = databases_.begin();
58 i != databases_.end(); ++i) 61 i != databases_.end(); ++i)
59 if (i->second) 62 if (i->second)
60 return false; 63 return false;
61 return true; 64 return true;
62 } 65 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698