OLD | NEW |
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 #include "testing/gtest/include/gtest/gtest.h" |
9 | 9 |
10 MockBrowsingDataDatabaseHelper::MockBrowsingDataDatabaseHelper( | 10 MockBrowsingDataDatabaseHelper::MockBrowsingDataDatabaseHelper( |
(...skipping 16 matching lines...) Expand all Loading... |
27 const std::string& name) { | 27 const std::string& name) { |
28 ASSERT_FALSE(callback_.is_null()); | 28 ASSERT_FALSE(callback_.is_null()); |
29 std::string key = origin + ":" + name; | 29 std::string key = origin + ":" + name; |
30 ASSERT_TRUE(databases_.find(key) != databases_.end()); | 30 ASSERT_TRUE(databases_.find(key) != databases_.end()); |
31 last_deleted_origin_ = origin; | 31 last_deleted_origin_ = origin; |
32 last_deleted_db_ = name; | 32 last_deleted_db_ = name; |
33 databases_[key] = false; | 33 databases_[key] = false; |
34 } | 34 } |
35 | 35 |
36 void MockBrowsingDataDatabaseHelper::AddDatabaseSamples() { | 36 void MockBrowsingDataDatabaseHelper::AddDatabaseSamples() { |
37 webkit_database::DatabaseIdentifier id1 = | 37 storage::DatabaseIdentifier id1 = |
38 webkit_database::DatabaseIdentifier::Parse("http_gdbhost1_1"); | 38 storage::DatabaseIdentifier::Parse("http_gdbhost1_1"); |
39 response_.push_back(BrowsingDataDatabaseHelper::DatabaseInfo( | 39 response_.push_back(BrowsingDataDatabaseHelper::DatabaseInfo( |
40 id1, "db1", "description 1", 1, base::Time())); | 40 id1, "db1", "description 1", 1, base::Time())); |
41 databases_["http_gdbhost1_1:db1"] = true; | 41 databases_["http_gdbhost1_1:db1"] = true; |
42 webkit_database::DatabaseIdentifier id2 = | 42 storage::DatabaseIdentifier id2 = |
43 webkit_database::DatabaseIdentifier::Parse("http_gdbhost2_2"); | 43 storage::DatabaseIdentifier::Parse("http_gdbhost2_2"); |
44 response_.push_back(BrowsingDataDatabaseHelper::DatabaseInfo( | 44 response_.push_back(BrowsingDataDatabaseHelper::DatabaseInfo( |
45 id2, "db2", "description 2", 2, base::Time())); | 45 id2, "db2", "description 2", 2, base::Time())); |
46 databases_["http_gdbhost2_2:db2"] = true; | 46 databases_["http_gdbhost2_2:db2"] = true; |
47 } | 47 } |
48 | 48 |
49 void MockBrowsingDataDatabaseHelper::Notify() { | 49 void MockBrowsingDataDatabaseHelper::Notify() { |
50 callback_.Run(response_); | 50 callback_.Run(response_); |
51 } | 51 } |
52 | 52 |
53 void MockBrowsingDataDatabaseHelper::Reset() { | 53 void MockBrowsingDataDatabaseHelper::Reset() { |
54 for (std::map<const std::string, bool>::iterator i = databases_.begin(); | 54 for (std::map<const std::string, bool>::iterator i = databases_.begin(); |
55 i != databases_.end(); ++i) | 55 i != databases_.end(); ++i) |
56 i->second = true; | 56 i->second = true; |
57 } | 57 } |
58 | 58 |
59 bool MockBrowsingDataDatabaseHelper::AllDeleted() { | 59 bool MockBrowsingDataDatabaseHelper::AllDeleted() { |
60 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(); |
61 i != databases_.end(); ++i) | 61 i != databases_.end(); ++i) |
62 if (i->second) | 62 if (i->second) |
63 return false; | 63 return false; |
64 return true; | 64 return true; |
65 } | 65 } |
OLD | NEW |