summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authoryzshen@google.com <yzshen@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-12-23 02:09:39 +0000
committeryzshen@google.com <yzshen@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-12-23 02:09:39 +0000
commit05fd9e3071321bc2dec75296dff0cc4dbdef7128 (patch)
tree017c2b6114fa75c48faf9ce9cc7847386faa0d33 /net
parent9edc6b2c8f0e0992c2f17eb5434d7c3044baff19 (diff)
downloadchromium_src-05fd9e3071321bc2dec75296dff0cc4dbdef7128.zip
chromium_src-05fd9e3071321bc2dec75296dff0cc4dbdef7128.tar.gz
chromium_src-05fd9e3071321bc2dec75296dff0cc4dbdef7128.tar.bz2
Give user the ability to disable the URL request throttler:
- Support the command line switch --disable-enforced-throttling. With this switch specified, the URL request throttler won't reject outgoing requests during the back-off peroid. Please note that in this case we still keep track of the back-off period, since we need it to determine retry intervals. - Add a more detailed error page description for net::ERR_TEMPORARILY_THROTTLED. BUG=66062 TEST=Without --disable-enforced-throttling switch: (1) Type in the addresss bar a URL which is expected to return 5XX. (2) Keep clicking the "reload" button. (3) After a few clicks, Chrome displays an error page explaining why a net::ERR_TEMPORARILY_THROTTLED error occurs. With --disable-enforced-throttling switch: Following step (1) and (2) described above won't result in a net::ERR_TEMPORARILY_THROTTLED error page. Review URL: http://codereview.chromium.org/5961008 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@70022 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r--net/url_request/url_request_http_job.cc4
-rw-r--r--net/url_request/url_request_throttler_manager.cc3
-rw-r--r--net/url_request/url_request_throttler_manager.h10
3 files changed, 15 insertions, 2 deletions
diff --git a/net/url_request/url_request_http_job.cc b/net/url_request/url_request_http_job.cc
index 6b8190f..ec0134a 100644
--- a/net/url_request/url_request_http_job.cc
+++ b/net/url_request/url_request_http_job.cc
@@ -696,7 +696,9 @@ void URLRequestHttpJob::StartTransaction() {
rv = request_->context()->http_transaction_factory()->CreateTransaction(
&transaction_);
if (rv == OK) {
- if (!throttling_entry_->IsDuringExponentialBackoff()) {
+ if (!throttling_entry_->IsDuringExponentialBackoff() ||
+ !net::URLRequestThrottlerManager::GetInstance()->
+ enforce_throttling()) {
rv = transaction_->Start(
&request_info_, &start_callback_, request_->net_log());
} else {
diff --git a/net/url_request/url_request_throttler_manager.cc b/net/url_request/url_request_throttler_manager.cc
index 5428d9a..04e05c9 100644
--- a/net/url_request/url_request_throttler_manager.cc
+++ b/net/url_request/url_request_throttler_manager.cc
@@ -32,7 +32,8 @@ scoped_refptr<URLRequestThrottlerEntryInterface>
}
URLRequestThrottlerManager::URLRequestThrottlerManager()
- : requests_since_last_gc_(0) {
+ : requests_since_last_gc_(0),
+ enforce_throttling_(true) {
}
URLRequestThrottlerManager::~URLRequestThrottlerManager() {
diff --git a/net/url_request/url_request_throttler_manager.h b/net/url_request/url_request_throttler_manager.h
index 6c8cd2f..98211d9 100644
--- a/net/url_request/url_request_throttler_manager.h
+++ b/net/url_request/url_request_throttler_manager.h
@@ -49,6 +49,12 @@ class URLRequestThrottlerManager {
// It is only used by unit tests.
void EraseEntryForTests(const GURL& url);
+ void set_enforce_throttling(bool enforce_throttling) {
+ enforce_throttling_ = enforce_throttling;
+ }
+
+ bool enforce_throttling() const { return enforce_throttling_; }
+
protected:
URLRequestThrottlerManager();
~URLRequestThrottlerManager();
@@ -93,6 +99,10 @@ class URLRequestThrottlerManager {
mutable scoped_ptr<GURL::Replacements> url_id_replacements_;
+ // Whether we would like to reject outgoing HTTP requests during the back-off
+ // period.
+ bool enforce_throttling_;
+
DISALLOW_COPY_AND_ASSIGN(URLRequestThrottlerManager);
};