| 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_PROTOCOL_MANAGER_H_ | 5 #ifndef COMPONENTS_SAFE_BROWSING_DB_V4_PROTOCOL_MANAGER_H_ |
| 6 #define COMPONENTS_SAFE_BROWSING_DB_V4_PROTOCOL_MANAGER_H_ | 6 #define COMPONENTS_SAFE_BROWSING_DB_V4_PROTOCOL_MANAGER_H_ |
| 7 | 7 |
| 8 // A class that implements Chrome's interface with the SafeBrowsing V4 protocol. | 8 // A class that implements Chrome's interface with the SafeBrowsing V4 protocol. |
| 9 // | 9 // |
| 10 // The SafeBrowsingV4ProtocolManager handles formatting and making requests of, | 10 // The SafeBrowsingV4ProtocolManager handles formatting and making requests of, |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 FullHashCallback callback); | 79 FullHashCallback callback); |
| 80 | 80 |
| 81 // Retrieve the full hash and API metadata for a set of prefixes, and invoke | 81 // Retrieve the full hash and API metadata for a set of prefixes, and invoke |
| 82 // the callback argument when the results are retrieved. The callback may be | 82 // the callback argument when the results are retrieved. The callback may be |
| 83 // invoked synchronously. Uses the V4 Safe Browsing protocol. | 83 // invoked synchronously. Uses the V4 Safe Browsing protocol. |
| 84 virtual void GetFullHashesWithApis(const std::vector<SBPrefix>& prefixes, | 84 virtual void GetFullHashesWithApis(const std::vector<SBPrefix>& prefixes, |
| 85 FullHashCallback callback); | 85 FullHashCallback callback); |
| 86 | 86 |
| 87 // Enumerate failures for histogramming purposes. DO NOT CHANGE THE | 87 // Enumerate failures for histogramming purposes. DO NOT CHANGE THE |
| 88 // ORDERING OF THESE VALUES. | 88 // ORDERING OF THESE VALUES. |
| 89 // TODO(kcarattini): Use a custom v4 histogram set. | |
| 90 enum ResultType { | 89 enum ResultType { |
| 91 // 200 response code means that the server recognized the hash | 90 // 200 response code means that the server recognized the hash |
| 92 // prefix, while 204 is an empty response indicating that the | 91 // prefix. |
| 93 // server did not recognize it. | 92 GET_HASH_STATUS_200 = 0, |
| 94 GET_HASH_STATUS_200, | |
| 95 GET_HASH_STATUS_204, | |
| 96 | |
| 97 // Subset of successful responses which returned no full hashes. | |
| 98 // This includes the STATUS_204 case, and the *_ERROR cases. | |
| 99 GET_HASH_FULL_HASH_EMPTY, | |
| 100 | |
| 101 // Subset of successful responses for which one or more of the | |
| 102 // full hashes matched (should lead to an interstitial). | |
| 103 GET_HASH_FULL_HASH_HIT, | |
| 104 | |
| 105 // Subset of successful responses which weren't empty and have no | |
| 106 // matches. It means that there was a prefix collision which was | |
| 107 // cleared up by the full hashes. | |
| 108 GET_HASH_FULL_HASH_MISS, | |
| 109 | 93 |
| 110 // Subset of successful responses where the response body wasn't parsable. | 94 // Subset of successful responses where the response body wasn't parsable. |
| 111 GET_HASH_PARSE_ERROR, | 95 GET_HASH_PARSE_ERROR = 1, |
| 112 | 96 |
| 113 // Gethash request failed (network error). | 97 // Gethash request failed (network error). |
| 114 GET_HASH_NETWORK_ERROR, | 98 GET_HASH_NETWORK_ERROR = 2, |
| 115 | 99 |
| 116 // Gethash request returned HTTP result code other than 200 or 204. | 100 // Gethash request returned HTTP result code other than 200. |
| 117 GET_HASH_HTTP_ERROR, | 101 GET_HASH_HTTP_ERROR = 3, |
| 118 | 102 |
| 119 // Gethash attempted during error backoff, no request sent. | 103 // Gethash attempted during error backoff, no request sent. |
| 120 GET_HASH_BACKOFF_ERROR, | 104 GET_HASH_BACKOFF_ERROR = 4, |
| 121 | 105 |
| 122 // Gethash attempted before min wait duration elapsed, no request sent. | 106 // Gethash attempted before min wait duration elapsed, no request sent. |
| 123 GET_HASH_MIN_WAIT_DURATION_ERROR, | 107 GET_HASH_MIN_WAIT_DURATION_ERROR = 5, |
| 124 | 108 |
| 125 // Memory space for histograms is determined by the max. ALWAYS | 109 // Memory space for histograms is determined by the max. ALWAYS |
| 126 // ADD NEW VALUES BEFORE THIS ONE. | 110 // ADD NEW VALUES BEFORE THIS ONE. |
| 127 GET_HASH_RESULT_MAX | 111 GET_HASH_RESULT_MAX = 6 |
| 128 }; | 112 }; |
| 129 | 113 |
| 130 // Record a V4 GetHash result. | 114 // Record a V4 GetHash result. |
| 131 static void RecordGetHashResult(ResultType result_type); | 115 static void RecordGetHashResult(ResultType result_type); |
| 132 | 116 |
| 133 // Record HTTP response code when there's no error in fetching an HTTP | 117 // Record HTTP response code when there's no error in fetching an HTTP |
| 134 // request, and the error code, when there is. | 118 // request, and the error code, when there is. |
| 135 // |metric_name| is the name of the UMA metric to record the response code or | 119 // |metric_name| is the name of the UMA metric to record the response code or |
| 136 // error code against, |status| represents the status of the HTTP request, and | 120 // error code against, |status| represents the status of the HTTP request, and |
| 137 // |response code| represents the HTTP response code received from the server. | 121 // |response code| represents the HTTP response code received from the server. |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 280 net::URLRequestContextGetter* request_context_getter, | 264 net::URLRequestContextGetter* request_context_getter, |
| 281 const V4ProtocolConfig& config) = 0; | 265 const V4ProtocolConfig& config) = 0; |
| 282 | 266 |
| 283 private: | 267 private: |
| 284 DISALLOW_COPY_AND_ASSIGN(V4ProtocolManagerFactory); | 268 DISALLOW_COPY_AND_ASSIGN(V4ProtocolManagerFactory); |
| 285 }; | 269 }; |
| 286 | 270 |
| 287 } // namespace safe_browsing | 271 } // namespace safe_browsing |
| 288 | 272 |
| 289 #endif // COMPONENTS_SAFE_BROWSING_DB_V4_PROTOCOL_MANAGER_H_ | 273 #endif // COMPONENTS_SAFE_BROWSING_DB_V4_PROTOCOL_MANAGER_H_ |
| OLD | NEW |