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 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 |
268 // Whether the service is running. | 271 // Whether the service is running. |
269 bool enabled_; | 272 bool enabled_; |
270 | 273 |
| 274 ExtendedReportingLevelCallback extended_reporting_level_callback_; |
| 275 |
271 // The list of stores to manage (for hash prefixes and full hashes). Each | 276 // The list of stores to manage (for hash prefixes and full hashes). Each |
272 // element contains the identifier for the store, the corresponding | 277 // element contains the identifier for the store, the corresponding |
273 // SBThreatType, whether to fetch hash prefixes for that store, and the | 278 // SBThreatType, whether to fetch hash prefixes for that store, and the |
274 // name of the file on disk that would contain the prefixes, if applicable. | 279 // name of the file on disk that would contain the prefixes, if applicable. |
275 ListInfos list_infos_; | 280 ListInfos list_infos_; |
276 | 281 |
277 // The checks awaiting for a full hash response from the SafeBrowsing service. | 282 // The checks awaiting for a full hash response from the SafeBrowsing service. |
278 PendingChecks pending_checks_; | 283 PendingChecks pending_checks_; |
279 | 284 |
280 // The checks that need to be scheduled when the database becomes ready for | 285 // The checks that need to be scheduled when the database becomes ready for |
(...skipping 12 matching lines...) Expand all Loading... |
293 | 298 |
294 base::WeakPtrFactory<V4LocalDatabaseManager> weak_factory_; | 299 base::WeakPtrFactory<V4LocalDatabaseManager> weak_factory_; |
295 | 300 |
296 friend class base::RefCountedThreadSafe<V4LocalDatabaseManager>; | 301 friend class base::RefCountedThreadSafe<V4LocalDatabaseManager>; |
297 DISALLOW_COPY_AND_ASSIGN(V4LocalDatabaseManager); | 302 DISALLOW_COPY_AND_ASSIGN(V4LocalDatabaseManager); |
298 }; // class V4LocalDatabaseManager | 303 }; // class V4LocalDatabaseManager |
299 | 304 |
300 } // namespace safe_browsing | 305 } // namespace safe_browsing |
301 | 306 |
302 #endif // COMPONENTS_SAFE_BROWSING_DB_V4_LOCAL_DATABASE_MANAGER_H_ | 307 #endif // COMPONENTS_SAFE_BROWSING_DB_V4_LOCAL_DATABASE_MANAGER_H_ |
OLD | NEW |