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, while 204 is an empty response indicating that the |
Nathan Parker
2016/02/02 22:56:14
fix comments since 204 isn't relevant anymore. Sa
kcarattini
2016/02/03 00:43:40
Done.
| |
93 // server did not recognize it. | 92 // server did not recognize it. |
94 GET_HASH_STATUS_200, | 93 GET_HASH_STATUS_200 = 0, |
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 | 94 |
110 // Subset of successful responses where the response body wasn't parsable. | 95 // Subset of successful responses where the response body wasn't parsable. |
111 GET_HASH_PARSE_ERROR, | 96 GET_HASH_PARSE_ERROR = 1, |
112 | 97 |
113 // Gethash request failed (network error). | 98 // Gethash request failed (network error). |
114 GET_HASH_NETWORK_ERROR, | 99 GET_HASH_NETWORK_ERROR = 2, |
115 | 100 |
116 // Gethash request returned HTTP result code other than 200 or 204. | 101 // Gethash request returned HTTP result code other than 200 or 204. |
117 GET_HASH_HTTP_ERROR, | 102 GET_HASH_HTTP_ERROR = 3, |
118 | 103 |
119 // Gethash attempted during error backoff, no request sent. | 104 // Gethash attempted during error backoff, no request sent. |
120 GET_HASH_BACKOFF_ERROR, | 105 GET_HASH_BACKOFF_ERROR = 4, |
121 | 106 |
122 // Gethash attempted before min wait duration elapsed, no request sent. | 107 // Gethash attempted before min wait duration elapsed, no request sent. |
123 GET_HASH_MIN_WAIT_DURATION_ERROR, | 108 GET_HASH_MIN_WAIT_DURATION_ERROR = 5, |
124 | 109 |
125 // Memory space for histograms is determined by the max. ALWAYS | 110 // Memory space for histograms is determined by the max. ALWAYS |
126 // ADD NEW VALUES BEFORE THIS ONE. | 111 // ADD NEW VALUES BEFORE THIS ONE. |
127 GET_HASH_RESULT_MAX | 112 GET_HASH_RESULT_MAX = 6 |
128 }; | 113 }; |
129 | 114 |
130 // Record a V4 GetHash result. | 115 // Record a V4 GetHash result. |
131 static void RecordGetHashResult(ResultType result_type); | 116 static void RecordGetHashResult(ResultType result_type); |
132 | 117 |
133 // Record HTTP response code when there's no error in fetching an HTTP | 118 // Record HTTP response code when there's no error in fetching an HTTP |
134 // request, and the error code, when there is. | 119 // request, and the error code, when there is. |
135 // |metric_name| is the name of the UMA metric to record the response code or | 120 // |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 | 121 // error code against, |status| represents the status of the HTTP request, and |
137 // |response code| represents the HTTP response code received from the server. | 122 // |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, | 265 net::URLRequestContextGetter* request_context_getter, |
281 const V4ProtocolConfig& config) = 0; | 266 const V4ProtocolConfig& config) = 0; |
282 | 267 |
283 private: | 268 private: |
284 DISALLOW_COPY_AND_ASSIGN(V4ProtocolManagerFactory); | 269 DISALLOW_COPY_AND_ASSIGN(V4ProtocolManagerFactory); |
285 }; | 270 }; |
286 | 271 |
287 } // namespace safe_browsing | 272 } // namespace safe_browsing |
288 | 273 |
289 #endif // COMPONENTS_SAFE_BROWSING_DB_V4_PROTOCOL_MANAGER_H_ | 274 #endif // COMPONENTS_SAFE_BROWSING_DB_V4_PROTOCOL_MANAGER_H_ |
OLD | NEW |