summaryrefslogtreecommitdiffstats
path: root/components/safe_browsing_db/v4_protocol_manager_util.h
diff options
context:
space:
mode:
authorvakh <vakh@chromium.org>2016-03-25 18:15:54 -0700
committerCommit bot <commit-bot@chromium.org>2016-03-26 01:16:54 +0000
commitddcb01e6116caefe5b89c589455df887ba18b1cd (patch)
tree31ff974d024fa0c8698339e085fb8c9e115a460e /components/safe_browsing_db/v4_protocol_manager_util.h
parentd0b8c473ba902e27b5d844c72be1d8fd179de177 (diff)
downloadchromium_src-ddcb01e6116caefe5b89c589455df887ba18b1cd.zip
chromium_src-ddcb01e6116caefe5b89c589455df887ba18b1cd.tar.gz
chromium_src-ddcb01e6116caefe5b89c589455df887ba18b1cd.tar.bz2
v4_update_protocol_manager: Basic implementation with TODOs
BUG=543161 Review URL: https://codereview.chromium.org/1727033003 Cr-Commit-Position: refs/heads/master@{#383433}
Diffstat (limited to 'components/safe_browsing_db/v4_protocol_manager_util.h')
-rw-r--r--components/safe_browsing_db/v4_protocol_manager_util.h58
1 files changed, 57 insertions, 1 deletions
diff --git a/components/safe_browsing_db/v4_protocol_manager_util.h b/components/safe_browsing_db/v4_protocol_manager_util.h
index f4665f0..6671555 100644
--- a/components/safe_browsing_db/v4_protocol_manager_util.h
+++ b/components/safe_browsing_db/v4_protocol_manager_util.h
@@ -11,11 +11,12 @@
#include <string>
#include "base/gtest_prod_util.h"
+#include "base/hash.h"
+#include "components/safe_browsing_db/safebrowsing.pb.h"
#include "net/url_request/url_request_status.h"
#include "url/gurl.h"
namespace safe_browsing {
-
// Config passed to the constructor of a V4 protocol manager.
struct V4ProtocolConfig {
// The safe browsing client name sent in each request.
@@ -28,6 +29,52 @@ struct V4ProtocolConfig {
std::string key_param;
};
+// The information required to uniquely identify each list the client is
+// interested in maintaining and downloading from the SafeBrowsing servers.
+// For example, for digests of Malware binaries on Windows:
+// platform_type = WINDOWS,
+// threat_entry_type = BINARY_DIGEST,
+// threat_type = MALWARE
+struct UpdateListIdentifier {
+ PlatformType platform_type;
+ ThreatEntryType threat_entry_type;
+ ThreatType threat_type;
+
+ bool operator==(const UpdateListIdentifier& other) const;
+ bool operator!=(const UpdateListIdentifier& other) const;
+ size_t hash() const;
+};
+
+// Enumerate failures for histogramming purposes. DO NOT CHANGE THE
+// ORDERING OF THESE VALUES.
+enum V4OperationResult {
+ // 200 response code means that the server recognized the request.
+ STATUS_200 = 0,
+
+ // Subset of successful responses where the response body wasn't parsable.
+ PARSE_ERROR = 1,
+
+ // Operation request failed (network error).
+ NETWORK_ERROR = 2,
+
+ // Operation request returned HTTP result code other than 200.
+ HTTP_ERROR = 3,
+
+ // Operation attempted during error backoff, no request sent.
+ BACKOFF_ERROR = 4,
+
+ // Operation attempted before min wait duration elapsed, no request sent.
+ MIN_WAIT_DURATION_ERROR = 5,
+
+ // Identical operation already pending.
+ ALREADY_PENDING_ERROR = 6,
+
+ // Memory space for histograms is determined by the max. ALWAYS
+ // ADD NEW VALUES BEFORE THIS ONE.
+ OPERATION_RESULT_MAX = 7
+};
+
+// A class that provides static methods related to the Pver4 protocol.
class V4ProtocolManagerUtil {
public:
// Record HTTP response code when there's no error in fetching an HTTP
@@ -76,4 +123,13 @@ class V4ProtocolManagerUtil {
} // namespace safe_browsing
+namespace std {
+template <>
+struct hash<safe_browsing::UpdateListIdentifier> {
+ std::size_t operator()(const safe_browsing::UpdateListIdentifier& s) const {
+ return s.hash();
+ }
+};
+}
+
#endif // COMPONENTS_SAFE_BROWSING_DB_V4_PROTOCOL_MANAGER_UTIL_H_