| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 // The SafeBrowsingProtocolManager handles formatting and making requests of, | 9 // The SafeBrowsingProtocolManager handles formatting and making requests of, |
| 10 // and handling responses from, Google's SafeBrowsing servers. This class uses | 10 // and handling responses from, Google's SafeBrowsing servers. This class uses |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 return reinterpret_cast<size_t>(fetcher); | 39 return reinterpret_cast<size_t>(fetcher); |
| 40 } | 40 } |
| 41 }; | 41 }; |
| 42 } | 42 } |
| 43 #endif | 43 #endif |
| 44 | 44 |
| 45 class SafeBrowsingProtocolManager : public URLFetcher::Delegate { | 45 class SafeBrowsingProtocolManager : public URLFetcher::Delegate { |
| 46 // Testing friends: | 46 // Testing friends: |
| 47 FRIEND_TEST(SafeBrowsingProtocolManagerTest, TestBackOffTimes); | 47 FRIEND_TEST(SafeBrowsingProtocolManagerTest, TestBackOffTimes); |
| 48 FRIEND_TEST(SafeBrowsingProtocolManagerTest, TestChunkStrings); | 48 FRIEND_TEST(SafeBrowsingProtocolManagerTest, TestChunkStrings); |
| 49 FRIEND_TEST(SafeBrowsingProtocolManagerTest, | 49 FRIEND_TEST(SafeBrowsingProtocolManagerTest, TestGetHashBackOffTimes); |
| 50 DISABLED_TestGetHashBackOffTimes); | |
| 51 | 50 |
| 52 public: | 51 public: |
| 53 SafeBrowsingProtocolManager(SafeBrowsingService* sb_service, | 52 SafeBrowsingProtocolManager(SafeBrowsingService* sb_service, |
| 54 MessageLoop* notify_loop, | 53 MessageLoop* notify_loop, |
| 55 const std::string& client_key, | 54 const std::string& client_key, |
| 56 const std::string& wrapped_key); | 55 const std::string& wrapped_key); |
| 57 ~SafeBrowsingProtocolManager(); | 56 ~SafeBrowsingProtocolManager(); |
| 58 | 57 |
| 59 // Set up the update schedule and internal state for making periodic requests | 58 // Set up the update schedule and internal state for making periodic requests |
| 60 // of the SafeBrowsing service. | 59 // of the SafeBrowsing service. |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 static std::string FormatList(const SBListChunkRanges& list, bool use_mac); | 138 static std::string FormatList(const SBListChunkRanges& list, bool use_mac); |
| 140 | 139 |
| 141 // Run the protocol parser on received data and update the SafeBrowsingService | 140 // Run the protocol parser on received data and update the SafeBrowsingService |
| 142 // with the new content. Returns 'true' on successful parse, 'false' on error. | 141 // with the new content. Returns 'true' on successful parse, 'false' on error. |
| 143 bool HandleServiceResponse(const GURL& url, const char* data, int length); | 142 bool HandleServiceResponse(const GURL& url, const char* data, int length); |
| 144 | 143 |
| 145 // If the SafeBrowsing service wants us to re-key, we clear our key state and | 144 // If the SafeBrowsing service wants us to re-key, we clear our key state and |
| 146 // issue the request. | 145 // issue the request. |
| 147 void HandleReKey(); | 146 void HandleReKey(); |
| 148 | 147 |
| 149 // Update internal state for each GetHash response error. | 148 // Update internal state for each GetHash response error, assuming that the |
| 150 void HandleGetHashError(); | 149 // current time is |now|. |
| 150 void HandleGetHashError(const base::Time& now); |
| 151 | 151 |
| 152 // Helper function for update completion. | 152 // Helper function for update completion. |
| 153 void UpdateFinished(bool success); | 153 void UpdateFinished(bool success); |
| 154 | 154 |
| 155 private: | 155 private: |
| 156 // Main SafeBrowsing interface object. | 156 // Main SafeBrowsing interface object. |
| 157 SafeBrowsingService* sb_service_; | 157 SafeBrowsingService* sb_service_; |
| 158 | 158 |
| 159 // Current active request (in case we need to cancel) for updates or chunks | 159 // Current active request (in case we need to cancel) for updates or chunks |
| 160 // from the SafeBrowsing service. We can only have one of these outstanding | 160 // from the SafeBrowsing service. We can only have one of these outstanding |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 // Track the size of each update (in bytes). | 231 // Track the size of each update (in bytes). |
| 232 int update_size_; | 232 int update_size_; |
| 233 | 233 |
| 234 // Track outstanding malware report fetchers for clean up. | 234 // Track outstanding malware report fetchers for clean up. |
| 235 std::set<const URLFetcher*> malware_reports_; | 235 std::set<const URLFetcher*> malware_reports_; |
| 236 | 236 |
| 237 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingProtocolManager); | 237 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingProtocolManager); |
| 238 }; | 238 }; |
| 239 | 239 |
| 240 #endif // CHROME_BROWSER_SAFE_BROWSING_PROTOCOL_MANAGER_H_ | 240 #endif // CHROME_BROWSER_SAFE_BROWSING_PROTOCOL_MANAGER_H_ |
| OLD | NEW |