OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "components/safe_browsing_db/v4_local_database_manager.h" | 5 #include "components/safe_browsing_db/v4_local_database_manager.h" |
6 #include "base/files/scoped_temp_dir.h" | 6 #include "base/files/scoped_temp_dir.h" |
7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 StoreAndHashPrefixes* store_and_hash_prefixes) override { | 113 StoreAndHashPrefixes* store_and_hash_prefixes) override { |
114 store_and_hash_prefixes->clear(); | 114 store_and_hash_prefixes->clear(); |
115 for (const StoreAndHashPrefix& stored_sahp : store_and_hash_prefixes_) { | 115 for (const StoreAndHashPrefix& stored_sahp : store_and_hash_prefixes_) { |
116 const PrefixSize& prefix_size = stored_sahp.hash_prefix.size(); | 116 const PrefixSize& prefix_size = stored_sahp.hash_prefix.size(); |
117 if (!full_hash.compare(0, prefix_size, stored_sahp.hash_prefix)) { | 117 if (!full_hash.compare(0, prefix_size, stored_sahp.hash_prefix)) { |
118 store_and_hash_prefixes->push_back(stored_sahp); | 118 store_and_hash_prefixes->push_back(stored_sahp); |
119 } | 119 } |
120 } | 120 } |
121 } | 121 } |
122 | 122 |
123 bool AreStoresAvailable(const StoresToCheck& stores_to_check) const override { | 123 bool AreAllStoresAvailable( |
| 124 const StoresToCheck& stores_to_check) const override { |
124 return stores_available_; | 125 return stores_available_; |
125 } | 126 } |
126 | 127 |
| 128 bool AreAnyStoresAvailable( |
| 129 const StoresToCheck& stores_to_check) const override { |
| 130 return stores_available_; |
| 131 } |
| 132 |
127 private: | 133 private: |
128 static void CreateOnTaskRunner( | 134 static void CreateOnTaskRunner( |
129 const scoped_refptr<base::SequencedTaskRunner>& db_task_runner, | 135 const scoped_refptr<base::SequencedTaskRunner>& db_task_runner, |
130 std::unique_ptr<StoreMap> store_map, | 136 std::unique_ptr<StoreMap> store_map, |
131 const StoreAndHashPrefixes& store_and_hash_prefixes, | 137 const StoreAndHashPrefixes& store_and_hash_prefixes, |
132 const scoped_refptr<base::SingleThreadTaskRunner>& callback_task_runner, | 138 const scoped_refptr<base::SingleThreadTaskRunner>& callback_task_runner, |
133 NewDatabaseReadyCallback new_db_callback, | 139 NewDatabaseReadyCallback new_db_callback, |
134 bool stores_available) { | 140 bool stores_available) { |
135 // Mimics the semantics of V4Database::CreateOnTaskRunner | 141 // Mimics the semantics of V4Database::CreateOnTaskRunner |
136 std::unique_ptr<FakeV4Database> fake_v4_database( | 142 std::unique_ptr<FakeV4Database> fake_v4_database( |
(...skipping 817 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
954 | 960 |
955 TestClient client(SB_THREAT_TYPE_BINARY_MALWARE_URL, url_chain); | 961 TestClient client(SB_THREAT_TYPE_BINARY_MALWARE_URL, url_chain); |
956 EXPECT_FALSE( | 962 EXPECT_FALSE( |
957 v4_local_database_manager_->CheckDownloadUrl(url_chain, &client)); | 963 v4_local_database_manager_->CheckDownloadUrl(url_chain, &client)); |
958 EXPECT_FALSE(client.on_check_download_urls_result_called_); | 964 EXPECT_FALSE(client.on_check_download_urls_result_called_); |
959 WaitForTasksOnTaskRunner(); | 965 WaitForTasksOnTaskRunner(); |
960 EXPECT_TRUE(client.on_check_download_urls_result_called_); | 966 EXPECT_TRUE(client.on_check_download_urls_result_called_); |
961 } | 967 } |
962 | 968 |
963 } // namespace safe_browsing | 969 } // namespace safe_browsing |
OLD | NEW |