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

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

Issue 2458743003: Failure to parse full hash metadata shouldn't discard the response (Closed)
Patch Set: Nit: Remove extra return Created 4 years, 1 month 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 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 264
265 // Parses a FindFullHashesResponse protocol buffer and fills the results in 265 // Parses a FindFullHashesResponse protocol buffer and fills the results in
266 // |full_hash_infos| and |negative_cache_expire|. |response_data| is a 266 // |full_hash_infos| and |negative_cache_expire|. |response_data| is a
267 // serialized FindFullHashes protocol buffer. |negative_cache_expire| is the 267 // serialized FindFullHashes protocol buffer. |negative_cache_expire| is the
268 // cache expiry time of the hash prefixes that were requested. Returns true if 268 // cache expiry time of the hash prefixes that were requested. Returns true if
269 // parsing is successful; false otherwise. 269 // parsing is successful; false otherwise.
270 bool ParseHashResponse(const std::string& response_data, 270 bool ParseHashResponse(const std::string& response_data,
271 std::vector<FullHashInfo>* full_hash_infos, 271 std::vector<FullHashInfo>* full_hash_infos,
272 base::Time* negative_cache_expire); 272 base::Time* negative_cache_expire);
273 273
274 // Parses the store specific |metadata| information from |match|. Returns 274 // Parses the store specific |metadata| information from |match|. Records
275 // true if the metadata information was parsed correctly and was consistent 275 // errors if the metadata information was not parsed correctly or was
Nathan Parker 2016/10/27 22:06:49 nit: "Logs errors to UMA if the metadata..."
vakh (use Gerrit instead) 2016/10/27 22:40:05 Done.
276 // with what's expected from that corresponding store; false otherwise. 276 // inconsistent with what's expected from that corresponding store.
277 bool ParseMetadata(const ThreatMatch& match, ThreatMetadata* metadata); 277 static void ParseMetadata(const ThreatMatch& match, ThreatMetadata* metadata);
278 278
279 // Resets the gethash error counter and multiplier. 279 // Resets the gethash error counter and multiplier.
280 void ResetGetHashErrors(); 280 void ResetGetHashErrors();
281 281
282 // Overrides the clock used to check the time. 282 // Overrides the clock used to check the time.
283 void SetClockForTests(std::unique_ptr<base::Clock> clock); 283 void SetClockForTests(std::unique_ptr<base::Clock> clock);
284 284
285 // Updates the state of the full hash cache upon receiving a valid response 285 // Updates the state of the full hash cache upon receiving a valid response
286 // from the server. 286 // from the server.
287 void UpdateCache(const std::vector<HashPrefix>& prefixes_requested, 287 void UpdateCache(const std::vector<HashPrefix>& prefixes_requested,
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 DISALLOW_COPY_AND_ASSIGN(V4GetHashProtocolManagerFactory); 356 DISALLOW_COPY_AND_ASSIGN(V4GetHashProtocolManagerFactory);
357 }; 357 };
358 358
359 #ifndef NDEBUG 359 #ifndef NDEBUG
360 std::ostream& operator<<(std::ostream& os, const FullHashInfo& id); 360 std::ostream& operator<<(std::ostream& os, const FullHashInfo& id);
361 #endif 361 #endif
362 362
363 } // namespace safe_browsing 363 } // namespace safe_browsing
364 364
365 #endif // COMPONENTS_SAFE_BROWSING_DB_V4_GET_HASH_PROTOCOL_MANAGER_H_ 365 #endif // COMPONENTS_SAFE_BROWSING_DB_V4_GET_HASH_PROTOCOL_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698