Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(182)

Side by Side Diff: components/safe_browsing_db/v4_get_hash_protocol_manager.h

Issue 1719883003: Ignore: v4_update_protocol_manager: Basic implementation with TODOs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@v4_01_prot_mgr
Patch Set: rebase again (and more branching funkiness) Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_GET_HASH_PROTOCOL_MANAGER_H_ 5 #ifndef COMPONENTS_SAFE_BROWSING_DB_V4_GET_HASH_PROTOCOL_MANAGER_H_
6 #define COMPONENTS_SAFE_BROWSING_DB_V4_GET_HASH_PROTOCOL_MANAGER_H_ 6 #define COMPONENTS_SAFE_BROWSING_DB_V4_GET_HASH_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 V4GetHashProtocolManager handles formatting and making requests of, and 10 // The V4GetHashProtocolManager handles formatting and making requests of, and
(...skipping 30 matching lines...) Expand all
41 public: 41 public:
42 // FullHashCallback is invoked when GetFullHashes completes. 42 // FullHashCallback is invoked when GetFullHashes completes.
43 // Parameters: 43 // Parameters:
44 // - The vector of full hash results. If empty, indicates that there 44 // - The vector of full hash results. If empty, indicates that there
45 // were no matches, and that the resource is safe. 45 // were no matches, and that the resource is safe.
46 // - The negative cache duration of the result. 46 // - The negative cache duration of the result.
47 typedef base::Callback<void(const std::vector<SBFullHashResult>&, 47 typedef base::Callback<void(const std::vector<SBFullHashResult>&,
48 const base::TimeDelta&)> 48 const base::TimeDelta&)>
49 FullHashCallback; 49 FullHashCallback;
50 50
51 typedef V4ProtocolManagerUtil::OperationResultType OperationResultType;
52
51 ~V4GetHashProtocolManager() override; 53 ~V4GetHashProtocolManager() override;
52 54
53 // Makes the passed |factory| the factory used to instantiate 55 // Makes the passed |factory| the factory used to instantiate
54 // a V4GetHashProtocolManager. Useful for tests. 56 // a V4GetHashProtocolManager. Useful for tests.
55 static void RegisterFactory(V4GetHashProtocolManagerFactory* factory) { 57 static void RegisterFactory(V4GetHashProtocolManagerFactory* factory) {
56 factory_ = factory; 58 factory_ = factory;
57 } 59 }
58 60
59 // Create an instance of the safe browsing v4 protocol manager. 61 // Create an instance of the safe browsing v4 protocol manager.
60 static V4GetHashProtocolManager* Create( 62 static V4GetHashProtocolManager* Create(
(...skipping 10 matching lines...) Expand all
71 const std::vector<PlatformType>& platforms, 73 const std::vector<PlatformType>& platforms,
72 ThreatType threat_type, 74 ThreatType threat_type,
73 FullHashCallback callback); 75 FullHashCallback callback);
74 76
75 // Retrieve the full hash and API metadata for a set of prefixes, and invoke 77 // Retrieve the full hash and API metadata for a set of prefixes, and invoke
76 // the callback argument when the results are retrieved. The callback may be 78 // the callback argument when the results are retrieved. The callback may be
77 // invoked synchronously. 79 // invoked synchronously.
78 virtual void GetFullHashesWithApis(const std::vector<SBPrefix>& prefixes, 80 virtual void GetFullHashesWithApis(const std::vector<SBPrefix>& prefixes,
79 FullHashCallback callback); 81 FullHashCallback callback);
80 82
81 // Enumerate failures for histogramming purposes. DO NOT CHANGE THE
82 // ORDERING OF THESE VALUES.
83 enum ResultType {
84 // 200 response code means that the server recognized the hash
85 // prefix.
86 GET_HASH_STATUS_200 = 0,
87
88 // Subset of successful responses where the response body wasn't parsable.
89 GET_HASH_PARSE_ERROR = 1,
90
91 // Gethash request failed (network error).
92 GET_HASH_NETWORK_ERROR = 2,
93
94 // Gethash request returned HTTP result code other than 200.
95 GET_HASH_HTTP_ERROR = 3,
96
97 // Gethash attempted during error backoff, no request sent.
98 GET_HASH_BACKOFF_ERROR = 4,
99
100 // Gethash attempted before min wait duration elapsed, no request sent.
101 GET_HASH_MIN_WAIT_DURATION_ERROR = 5,
102
103 // Memory space for histograms is determined by the max. ALWAYS
104 // ADD NEW VALUES BEFORE THIS ONE.
105 GET_HASH_RESULT_MAX = 6
106 };
107
108 // Record a GetHash result. 83 // Record a GetHash result.
109 static void RecordGetHashResult(ResultType result_type); 84 static void RecordGetHashResult(OperationResultType result_type);
110 85
111 protected: 86 protected:
112 // Constructs a V4GetHashProtocolManager that issues 87 // Constructs a V4GetHashProtocolManager that issues
113 // network requests using |request_context_getter|. 88 // network requests using |request_context_getter|.
114 V4GetHashProtocolManager( 89 V4GetHashProtocolManager(
115 net::URLRequestContextGetter* request_context_getter, 90 net::URLRequestContextGetter* request_context_getter,
116 const V4ProtocolConfig& config); 91 const V4ProtocolConfig& config);
117 92
118 private: 93 private:
119 FRIEND_TEST_ALL_PREFIXES(SafeBrowsingV4GetHashProtocolManagerTest, 94 FRIEND_TEST_ALL_PREFIXES(SafeBrowsingV4GetHashProtocolManagerTest,
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 net::URLRequestContextGetter* request_context_getter, 183 net::URLRequestContextGetter* request_context_getter,
209 const V4ProtocolConfig& config) = 0; 184 const V4ProtocolConfig& config) = 0;
210 185
211 private: 186 private:
212 DISALLOW_COPY_AND_ASSIGN(V4GetHashProtocolManagerFactory); 187 DISALLOW_COPY_AND_ASSIGN(V4GetHashProtocolManagerFactory);
213 }; 188 };
214 189
215 } // namespace safe_browsing 190 } // namespace safe_browsing
216 191
217 #endif // COMPONENTS_SAFE_BROWSING_DB_V4_GET_HASH_PROTOCOL_MANAGER_H_ 192 #endif // COMPONENTS_SAFE_BROWSING_DB_V4_GET_HASH_PROTOCOL_MANAGER_H_
OLDNEW
« no previous file with comments | « components/safe_browsing_db/database_manager.cc ('k') | components/safe_browsing_db/v4_get_hash_protocol_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698