| 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 #ifndef COMPONENTS_SAFE_BROWSING_DB_V4_DATABASE_H_ | 5 #ifndef COMPONENTS_SAFE_BROWSING_DB_V4_DATABASE_H_ |
| 6 #define COMPONENTS_SAFE_BROWSING_DB_V4_DATABASE_H_ | 6 #define COMPONENTS_SAFE_BROWSING_DB_V4_DATABASE_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <unordered_map> | 10 #include <unordered_map> |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "base/callback.h" | 13 #include "base/callback.h" |
| 14 #include "base/files/file_path.h" | 14 #include "base/files/file_path.h" |
| 15 #include "base/memory/ref_counted.h" | 15 #include "base/memory/ref_counted.h" |
| 16 #include "base/memory/weak_ptr.h" | 16 #include "base/memory/weak_ptr.h" |
| 17 #include "base/sequenced_task_runner.h" | 17 #include "base/sequenced_task_runner.h" |
| 18 #include "base/single_thread_task_runner.h" | 18 #include "base/single_thread_task_runner.h" |
| 19 #include "components/safe_browsing_db/v4_protocol_manager_util.h" | 19 #include "components/safe_browsing_db/v4_protocol_manager_util.h" |
| 20 #include "components/safe_browsing_db/v4_store.h" | 20 #include "components/safe_browsing_db/v4_store.h" |
| 21 | 21 |
| 22 namespace subresource_filter { | 22 namespace subresource_filter { |
| 23 class SubresourceFilterBrowserTestImpl; | 23 class SubresourceFilterBrowserTest; |
| 24 } | 24 } |
| 25 | 25 |
| 26 namespace safe_browsing { | 26 namespace safe_browsing { |
| 27 | 27 |
| 28 class V4Database; | 28 class V4Database; |
| 29 | 29 |
| 30 // Scheduled when the database has been read from disk and is ready to process | 30 // Scheduled when the database has been read from disk and is ready to process |
| 31 // resource reputation requests. | 31 // resource reputation requests. |
| 32 using NewDatabaseReadyCallback = | 32 using NewDatabaseReadyCallback = |
| 33 base::Callback<void(std::unique_ptr<V4Database>)>; | 33 base::Callback<void(std::unique_ptr<V4Database>)>; |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 void RecordFileSizeHistograms(); | 158 void RecordFileSizeHistograms(); |
| 159 | 159 |
| 160 protected: | 160 protected: |
| 161 V4Database(const scoped_refptr<base::SequencedTaskRunner>& db_task_runner, | 161 V4Database(const scoped_refptr<base::SequencedTaskRunner>& db_task_runner, |
| 162 std::unique_ptr<StoreMap> store_map); | 162 std::unique_ptr<StoreMap> store_map); |
| 163 | 163 |
| 164 // Map of ListIdentifier to the V4Store. | 164 // Map of ListIdentifier to the V4Store. |
| 165 const std::unique_ptr<StoreMap> store_map_; | 165 const std::unique_ptr<StoreMap> store_map_; |
| 166 | 166 |
| 167 private: | 167 private: |
| 168 friend class subresource_filter::SubresourceFilterBrowserTestImpl; | 168 friend class subresource_filter::SubresourceFilterBrowserTest; |
| 169 friend class V4DatabaseFactory; | 169 friend class V4DatabaseFactory; |
| 170 friend class V4DatabaseTest; | 170 friend class V4DatabaseTest; |
| 171 friend class V4SafeBrowsingServiceTest; | 171 friend class V4SafeBrowsingServiceTest; |
| 172 FRIEND_TEST_ALL_PREFIXES(V4DatabaseTest, TestSetupDatabaseWithFakeStores); | 172 FRIEND_TEST_ALL_PREFIXES(V4DatabaseTest, TestSetupDatabaseWithFakeStores); |
| 173 FRIEND_TEST_ALL_PREFIXES(V4DatabaseTest, | 173 FRIEND_TEST_ALL_PREFIXES(V4DatabaseTest, |
| 174 TestSetupDatabaseWithFakeStoresFailsReset); | 174 TestSetupDatabaseWithFakeStoresFailsReset); |
| 175 FRIEND_TEST_ALL_PREFIXES(V4DatabaseTest, TestApplyUpdateWithNewStates); | 175 FRIEND_TEST_ALL_PREFIXES(V4DatabaseTest, TestApplyUpdateWithNewStates); |
| 176 FRIEND_TEST_ALL_PREFIXES(V4DatabaseTest, TestApplyUpdateWithNoNewState); | 176 FRIEND_TEST_ALL_PREFIXES(V4DatabaseTest, TestApplyUpdateWithNoNewState); |
| 177 FRIEND_TEST_ALL_PREFIXES(V4DatabaseTest, TestApplyUpdateWithEmptyUpdate); | 177 FRIEND_TEST_ALL_PREFIXES(V4DatabaseTest, TestApplyUpdateWithEmptyUpdate); |
| 178 FRIEND_TEST_ALL_PREFIXES(V4DatabaseTest, TestApplyUpdateWithInvalidUpdate); | 178 FRIEND_TEST_ALL_PREFIXES(V4DatabaseTest, TestApplyUpdateWithInvalidUpdate); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 // Only meant to be dereferenced and invalidated on the IO thread and hence | 222 // Only meant to be dereferenced and invalidated on the IO thread and hence |
| 223 // named. For details, see the comment at the top of weak_ptr.h | 223 // named. For details, see the comment at the top of weak_ptr.h |
| 224 base::WeakPtrFactory<V4Database> weak_factory_on_io_; | 224 base::WeakPtrFactory<V4Database> weak_factory_on_io_; |
| 225 | 225 |
| 226 DISALLOW_COPY_AND_ASSIGN(V4Database); | 226 DISALLOW_COPY_AND_ASSIGN(V4Database); |
| 227 }; | 227 }; |
| 228 | 228 |
| 229 } // namespace safe_browsing | 229 } // namespace safe_browsing |
| 230 | 230 |
| 231 #endif // COMPONENTS_SAFE_BROWSING_DB_V4_DATABASE_H_ | 231 #endif // COMPONENTS_SAFE_BROWSING_DB_V4_DATABASE_H_ |
| OLD | NEW |