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