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

Unified Diff: chrome/browser/safe_browsing/protocol_manager.h

Issue 1555953002: Adds backoff and Min Wait Duration compliance to Protocolmanager pver4 handlers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@osb-pm-2
Patch Set: Review COmments Created 4 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/safe_browsing/protocol_manager.h
diff --git a/chrome/browser/safe_browsing/protocol_manager.h b/chrome/browser/safe_browsing/protocol_manager.h
index fe354284b81f6e4f91571023dcbbb046a537457c..579f26b241703e6c062ab4aea71b1523fc99fd2e 100644
--- a/chrome/browser/safe_browsing/protocol_manager.h
+++ b/chrome/browser/safe_browsing/protocol_manager.h
@@ -216,6 +216,8 @@ class SafeBrowsingProtocolManager : public net::URLFetcherDelegate,
TestParseV4HashResponseNonPermissionMetadata);
FRIEND_TEST_ALL_PREFIXES(SafeBrowsingProtocolManagerTest,
TestGetHashBackOffTimes);
+ FRIEND_TEST_ALL_PREFIXES(SafeBrowsingProtocolManagerTest,
+ TestGetV4HashBackOffTimes);
FRIEND_TEST_ALL_PREFIXES(SafeBrowsingProtocolManagerTest, TestNextChunkUrl);
FRIEND_TEST_ALL_PREFIXES(SafeBrowsingProtocolManagerTest, TestUpdateUrl);
friend class SafeBrowsingServerTest;
@@ -284,6 +286,12 @@ class SafeBrowsingProtocolManager : public net::URLFetcherDelegate,
base::TimeDelta GetNextBackOffInterval(size_t* error_count,
size_t* multiplier) const;
+ // Worker function for calculating the V4 GetHash backoff times.
+ // |multiplier| is doubled for each consecutive error after the
+ // first, and |error_count| is incremented with each call.
+ static base::TimeDelta GetNextV4BackOffInterval(size_t* error_count,
+ size_t* multiplier);
+
// Manages our update with the next allowable update time. If 'back_off_' is
// true, we must decrease the frequency of requests of the SafeBrowsing
// service according to section 5 of the protocol specification.
@@ -318,6 +326,10 @@ class SafeBrowsingProtocolManager : public net::URLFetcherDelegate,
// current time is |now|.
void HandleGetHashError(const base::Time& now);
+ // Updates internal state for each GetHash V4 response error, assuming that
+ // the current time is |now|.
+ void HandleGetHashV4Error(const base::Time& now);
+
// Helper function for update completion.
void UpdateFinished(bool success);
void UpdateFinished(bool success, bool back_off);
@@ -359,10 +371,12 @@ class SafeBrowsingProtocolManager : public net::URLFetcherDelegate,
// The number of HTTP response errors, used for request backoff timing.
Nathan Parker 2016/01/12 04:14:38 number of HTTP response error since the last succe
kcarattini 2016/01/12 05:18:06 Done.
size_t update_error_count_;
size_t gethash_error_count_;
+ size_t gethash_v4_error_count_;
// Multipliers which double (max == 8) for each error after the second.
size_t update_back_off_mult_;
size_t gethash_back_off_mult_;
+ size_t gethash_v4_back_off_mult_;
// Multiplier between 0 and 1 to spread clients over an interval.
float back_off_fuzz_;
@@ -394,6 +408,7 @@ class SafeBrowsingProtocolManager : public net::URLFetcherDelegate,
// While in GetHash backoff, we can't make another GetHash until this time.
base::Time next_gethash_time_;
+ base::Time next_gethash_v4_time_;
Nathan Parker 2016/01/12 04:14:38 Is this the max of the prescribed min-wait-time an
kcarattini 2016/01/12 05:18:06 No, it should be one or the other. Added a comment
// Current product version sent in each request.
std::string version_;
« no previous file with comments | « no previous file | chrome/browser/safe_browsing/protocol_manager.cc » ('j') | chrome/browser/safe_browsing/protocol_manager.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698