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_PROTOCOL_MANAGER_UTIL_H_ | 5 #ifndef COMPONENTS_SAFE_BROWSING_DB_V4_PROTOCOL_MANAGER_UTIL_H_ |
| 6 #define COMPONENTS_SAFE_BROWSING_DB_V4_PROTOCOL_MANAGER_UTIL_H_ | 6 #define COMPONENTS_SAFE_BROWSING_DB_V4_PROTOCOL_MANAGER_UTIL_H_ |
| 7 | 7 |
| 8 // A class that implements the stateless methods used by the GetHashUpdate and | 8 // A class that implements the stateless methods used by the GetHashUpdate and |
| 9 // GetFullHash stubby calls made by Chrome using the SafeBrowsing V4 protocol. | 9 // GetFullHash stubby calls made by Chrome using the SafeBrowsing V4 protocol. |
| 10 | 10 |
| 11 #include <string> | 11 #include <string> |
| 12 | 12 |
| 13 #include "base/gtest_prod_util.h" | 13 #include "base/gtest_prod_util.h" |
| 14 #include "components/safe_browsing_db/safebrowsing.pb.h" | |
| 14 #include "net/url_request/url_request_status.h" | 15 #include "net/url_request/url_request_status.h" |
| 15 #include "url/gurl.h" | 16 #include "url/gurl.h" |
| 16 | 17 |
| 17 namespace safe_browsing { | 18 namespace safe_browsing { |
| 19 // Enumerate failures for histogramming purposes. DO NOT CHANGE THE | |
| 20 // ORDERING OF THESE VALUES. | |
| 21 enum OperationResultType { | |
| 22 // 200 response code means that the server recognized the hash | |
| 23 // prefix. | |
| 24 ORT_STATUS_200 = 0, | |
| 25 | |
| 26 // Subset of successful responses where the response body wasn't parsable. | |
| 27 ORT_PARSE_ERROR = 1, | |
| 28 | |
| 29 // Gethash request failed (network error). | |
| 30 ORT_NETWORK_ERROR = 2, | |
| 31 | |
| 32 // Gethash request returned HTTP result code other than 200. | |
| 33 ORT_HTTP_ERROR = 3, | |
| 34 | |
| 35 // Gethash attempted during error backoff, no request sent. | |
| 36 ORT_BACKOFF_ERROR = 4, | |
| 37 | |
| 38 // Gethash attempted before min wait duration elapsed, no request sent. | |
| 39 ORT_MIN_WAIT_DURATION_ERROR = 5, | |
| 40 | |
| 41 // Memory space for histograms is determined by the max. ALWAYS | |
| 42 // ADD NEW VALUES BEFORE THIS ONE. | |
| 43 OPERATION_RESULT_TYPE_MAX = 6 | |
| 44 }; | |
| 18 | 45 |
| 19 // Config passed to the constructor of a V4 protocol manager. | 46 // Config passed to the constructor of a V4 protocol manager. |
| 20 struct V4ProtocolConfig { | 47 struct V4ProtocolConfig { |
| 21 // The safe browsing client name sent in each request. | 48 // The safe browsing client name sent in each request. |
| 22 std::string client_name; | 49 std::string client_name; |
| 23 | 50 |
| 24 // Current product version sent in each request. | 51 // Current product version sent in each request. |
| 25 std::string version; | 52 std::string version; |
| 26 | 53 |
| 27 // The Google API key. | 54 // The Google API key. |
| 28 std::string key_param; | 55 std::string key_param; |
| 29 }; | 56 }; |
| 30 | 57 |
| 58 struct UpdateListIdentifier { | |
|
Nathan Parker
2016/02/23 18:47:06
Is this the key for the list, like in the map of k
vakh (use Gerrit instead)
2016/02/24 03:25:56
Done.
| |
| 59 ThreatType threat_type; | |
| 60 PlatformType platform_type; | |
| 61 ThreatEntryType threat_entry_type; | |
| 62 }; | |
| 63 | |
| 31 class V4ProtocolManagerUtil { | 64 class V4ProtocolManagerUtil { |
| 32 public: | 65 public: |
| 33 // Record HTTP response code when there's no error in fetching an HTTP | 66 // Record HTTP response code when there's no error in fetching an HTTP |
| 34 // request, and the error code, when there is. | 67 // request, and the error code, when there is. |
| 35 // |metric_name| is the name of the UMA metric to record the response code or | 68 // |metric_name| is the name of the UMA metric to record the response code or |
| 36 // error code against, |status| represents the status of the HTTP request, and | 69 // error code against, |status| represents the status of the HTTP request, and |
| 37 // |response code| represents the HTTP response code received from the server. | 70 // |response code| represents the HTTP response code received from the server. |
| 38 static void RecordHttpResponseOrErrorCode(const char* metric_name, | 71 static void RecordHttpResponseOrErrorCode(const char* metric_name, |
| 39 const net::URLRequestStatus& status, | 72 const net::URLRequestStatus& status, |
| 40 int response_code); | 73 int response_code); |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 70 const std::string& client_id, | 103 const std::string& client_id, |
| 71 const std::string& version, | 104 const std::string& version, |
| 72 const std::string& key_param); | 105 const std::string& key_param); |
| 73 | 106 |
| 74 DISALLOW_COPY_AND_ASSIGN(V4ProtocolManagerUtil); | 107 DISALLOW_COPY_AND_ASSIGN(V4ProtocolManagerUtil); |
| 75 }; | 108 }; |
| 76 | 109 |
| 77 } // namespace safe_browsing | 110 } // namespace safe_browsing |
| 78 | 111 |
| 79 #endif // COMPONENTS_SAFE_BROWSING_DB_V4_PROTOCOL_MANAGER_UTIL_H_ | 112 #endif // COMPONENTS_SAFE_BROWSING_DB_V4_PROTOCOL_MANAGER_UTIL_H_ |
| OLD | NEW |