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 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 // |metric_name| is the name of the UMA metric to record the response code or | 184 // |metric_name| is the name of the UMA metric to record the response code or |
185 // error code against, |status| represents the status of the HTTP request, and | 185 // error code against, |status| represents the status of the HTTP request, and |
186 // |response code| represents the HTTP response code received from the server. | 186 // |response code| represents the HTTP response code received from the server. |
187 static void RecordHttpResponseOrErrorCode( | 187 static void RecordHttpResponseOrErrorCode( |
188 const char* metric_name, const net::URLRequestStatus& status, | 188 const char* metric_name, const net::URLRequestStatus& status, |
189 int response_code); | 189 int response_code); |
190 | 190 |
191 // Returns whether another update is currently scheduled. | 191 // Returns whether another update is currently scheduled. |
192 bool IsUpdateScheduled() const; | 192 bool IsUpdateScheduled() const; |
193 | 193 |
194 // Called when app changes status of foreground or background. | |
195 void SetAppInForeground(bool foreground) { | |
196 app_in_foreground_ = foreground; | |
197 } | |
198 | |
199 protected: | 194 protected: |
200 // Constructs a SafeBrowsingProtocolManager for |delegate| that issues | 195 // Constructs a SafeBrowsingProtocolManager for |delegate| that issues |
201 // network requests using |request_context_getter|. | 196 // network requests using |request_context_getter|. |
202 SafeBrowsingProtocolManager( | 197 SafeBrowsingProtocolManager( |
203 SafeBrowsingProtocolManagerDelegate* delegate, | 198 SafeBrowsingProtocolManagerDelegate* delegate, |
204 net::URLRequestContextGetter* request_context_getter, | 199 net::URLRequestContextGetter* request_context_getter, |
205 const SafeBrowsingProtocolConfig& config); | 200 const SafeBrowsingProtocolConfig& config); |
206 | 201 |
207 private: | 202 private: |
208 FRIEND_TEST_ALL_PREFIXES(SafeBrowsingProtocolManagerTest, TestBackOffTimes); | 203 FRIEND_TEST_ALL_PREFIXES(SafeBrowsingProtocolManagerTest, TestBackOffTimes); |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
462 // Data to POST when doing an update. | 457 // Data to POST when doing an update. |
463 std::string update_list_data_; | 458 std::string update_list_data_; |
464 | 459 |
465 // When true, protocol manager will not start an update unless | 460 // When true, protocol manager will not start an update unless |
466 // ForceScheduleNextUpdate() is called. This is set for testing purpose. | 461 // ForceScheduleNextUpdate() is called. This is set for testing purpose. |
467 bool disable_auto_update_; | 462 bool disable_auto_update_; |
468 | 463 |
469 // ID for URLFetchers for testing. | 464 // ID for URLFetchers for testing. |
470 int url_fetcher_id_; | 465 int url_fetcher_id_; |
471 | 466 |
472 // Whether the app is in foreground or background. | |
473 bool app_in_foreground_; | |
474 | |
475 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingProtocolManager); | 467 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingProtocolManager); |
476 }; | 468 }; |
477 | 469 |
478 // Interface of a factory to create ProtocolManager. Useful for tests. | 470 // Interface of a factory to create ProtocolManager. Useful for tests. |
479 class SBProtocolManagerFactory { | 471 class SBProtocolManagerFactory { |
480 public: | 472 public: |
481 SBProtocolManagerFactory() {} | 473 SBProtocolManagerFactory() {} |
482 virtual ~SBProtocolManagerFactory() {} | 474 virtual ~SBProtocolManagerFactory() {} |
483 virtual SafeBrowsingProtocolManager* CreateProtocolManager( | 475 virtual SafeBrowsingProtocolManager* CreateProtocolManager( |
484 SafeBrowsingProtocolManagerDelegate* delegate, | 476 SafeBrowsingProtocolManagerDelegate* delegate, |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
525 AddChunksCallback callback) = 0; | 517 AddChunksCallback callback) = 0; |
526 | 518 |
527 // Delete chunks from the database. | 519 // Delete chunks from the database. |
528 virtual void DeleteChunks( | 520 virtual void DeleteChunks( |
529 scoped_ptr<std::vector<SBChunkDelete> > chunk_deletes) = 0; | 521 scoped_ptr<std::vector<SBChunkDelete> > chunk_deletes) = 0; |
530 }; | 522 }; |
531 | 523 |
532 } // namespace safe_browsing | 524 } // namespace safe_browsing |
533 | 525 |
534 #endif // CHROME_BROWSER_SAFE_BROWSING_PROTOCOL_MANAGER_H_ | 526 #endif // CHROME_BROWSER_SAFE_BROWSING_PROTOCOL_MANAGER_H_ |
OLD | NEW |