| 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 #ifndef CHROME_BROWSER_SAFE_BROWSING_PROTOCOL_MANAGER_H_ | 5 #ifndef CHROME_BROWSER_SAFE_BROWSING_PROTOCOL_MANAGER_H_ |
| 6 #define CHROME_BROWSER_SAFE_BROWSING_PROTOCOL_MANAGER_H_ | 6 #define CHROME_BROWSER_SAFE_BROWSING_PROTOCOL_MANAGER_H_ |
| 7 | 7 |
| 8 // A class that implements Chrome's interface with the SafeBrowsing protocol. | 8 // A class that implements Chrome's interface with the SafeBrowsing protocol. |
| 9 // See https://developers.google.com/safe-browsing/developers_guide_v2 for | 9 // See https://developers.google.com/safe-browsing/developers_guide_v2 for |
| 10 // protocol details. | 10 // protocol details. |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 }; | 159 }; |
| 160 | 160 |
| 161 // Record a GetHash result. |is_download| indicates if the get | 161 // Record a GetHash result. |is_download| indicates if the get |
| 162 // hash is triggered by download related lookup. | 162 // hash is triggered by download related lookup. |
| 163 static void RecordGetHashResult(bool is_download, | 163 static void RecordGetHashResult(bool is_download, |
| 164 ResultType result_type); | 164 ResultType result_type); |
| 165 | 165 |
| 166 // Returns whether another update is currently scheduled. | 166 // Returns whether another update is currently scheduled. |
| 167 bool IsUpdateScheduled() const; | 167 bool IsUpdateScheduled() const; |
| 168 | 168 |
| 169 // Called when app changes status of foreground or background. |
| 170 void SetAppInForeground(bool foreground) { |
| 171 app_in_foreground_ = foreground; |
| 172 } |
| 173 |
| 169 protected: | 174 protected: |
| 170 // Constructs a SafeBrowsingProtocolManager for |delegate| that issues | 175 // Constructs a SafeBrowsingProtocolManager for |delegate| that issues |
| 171 // network requests using |request_context_getter|. | 176 // network requests using |request_context_getter|. |
| 172 SafeBrowsingProtocolManager( | 177 SafeBrowsingProtocolManager( |
| 173 SafeBrowsingProtocolManagerDelegate* delegate, | 178 SafeBrowsingProtocolManagerDelegate* delegate, |
| 174 net::URLRequestContextGetter* request_context_getter, | 179 net::URLRequestContextGetter* request_context_getter, |
| 175 const SafeBrowsingProtocolConfig& config); | 180 const SafeBrowsingProtocolConfig& config); |
| 176 | 181 |
| 177 private: | 182 private: |
| 178 FRIEND_TEST_ALL_PREFIXES(SafeBrowsingProtocolManagerTest, TestBackOffTimes); | 183 FRIEND_TEST_ALL_PREFIXES(SafeBrowsingProtocolManagerTest, TestBackOffTimes); |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 381 // Data to POST when doing an update. | 386 // Data to POST when doing an update. |
| 382 std::string update_list_data_; | 387 std::string update_list_data_; |
| 383 | 388 |
| 384 // When true, protocol manager will not start an update unless | 389 // When true, protocol manager will not start an update unless |
| 385 // ForceScheduleNextUpdate() is called. This is set for testing purpose. | 390 // ForceScheduleNextUpdate() is called. This is set for testing purpose. |
| 386 bool disable_auto_update_; | 391 bool disable_auto_update_; |
| 387 | 392 |
| 388 // ID for URLFetchers for testing. | 393 // ID for URLFetchers for testing. |
| 389 int url_fetcher_id_; | 394 int url_fetcher_id_; |
| 390 | 395 |
| 396 // Whether the app is in foreground or background. |
| 397 bool app_in_foreground_; |
| 398 |
| 391 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingProtocolManager); | 399 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingProtocolManager); |
| 392 }; | 400 }; |
| 393 | 401 |
| 394 // Interface of a factory to create ProtocolManager. Useful for tests. | 402 // Interface of a factory to create ProtocolManager. Useful for tests. |
| 395 class SBProtocolManagerFactory { | 403 class SBProtocolManagerFactory { |
| 396 public: | 404 public: |
| 397 SBProtocolManagerFactory() {} | 405 SBProtocolManagerFactory() {} |
| 398 virtual ~SBProtocolManagerFactory() {} | 406 virtual ~SBProtocolManagerFactory() {} |
| 399 virtual SafeBrowsingProtocolManager* CreateProtocolManager( | 407 virtual SafeBrowsingProtocolManager* CreateProtocolManager( |
| 400 SafeBrowsingProtocolManagerDelegate* delegate, | 408 SafeBrowsingProtocolManagerDelegate* delegate, |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 434 // call at a later time. | 442 // call at a later time. |
| 435 virtual void AddChunks(const std::string& list, SBChunkList* chunks, | 443 virtual void AddChunks(const std::string& list, SBChunkList* chunks, |
| 436 AddChunksCallback callback) = 0; | 444 AddChunksCallback callback) = 0; |
| 437 | 445 |
| 438 // Delete chunks from the database. | 446 // Delete chunks from the database. |
| 439 virtual void DeleteChunks( | 447 virtual void DeleteChunks( |
| 440 std::vector<SBChunkDelete>* delete_chunks) = 0; | 448 std::vector<SBChunkDelete>* delete_chunks) = 0; |
| 441 }; | 449 }; |
| 442 | 450 |
| 443 #endif // CHROME_BROWSER_SAFE_BROWSING_PROTOCOL_MANAGER_H_ | 451 #endif // CHROME_BROWSER_SAFE_BROWSING_PROTOCOL_MANAGER_H_ |
| OLD | NEW |