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

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: Rebase 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
« no previous file with comments | « no previous file | chrome/browser/safe_browsing/protocol_manager.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..7faba475494e14179ecc6e8536bd711d18c837a4 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,15 @@ 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);
+
+ // Resets the V4 gethash error counter and multiplier.
+ void ResetGetHashV4Errors();
+
// 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 +329,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);
@@ -356,13 +371,16 @@ class SafeBrowsingProtocolManager : public net::URLFetcherDelegate,
// The kind of request that is currently in progress.
SafeBrowsingRequestType request_type_;
- // The number of HTTP response errors, used for request backoff timing.
+ // The number of HTTP response errors since the the last successful HTTP
+ // response, used for request backoff timing.
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 +412,10 @@ class SafeBrowsingProtocolManager : public net::URLFetcherDelegate,
// While in GetHash backoff, we can't make another GetHash until this time.
base::Time next_gethash_time_;
+ // For v4, the next gethash time is set to the backoff time is the last
+ // response was an error, or the minimum wait time if the last response was
+ // successful.
+ base::Time next_gethash_v4_time_;
// 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') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698