| 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_UPDATE_PROTOCOL_MANAGER_H_ | 5 #ifndef COMPONENTS_SAFE_BROWSING_DB_V4_UPDATE_PROTOCOL_MANAGER_H_ |
| 6 #define COMPONENTS_SAFE_BROWSING_DB_V4_UPDATE_PROTOCOL_MANAGER_H_ | 6 #define COMPONENTS_SAFE_BROWSING_DB_V4_UPDATE_PROTOCOL_MANAGER_H_ |
| 7 | 7 |
| 8 // A class that implements Chrome's interface with the SafeBrowsing V4 update | 8 // A class that implements Chrome's interface with the SafeBrowsing V4 update |
| 9 // protocol. | 9 // protocol. |
| 10 // | 10 // |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 } // namespace net | 34 } // namespace net |
| 35 | 35 |
| 36 namespace safe_browsing { | 36 namespace safe_browsing { |
| 37 | 37 |
| 38 class V4UpdateProtocolManagerFactory; | 38 class V4UpdateProtocolManagerFactory; |
| 39 | 39 |
| 40 // V4UpdateCallback is invoked when a scheduled update completes. | 40 // V4UpdateCallback is invoked when a scheduled update completes. |
| 41 // Parameters: | 41 // Parameters: |
| 42 // - The vector of update response protobufs received from the server for | 42 // - The vector of update response protobufs received from the server for |
| 43 // each list type. | 43 // each list type. |
| 44 typedef base::Callback<void(const std::vector<ListUpdateResponse>&)> | 44 typedef base::Callback<void(std::unique_ptr<ParsedServerResponse>)> |
| 45 V4UpdateCallback; | 45 V4UpdateCallback; |
| 46 | 46 |
| 47 class V4UpdateProtocolManager : public net::URLFetcherDelegate, | 47 class V4UpdateProtocolManager : public net::URLFetcherDelegate, |
| 48 public base::NonThreadSafe { | 48 public base::NonThreadSafe { |
| 49 public: | 49 public: |
| 50 ~V4UpdateProtocolManager() override; | 50 ~V4UpdateProtocolManager() override; |
| 51 | 51 |
| 52 // Makes the passed |factory| the factory used to instantiate | 52 // Makes the passed |factory| the factory used to instantiate |
| 53 // a V4UpdateProtocolManager. Useful for tests. | 53 // a V4UpdateProtocolManager. Useful for tests. |
| 54 static void RegisterFactory(V4UpdateProtocolManagerFactory* factory) { | 54 static void RegisterFactory(V4UpdateProtocolManagerFactory* factory) { |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 | 99 |
| 100 // Fills a FetchThreatListUpdatesRequest protocol buffer for a request. | 100 // Fills a FetchThreatListUpdatesRequest protocol buffer for a request. |
| 101 // Returns the serialized and base64 URL encoded request as a string. | 101 // Returns the serialized and base64 URL encoded request as a string. |
| 102 static std::string GetBase64SerializedUpdateRequestProto( | 102 static std::string GetBase64SerializedUpdateRequestProto( |
| 103 const StoreStateMap& store_state_map); | 103 const StoreStateMap& store_state_map); |
| 104 | 104 |
| 105 // Parses the base64 encoded response received from the server as a | 105 // Parses the base64 encoded response received from the server as a |
| 106 // FetchThreatListUpdatesResponse protobuf and returns each of the | 106 // FetchThreatListUpdatesResponse protobuf and returns each of the |
| 107 // ListUpdateResponse protobufs contained in it as a vector. | 107 // ListUpdateResponse protobufs contained in it as a vector. |
| 108 // Returns true if parsing is successful, false otherwise. | 108 // Returns true if parsing is successful, false otherwise. |
| 109 bool ParseUpdateResponse( | 109 bool ParseUpdateResponse(const std::string& data_base64, |
| 110 const std::string& data_base64, | 110 ParsedServerResponse* parsed_server_response); |
| 111 std::vector<ListUpdateResponse>* list_update_responses); | |
| 112 | 111 |
| 113 // Resets the update error counter and multiplier. | 112 // Resets the update error counter and multiplier. |
| 114 void ResetUpdateErrors(); | 113 void ResetUpdateErrors(); |
| 115 | 114 |
| 116 // Updates internal update and backoff state for each update response error, | 115 // Updates internal update and backoff state for each update response error, |
| 117 // assuming that the current time is |now|. | 116 // assuming that the current time is |now|. |
| 118 void HandleUpdateError(const base::Time& now); | 117 void HandleUpdateError(const base::Time& now); |
| 119 | 118 |
| 120 // Generates the URL for the update request and issues the request for the | 119 // Generates the URL for the update request and issues the request for the |
| 121 // lists passed to the constructor. | 120 // lists passed to the constructor. |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 const V4ProtocolConfig& config, | 186 const V4ProtocolConfig& config, |
| 188 V4UpdateCallback callback) = 0; | 187 V4UpdateCallback callback) = 0; |
| 189 | 188 |
| 190 private: | 189 private: |
| 191 DISALLOW_COPY_AND_ASSIGN(V4UpdateProtocolManagerFactory); | 190 DISALLOW_COPY_AND_ASSIGN(V4UpdateProtocolManagerFactory); |
| 192 }; | 191 }; |
| 193 | 192 |
| 194 } // namespace safe_browsing | 193 } // namespace safe_browsing |
| 195 | 194 |
| 196 #endif // COMPONENTS_SAFE_BROWSING_DB_V4_UPDATE_PROTOCOL_MANAGER_H_ | 195 #endif // COMPONENTS_SAFE_BROWSING_DB_V4_UPDATE_PROTOCOL_MANAGER_H_ |
| OLD | NEW |