OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #pragma once | 7 #pragma once |
8 | 8 |
9 // A class that implements Chrome's interface with the SafeBrowsing protocol. | 9 // A class that implements Chrome's interface with the SafeBrowsing protocol. |
10 // The SafeBrowsingProtocolManager handles formatting and making requests of, | 10 // The SafeBrowsingProtocolManager handles formatting and making requests of, |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 // be changed in the middle of an update, caller (e.g.: SafeBrowsingService) | 151 // be changed in the middle of an update, caller (e.g.: SafeBrowsingService) |
152 // should call this after callbacks triggered in UpdateFinished() or before | 152 // should call this after callbacks triggered in UpdateFinished() or before |
153 // IssueUpdateRequest(). | 153 // IssueUpdateRequest(). |
154 void set_additional_query(const std::string& query) { | 154 void set_additional_query(const std::string& query) { |
155 additional_query_ = query; | 155 additional_query_ = query; |
156 } | 156 } |
157 const std::string& additional_query() const { | 157 const std::string& additional_query() const { |
158 return additional_query_; | 158 return additional_query_; |
159 } | 159 } |
160 | 160 |
| 161 // Enumerate failures for histogramming purposes. DO NOT CHANGE THE |
| 162 // ORDERING OF THESE VALUES. |
| 163 enum ResultType { |
| 164 // 200 response code means that the server recognized the hash |
| 165 // prefix, while 204 is an empty response indicating that the |
| 166 // server did not recognize it. |
| 167 GET_HASH_STATUS_200, |
| 168 GET_HASH_STATUS_204, |
| 169 |
| 170 // Subset of successful responses which returned no full hashes. |
| 171 // This includes the 204 case, and also 200 responses for stale |
| 172 // prefixes (deleted at the server but yet deleted on the client). |
| 173 GET_HASH_FULL_HASH_EMPTY, |
| 174 |
| 175 // Subset of successful responses for which one or more of the |
| 176 // full hashes matched (should lead to an interstitial). |
| 177 GET_HASH_FULL_HASH_HIT, |
| 178 |
| 179 // Subset of successful responses which weren't empty and have no |
| 180 // matches. It means that there was a prefix collision which was |
| 181 // cleared up by the full hashes. |
| 182 GET_HASH_FULL_HASH_MISS, |
| 183 |
| 184 // Memory space for histograms is determined by the max. ALWAYS |
| 185 // ADD NEW VALUES BEFORE THIS ONE. |
| 186 GET_HASH_RESULT_MAX |
| 187 }; |
| 188 |
| 189 // Record a GetHash result. |
| 190 static void RecordGetHashResult(ResultType result_type); |
| 191 |
161 protected: | 192 protected: |
162 // Constructs a SafeBrowsingProtocolManager for |sb_service| that issues | 193 // Constructs a SafeBrowsingProtocolManager for |sb_service| that issues |
163 // network requests using |request_context_getter|. When |disable_auto_update| | 194 // network requests using |request_context_getter|. When |disable_auto_update| |
164 // is true, protocol manager won't schedule next update until | 195 // is true, protocol manager won't schedule next update until |
165 // ForceScheduleNextUpdate is called. | 196 // ForceScheduleNextUpdate is called. |
166 SafeBrowsingProtocolManager(SafeBrowsingService* sb_service, | 197 SafeBrowsingProtocolManager(SafeBrowsingService* sb_service, |
167 const std::string& client_name, | 198 const std::string& client_name, |
168 const std::string& client_key, | 199 const std::string& client_key, |
169 const std::string& wrapped_key, | 200 const std::string& wrapped_key, |
170 URLRequestContextGetter* request_context_getter, | 201 URLRequestContextGetter* request_context_getter, |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
370 std::string https_url_prefix_; | 401 std::string https_url_prefix_; |
371 | 402 |
372 // When true, protocol manager will not start an update unless | 403 // When true, protocol manager will not start an update unless |
373 // ForceScheduleNextUpdate() is called. This is set for testing purpose. | 404 // ForceScheduleNextUpdate() is called. This is set for testing purpose. |
374 bool disable_auto_update_; | 405 bool disable_auto_update_; |
375 | 406 |
376 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingProtocolManager); | 407 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingProtocolManager); |
377 }; | 408 }; |
378 | 409 |
379 #endif // CHROME_BROWSER_SAFE_BROWSING_PROTOCOL_MANAGER_H_ | 410 #endif // CHROME_BROWSER_SAFE_BROWSING_PROTOCOL_MANAGER_H_ |
OLD | NEW |