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

Unified Diff: net/url_request/url_request_throttler_manager.cc

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: Update copyright years. 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.cc
diff --git a/net/url_request/url_request_throttler_manager.cc b/net/url_request/url_request_throttler_manager.cc
index 1c2f944931f3f414e23d084d78ff87b1bacfef56..3b63d2c5bfd83d8d2bbe4a02b6fa3bf591db4804 100644
--- a/net/url_request/url_request_throttler_manager.cc
+++ b/net/url_request/url_request_throttler_manager.cc
@@ -6,6 +6,7 @@
#include "base/logging.h"
#include "base/string_util.h"
+#include "net/base/net_util.h"
namespace net {
@@ -29,11 +30,29 @@ scoped_refptr<URLRequestThrottlerEntryInterface>
// Find the entry in the map or create it.
scoped_refptr<URLRequestThrottlerEntry>& entry = url_entries_[url_id];
if (entry.get() == NULL)
- entry = new URLRequestThrottlerEntry();
+ entry = new URLRequestThrottlerEntry(this);
+
+ std::string host = url.host();
+ if (opt_out_hosts_.find(host) != opt_out_hosts_.end() || IsLocalhost(host)) {
yzshen1 2011/03/18 22:49:51 [Don't have a strong opinion. Just to make sure yo
Jói 2011/03/23 23:38:24 I'm doing this on request of the web developers in
+ // TODO(joi): Once sliding window is separate from back-off throttling,
+ // we can simply return a dummy implementation of
+ // URLRequestThrottlerEntryInterface here that never blocks anything (and
+ // not keep entries in url_entries_ for opted-out sites).
yzshen1 2011/03/18 22:49:51 We might still need to keep track of back-off peri
Jói 2011/03/23 23:38:24 Right, I think as per the comment I added on URLRe
+ entry->DisableBackoffThrottling();
+ }
return entry;
}
+void URLRequestThrottlerManager::AddToOptOutList(const std::string& host) {
+ // There is an edge case here that we are not handling, to keep things
+ // simple. If a host starts adding the opt-out header to its responses
+ // after there are already one or more entries in url_entries_ for that
+ // host, the pre-existing entries may still perform back-off throttling.
+ // In practice, this would almost never occur.
+ opt_out_hosts_.insert(host);
+}
+
void URLRequestThrottlerManager::OverrideEntryForTests(
const GURL& url,
URLRequestThrottlerEntry* entry) {

Powered by Google App Engine
This is Rietveld 408576698