| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // The Safe Browsing service is responsible for downloading anti-phishing and | 5 // The Safe Browsing service is responsible for downloading anti-phishing and |
| 6 // anti-malware tables and checking urls against them. | 6 // anti-malware tables and checking urls against them. |
| 7 | 7 |
| 8 #ifndef COMPONENTS_SAFE_BROWSING_DB_DATABASE_MANAGER_H_ | 8 #ifndef COMPONENTS_SAFE_BROWSING_DB_DATABASE_MANAGER_H_ |
| 9 #define COMPONENTS_SAFE_BROWSING_DB_DATABASE_MANAGER_H_ | 9 #define COMPONENTS_SAFE_BROWSING_DB_DATABASE_MANAGER_H_ |
| 10 | 10 |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 // If false, calls to CheckBrowseUrl may dcheck-fail. | 189 // If false, calls to CheckBrowseUrl may dcheck-fail. |
| 190 virtual bool IsSupported() const = 0; | 190 virtual bool IsSupported() const = 0; |
| 191 | 191 |
| 192 // | 192 // |
| 193 // Methods to indicate when to start or suspend the SafeBrowsing operations. | 193 // Methods to indicate when to start or suspend the SafeBrowsing operations. |
| 194 // These functions are always called on the IO thread. | 194 // These functions are always called on the IO thread. |
| 195 // | 195 // |
| 196 | 196 |
| 197 // Called to initialize objects that are used on the io_thread, such as the | 197 // Called to initialize objects that are used on the io_thread, such as the |
| 198 // v4 protocol manager. This may be called multiple times during the life of | 198 // v4 protocol manager. This may be called multiple times during the life of |
| 199 // the DatabaseManager. Must be called on IO thread. | 199 // the DatabaseManager. Must be called on IO thread. All subclasses should |
| 200 // override this method, set enabled_ to true and call the base class method |
| 201 // at the top of it. |
| 200 virtual void StartOnIOThread( | 202 virtual void StartOnIOThread( |
| 201 net::URLRequestContextGetter* request_context_getter, | 203 net::URLRequestContextGetter* request_context_getter, |
| 202 const V4ProtocolConfig& config); | 204 const V4ProtocolConfig& config); |
| 203 | 205 |
| 204 // Called to stop or shutdown operations on the io_thread. | 206 // Called to stop or shutdown operations on the io_thread. All subclasses |
| 207 // should override this method, set enabled_ to false and call the base class |
| 208 // method at the bottom of it. |
| 205 virtual void StopOnIOThread(bool shutdown); | 209 virtual void StopOnIOThread(bool shutdown); |
| 206 | 210 |
| 207 protected: | 211 protected: |
| 208 // Bundled client info for an API abuse hash prefix check. | 212 // Bundled client info for an API abuse hash prefix check. |
| 209 class SafeBrowsingApiCheck { | 213 class SafeBrowsingApiCheck { |
| 210 public: | 214 public: |
| 211 SafeBrowsingApiCheck(const GURL& url, Client* client); | 215 SafeBrowsingApiCheck(const GURL& url, Client* client); |
| 212 ~SafeBrowsingApiCheck(); | 216 ~SafeBrowsingApiCheck(); |
| 213 | 217 |
| 214 const GURL& url() const { return url_; } | 218 const GURL& url() const { return url_; } |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 255 // CheckApiBlacklistUrl. | 259 // CheckApiBlacklistUrl. |
| 256 void OnThreatMetadataResponse(std::unique_ptr<SafeBrowsingApiCheck> check, | 260 void OnThreatMetadataResponse(std::unique_ptr<SafeBrowsingApiCheck> check, |
| 257 const ThreatMetadata& md); | 261 const ThreatMetadata& md); |
| 258 | 262 |
| 259 typedef std::set<SafeBrowsingApiCheck*> ApiCheckSet; | 263 typedef std::set<SafeBrowsingApiCheck*> ApiCheckSet; |
| 260 | 264 |
| 261 // In-progress checks. This set owns the SafeBrowsingApiCheck pointers and is | 265 // In-progress checks. This set owns the SafeBrowsingApiCheck pointers and is |
| 262 // responsible for deleting them when removing from the set. | 266 // responsible for deleting them when removing from the set. |
| 263 ApiCheckSet api_checks_; | 267 ApiCheckSet api_checks_; |
| 264 | 268 |
| 269 // Whether the service is running. 'enabled_' is used by the |
| 270 // SafeBrowsingDatabaseManager on the IO thread during normal operations. |
| 271 bool enabled_; |
| 272 |
| 265 // Created and destroyed via StartOnIOThread/StopOnIOThread. | 273 // Created and destroyed via StartOnIOThread/StopOnIOThread. |
| 266 std::unique_ptr<V4GetHashProtocolManager> v4_get_hash_protocol_manager_; | 274 std::unique_ptr<V4GetHashProtocolManager> v4_get_hash_protocol_manager_; |
| 267 | 275 |
| 268 private: | 276 private: |
| 269 // Returns an iterator to the pending API check with the given |client|. | 277 // Returns an iterator to the pending API check with the given |client|. |
| 270 ApiCheckSet::iterator FindClientApiCheck(Client* client); | 278 ApiCheckSet::iterator FindClientApiCheck(Client* client); |
| 271 }; // class SafeBrowsingDatabaseManager | 279 }; // class SafeBrowsingDatabaseManager |
| 272 | 280 |
| 273 } // namespace safe_browsing | 281 } // namespace safe_browsing |
| 274 | 282 |
| 275 #endif // COMPONENTS_SAFE_BROWSING_DB_DATABASE_MANAGER_H_ | 283 #endif // COMPONENTS_SAFE_BROWSING_DB_DATABASE_MANAGER_H_ |
| OLD | NEW |