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

Unified Diff: net/url_request/url_request_throttler_manager.h

Issue 6711046: Add an opt-out header for HTTP throttling. Never throttle for localhost. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge to head. Created 9 years, 9 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: net/url_request/url_request_throttler_manager.h
diff --git a/net/url_request/url_request_throttler_manager.h b/net/url_request/url_request_throttler_manager.h
index d65b20f79c94f94e8faaacb73ba480172f4906d7..bef882443fd0c3b85e2932aad0a64a8c03d68dfa 100644
--- a/net/url_request/url_request_throttler_manager.h
+++ b/net/url_request/url_request_throttler_manager.h
@@ -7,6 +7,7 @@
#pragma once
#include <map>
+#include <set>
#include <string>
#include "base/basictypes.h"
@@ -42,6 +43,11 @@ class URLRequestThrottlerManager : public base::NonThreadSafe {
scoped_refptr<URLRequestThrottlerEntryInterface> RegisterRequestUrl(
const GURL& url);
+ // Adds the given host to a list of sites for which exponential back-off
+ // throttling will be disabled. Subdomains are not included, so they
+ // must be added separately.
+ void AddToOptOutList(const std::string& host);
+
// Registers a new entry in this service and overrides the existing entry (if
// any) for the URL. The service will hold a reference to the entry.
// It is only used by unit tests.
@@ -93,6 +99,10 @@ class URLRequestThrottlerManager : public base::NonThreadSafe {
typedef std::map<std::string, scoped_refptr<URLRequestThrottlerEntry> >
UrlEntryMap;
+ // We maintain a set of hosts that have opted out of exponential
+ // back-off throttling.
+ typedef std::set<std::string> OptOutHosts;
+
// Maximum number of entries that we are willing to collect in our map.
static const unsigned int kMaximumNumberOfEntries;
// Number of requests that will be made between garbage collection.
@@ -102,6 +112,9 @@ class URLRequestThrottlerManager : public base::NonThreadSafe {
// URLRequestThrottlerEntry.
UrlEntryMap url_entries_;
+ // Set of hosts that have opted out.
+ OptOutHosts opt_out_hosts_;
+
// This keeps track of how many requests have been made. Used with
// GarbageCollectEntries.
unsigned int requests_since_last_gc_;

Powered by Google App Engine
This is Rietveld 408576698