Chromium Code Reviews| 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( |
| 45 std::unique_ptr<ParsedServerResponse> parsed_server_response)> | |
|
Scott Hess - ex-Googler
2016/06/28 03:58:43
Don't need the parameter's name in this context, j
vakh (use Gerrit instead)
2016/06/28 21:34:14
Done.
| |
| 45 V4UpdateCallback; | 46 V4UpdateCallback; |
| 46 | 47 |
| 47 class V4UpdateProtocolManager : public net::URLFetcherDelegate, | 48 class V4UpdateProtocolManager : public net::URLFetcherDelegate, |
| 48 public base::NonThreadSafe { | 49 public base::NonThreadSafe { |
| 49 public: | 50 public: |
| 50 ~V4UpdateProtocolManager() override; | 51 ~V4UpdateProtocolManager() override; |
| 51 | 52 |
| 52 // Makes the passed |factory| the factory used to instantiate | 53 // Makes the passed |factory| the factory used to instantiate |
| 53 // a V4UpdateProtocolManager. Useful for tests. | 54 // a V4UpdateProtocolManager. Useful for tests. |
| 54 static void RegisterFactory(V4UpdateProtocolManagerFactory* factory) { | 55 static void RegisterFactory(V4UpdateProtocolManagerFactory* factory) { |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 97 | 98 |
| 98 // Fills a FetchThreatListUpdatesRequest protocol buffer for a request. | 99 // Fills a FetchThreatListUpdatesRequest protocol buffer for a request. |
| 99 // Returns the serialized and base 64 encoded request as a string. | 100 // Returns the serialized and base 64 encoded request as a string. |
| 100 static std::string GetBase64SerializedUpdateRequestProto( | 101 static std::string GetBase64SerializedUpdateRequestProto( |
| 101 const StoreStateMap& store_state_map); | 102 const StoreStateMap& store_state_map); |
| 102 | 103 |
| 103 // Parses the base64 encoded response received from the server as a | 104 // Parses the base64 encoded response received from the server as a |
| 104 // FetchThreatListUpdatesResponse protobuf and returns each of the | 105 // FetchThreatListUpdatesResponse protobuf and returns each of the |
| 105 // ListUpdateResponse protobufs contained in it as a vector. | 106 // ListUpdateResponse protobufs contained in it as a vector. |
| 106 // Returns true if parsing is successful, false otherwise. | 107 // Returns true if parsing is successful, false otherwise. |
| 107 bool ParseUpdateResponse( | 108 bool ParseUpdateResponse(const std::string& data_base64, |
| 108 const std::string& data_base64, | 109 ParsedServerResponse* parsed_server_response); |
| 109 std::vector<ListUpdateResponse>* list_update_responses); | |
| 110 | 110 |
| 111 // Resets the update error counter and multiplier. | 111 // Resets the update error counter and multiplier. |
| 112 void ResetUpdateErrors(); | 112 void ResetUpdateErrors(); |
| 113 | 113 |
| 114 // Updates internal update and backoff state for each update response error, | 114 // Updates internal update and backoff state for each update response error, |
| 115 // assuming that the current time is |now|. | 115 // assuming that the current time is |now|. |
| 116 void HandleUpdateError(const base::Time& now); | 116 void HandleUpdateError(const base::Time& now); |
| 117 | 117 |
| 118 // Generates the URL for the update request and issues the request for the | 118 // Generates the URL for the update request and issues the request for the |
| 119 // lists passed to the constructor. | 119 // lists passed to the constructor. |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 185 const V4ProtocolConfig& config, | 185 const V4ProtocolConfig& config, |
| 186 V4UpdateCallback callback) = 0; | 186 V4UpdateCallback callback) = 0; |
| 187 | 187 |
| 188 private: | 188 private: |
| 189 DISALLOW_COPY_AND_ASSIGN(V4UpdateProtocolManagerFactory); | 189 DISALLOW_COPY_AND_ASSIGN(V4UpdateProtocolManagerFactory); |
| 190 }; | 190 }; |
| 191 | 191 |
| 192 } // namespace safe_browsing | 192 } // namespace safe_browsing |
| 193 | 193 |
| 194 #endif // COMPONENTS_SAFE_BROWSING_DB_V4_UPDATE_PROTOCOL_MANAGER_H_ | 194 #endif // COMPONENTS_SAFE_BROWSING_DB_V4_UPDATE_PROTOCOL_MANAGER_H_ |
| OLD | NEW |