OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/mock_browsing_data_indexed_db_helper.h" | 5 #include "chrome/browser/mock_browsing_data_indexed_db_helper.h" |
6 | 6 |
7 #include "base/callback.h" | 7 #include "base/callback.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 | 9 |
10 MockBrowsingDataIndexedDBHelper::MockBrowsingDataIndexedDBHelper( | 10 MockBrowsingDataIndexedDBHelper::MockBrowsingDataIndexedDBHelper( |
(...skipping 16 matching lines...) Expand all Loading... |
27 void MockBrowsingDataIndexedDBHelper::DeleteIndexedDBFile( | 27 void MockBrowsingDataIndexedDBHelper::DeleteIndexedDBFile( |
28 const FilePath& file_path) { | 28 const FilePath& file_path) { |
29 CHECK(files_.find(file_path.value()) != files_.end()); | 29 CHECK(files_.find(file_path.value()) != files_.end()); |
30 last_deleted_file_ = file_path; | 30 last_deleted_file_ = file_path; |
31 files_[file_path.value()] = false; | 31 files_[file_path.value()] = false; |
32 } | 32 } |
33 | 33 |
34 void MockBrowsingDataIndexedDBHelper::AddIndexedDBSamples() { | 34 void MockBrowsingDataIndexedDBHelper::AddIndexedDBSamples() { |
35 response_.push_back( | 35 response_.push_back( |
36 BrowsingDataIndexedDBHelper::IndexedDBInfo( | 36 BrowsingDataIndexedDBHelper::IndexedDBInfo( |
37 "http", "idbhost1", 1, "idb1", "http://idbhost1:1/", "name", | 37 "http", "idbhost1", 1, "idb1", "http://idbhost1:1/", |
38 FilePath(FILE_PATH_LITERAL("file1")), 1, base::Time())); | 38 FilePath(FILE_PATH_LITERAL("file1")), 1, base::Time())); |
39 files_[FILE_PATH_LITERAL("file1")] = true; | 39 files_[FILE_PATH_LITERAL("file1")] = true; |
40 response_.push_back( | 40 response_.push_back( |
41 BrowsingDataIndexedDBHelper::IndexedDBInfo( | 41 BrowsingDataIndexedDBHelper::IndexedDBInfo( |
42 "http", "idbhost2", 2, "idb2", "http://idbhost2:2/", "name", | 42 "http", "idbhost2", 2, "idb2", "http://idbhost2:2/", |
43 FilePath(FILE_PATH_LITERAL("file2")), 2, base::Time())); | 43 FilePath(FILE_PATH_LITERAL("file2")), 2, base::Time())); |
44 files_[FILE_PATH_LITERAL("file2")] = true; | 44 files_[FILE_PATH_LITERAL("file2")] = true; |
45 } | 45 } |
46 | 46 |
47 void MockBrowsingDataIndexedDBHelper::Notify() { | 47 void MockBrowsingDataIndexedDBHelper::Notify() { |
48 CHECK(callback_.get()); | 48 CHECK(callback_.get()); |
49 callback_->Run(response_); | 49 callback_->Run(response_); |
50 } | 50 } |
51 | 51 |
52 void MockBrowsingDataIndexedDBHelper::Reset() { | 52 void MockBrowsingDataIndexedDBHelper::Reset() { |
53 for (std::map<const FilePath::StringType, bool>::iterator i = files_.begin(); | 53 for (std::map<const FilePath::StringType, bool>::iterator i = files_.begin(); |
54 i != files_.end(); ++i) | 54 i != files_.end(); ++i) |
55 i->second = true; | 55 i->second = true; |
56 } | 56 } |
57 | 57 |
58 bool MockBrowsingDataIndexedDBHelper::AllDeleted() { | 58 bool MockBrowsingDataIndexedDBHelper::AllDeleted() { |
59 for (std::map<const FilePath::StringType, bool>::const_iterator i = | 59 for (std::map<const FilePath::StringType, bool>::const_iterator i = |
60 files_.begin(); i != files_.end(); ++i) | 60 files_.begin(); i != files_.end(); ++i) |
61 if (i->second) | 61 if (i->second) |
62 return false; | 62 return false; |
63 return true; | 63 return true; |
64 } | 64 } |
OLD | NEW |