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_LOCAL_DATABASE_MANAGER_H_ | 5 #ifndef COMPONENTS_SAFE_BROWSING_DB_V4_LOCAL_DATABASE_MANAGER_H_ |
6 #define COMPONENTS_SAFE_BROWSING_DB_V4_LOCAL_DATABASE_MANAGER_H_ | 6 #define COMPONENTS_SAFE_BROWSING_DB_V4_LOCAL_DATABASE_MANAGER_H_ |
7 | 7 |
8 // A class that provides the interface between the SafeBrowsing protocol manager | 8 // A class that provides the interface between the SafeBrowsing protocol manager |
9 // and database that holds the downloaded updates. | 9 // and database that holds the downloaded updates. |
10 | 10 |
(...skipping 13 matching lines...) Expand all Loading... |
24 | 24 |
25 typedef unsigned ThreatSeverity; | 25 typedef unsigned ThreatSeverity; |
26 | 26 |
27 // Manages the local, on-disk database of updates downloaded from the | 27 // Manages the local, on-disk database of updates downloaded from the |
28 // SafeBrowsing service and interfaces with the protocol manager. | 28 // SafeBrowsing service and interfaces with the protocol manager. |
29 class V4LocalDatabaseManager : public SafeBrowsingDatabaseManager { | 29 class V4LocalDatabaseManager : public SafeBrowsingDatabaseManager { |
30 public: | 30 public: |
31 // Create and return an instance of V4LocalDatabaseManager, if Finch trial | 31 // Create and return an instance of V4LocalDatabaseManager, if Finch trial |
32 // allows it; nullptr otherwise. | 32 // allows it; nullptr otherwise. |
33 static scoped_refptr<V4LocalDatabaseManager> Create( | 33 static scoped_refptr<V4LocalDatabaseManager> Create( |
34 const base::FilePath& base_path); | 34 const base::FilePath& base_path, |
| 35 ExtendedReportingLevelCallback extended_reporting_level_callback); |
35 | 36 |
36 // | 37 // |
37 // SafeBrowsingDatabaseManager implementation | 38 // SafeBrowsingDatabaseManager implementation |
38 // | 39 // |
39 | 40 |
40 void CancelCheck(Client* client) override; | 41 void CancelCheck(Client* client) override; |
41 bool CanCheckResourceType(content::ResourceType resource_type) const override; | 42 bool CanCheckResourceType(content::ResourceType resource_type) const override; |
42 bool CanCheckUrl(const GURL& url) const override; | 43 bool CanCheckUrl(const GURL& url) const override; |
43 bool ChecksAreAlwaysAsync() const override; | 44 bool ChecksAreAlwaysAsync() const override; |
44 bool CheckBrowseUrl(const GURL& url, Client* client) override; | 45 bool CheckBrowseUrl(const GURL& url, Client* client) override; |
(...skipping 20 matching lines...) Expand all Loading... |
65 const V4ProtocolConfig& config) override; | 66 const V4ProtocolConfig& config) override; |
66 void StopOnIOThread(bool shutdown) override; | 67 void StopOnIOThread(bool shutdown) override; |
67 | 68 |
68 // | 69 // |
69 // End: SafeBrowsingDatabaseManager implementation | 70 // End: SafeBrowsingDatabaseManager implementation |
70 // | 71 // |
71 | 72 |
72 protected: | 73 protected: |
73 // Construct V4LocalDatabaseManager. | 74 // Construct V4LocalDatabaseManager. |
74 // Must be initialized by calling StartOnIOThread() before using. | 75 // Must be initialized by calling StartOnIOThread() before using. |
75 V4LocalDatabaseManager(const base::FilePath& base_path); | 76 V4LocalDatabaseManager( |
| 77 const base::FilePath& base_path, |
| 78 ExtendedReportingLevelCallback extended_reporting_level_callback); |
76 | 79 |
77 ~V4LocalDatabaseManager() override; | 80 ~V4LocalDatabaseManager() override; |
78 | 81 |
79 void SetTaskRunnerForTest( | 82 void SetTaskRunnerForTest( |
80 const scoped_refptr<base::SequencedTaskRunner>& task_runner) { | 83 const scoped_refptr<base::SequencedTaskRunner>& task_runner) { |
81 task_runner_ = task_runner; | 84 task_runner_ = task_runner; |
82 } | 85 } |
83 | 86 |
84 enum class ClientCallbackType { | 87 enum class ClientCallbackType { |
85 // This represents the case when we're trying to determine if a URL is | 88 // This represents the case when we're trying to determine if a URL is |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
258 // these stores. | 261 // these stores. |
259 bool AreStoresAvailableNow(const StoresToCheck& stores_to_check) const; | 262 bool AreStoresAvailableNow(const StoresToCheck& stores_to_check) const; |
260 | 263 |
261 // The base directory under which to create the files that contain hashes. | 264 // The base directory under which to create the files that contain hashes. |
262 const base::FilePath base_path_; | 265 const base::FilePath base_path_; |
263 | 266 |
264 // Called when the V4Database has finished applying the latest update and is | 267 // Called when the V4Database has finished applying the latest update and is |
265 // ready to process next update. | 268 // ready to process next update. |
266 DatabaseUpdatedCallback db_updated_callback_; | 269 DatabaseUpdatedCallback db_updated_callback_; |
267 | 270 |
| 271 // Callback to get the current extended reporting level. Needed by the update |
| 272 // manager. |
| 273 ExtendedReportingLevelCallback extended_reporting_level_callback_; |
| 274 |
268 // The list of stores to manage (for hash prefixes and full hashes). Each | 275 // The list of stores to manage (for hash prefixes and full hashes). Each |
269 // element contains the identifier for the store, the corresponding | 276 // element contains the identifier for the store, the corresponding |
270 // SBThreatType, whether to fetch hash prefixes for that store, and the | 277 // SBThreatType, whether to fetch hash prefixes for that store, and the |
271 // name of the file on disk that would contain the prefixes, if applicable. | 278 // name of the file on disk that would contain the prefixes, if applicable. |
272 ListInfos list_infos_; | 279 ListInfos list_infos_; |
273 | 280 |
274 // The checks awaiting for a full hash response from the SafeBrowsing service. | 281 // The checks awaiting for a full hash response from the SafeBrowsing service. |
275 PendingChecks pending_checks_; | 282 PendingChecks pending_checks_; |
276 | 283 |
277 // The checks that need to be scheduled when the database becomes ready for | 284 // The checks that need to be scheduled when the database becomes ready for |
(...skipping 12 matching lines...) Expand all Loading... |
290 | 297 |
291 base::WeakPtrFactory<V4LocalDatabaseManager> weak_factory_; | 298 base::WeakPtrFactory<V4LocalDatabaseManager> weak_factory_; |
292 | 299 |
293 friend class base::RefCountedThreadSafe<V4LocalDatabaseManager>; | 300 friend class base::RefCountedThreadSafe<V4LocalDatabaseManager>; |
294 DISALLOW_COPY_AND_ASSIGN(V4LocalDatabaseManager); | 301 DISALLOW_COPY_AND_ASSIGN(V4LocalDatabaseManager); |
295 }; // class V4LocalDatabaseManager | 302 }; // class V4LocalDatabaseManager |
296 | 303 |
297 } // namespace safe_browsing | 304 } // namespace safe_browsing |
298 | 305 |
299 #endif // COMPONENTS_SAFE_BROWSING_DB_V4_LOCAL_DATABASE_MANAGER_H_ | 306 #endif // COMPONENTS_SAFE_BROWSING_DB_V4_LOCAL_DATABASE_MANAGER_H_ |
OLD | NEW |