summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/app/generated_resources.grd9
-rw-r--r--chrome/browser/browser_main.cc6
-rw-r--r--chrome/common/chrome_switches.cc6
-rw-r--r--chrome/common/chrome_switches.h1
-rw-r--r--chrome/renderer/localized_error.cc7
-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
8 files changed, 44 insertions, 2 deletions
diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd
index b6c81ed..cbb8079 100644
--- a/chrome/app/generated_resources.grd
+++ b/chrome/app/generated_resources.grd
@@ -6291,6 +6291,15 @@ Keep your key file in a safe place. You will need it to create new versions of y
Bad SSL client authentication certificate.
</message>
+ <message name="IDS_ERRORPAGES_SUMMARY_TEMPORARILY_THROTTLED" desc="Summary in the error page when we temporarily stop sending requests to a server in order to avoid DDoS.">
+ It is likely that the server hosting the webpage has been overloaded or encountered an error. In order to avoid causing too much traffic and making the situation worse, <ph name="PRODUCT_NAME">&lt;span jscontent="productName"&gt;&lt;/span&gt;<ex>Google Chrome</ex></ph> has temporarily stopped allowing requests to the server.
+ <ph name="LINE_BREAK">&lt;br /&gt;&lt;br /&gt;</ph>
+ If you think this behavior is undesirable, for example, you are debugging your own website, you could disable it by restarting <ph name="PRODUCT_NAME">&lt;span jscontent="productName"&gt;&lt;/span&gt;<ex>Google Chrome</ex></ph> with the command line flag <ph name="COMMAND_LINE_FLAG">&lt;strong&gt;--disable-enforced-throttling&lt;/strong&gt;</ph>.
+ </message>
+ <message name="IDS_ERRORPAGES_DETAILS_TEMPORARILY_THROTTLED" desc="The error message displayed when we temporarily stop sending requests to a server in order to avoid DDoS.">
+ Requests to the server have been temporarily throttled.
+ </message>
+
<message name="IDS_ERRORPAGES_HTTP_POST_WARNING" desc="The error message displayed when the user navigates back or forward to a page which would resubmit post data. They can hit reload to send POST data again and load the page.">
This web page requires data that you entered earlier in order to be properly displayed. You can send this data again, but by doing so you will repeat any action this page previously performed. Press Reload to resend that data and display this page.
</message>
diff --git a/chrome/browser/browser_main.cc b/chrome/browser/browser_main.cc
index 7f535f6..030e1ee 100644
--- a/chrome/browser/browser_main.cc
+++ b/chrome/browser/browser_main.cc
@@ -100,6 +100,7 @@
#include "net/spdy/spdy_session.h"
#include "net/spdy/spdy_session_pool.h"
#include "net/url_request/url_request.h"
+#include "net/url_request/url_request_throttler_manager.h"
#if defined(USE_LINUX_BREAKPAD)
#include "base/linux_util.h"
@@ -586,6 +587,11 @@ void InitializeNetworkOptions(const CommandLine& parsed_command_line) {
net::SpdySessionPool::set_max_sessions_per_domain(value);
}
+ if (parsed_command_line.HasSwitch(switches::kDisableEnforcedThrottling)) {
+ net::URLRequestThrottlerManager::GetInstance()->
+ set_enforce_throttling(false);
+ }
+
SetDnsCertProvenanceCheckerFactory(CreateChromeDnsCertProvenanceChecker);
}
diff --git a/chrome/common/chrome_switches.cc b/chrome/common/chrome_switches.cc
index 7f0a2ac..df8e12c 100644
--- a/chrome/common/chrome_switches.cc
+++ b/chrome/common/chrome_switches.cc
@@ -204,6 +204,12 @@ const char kDisableDevTools[] = "disable-dev-tools";
// Disables device orientation events.
const char kDisableDeviceOrientation[] = "disable-device-orientation";
+// By default, if the URL request throttler finds that a server is overloaded or
+// encounters an error, it rejects requests to the server for a period of time,
+// which is determined by an exponential back-off algorithm. This switch
+// disables such behavior.
+const char kDisableEnforcedThrottling[] = "disable-enforced-throttling";
+
// Disable experimental WebGL support.
const char kDisableExperimentalWebGL[] = "disable-webgl";
diff --git a/chrome/common/chrome_switches.h b/chrome/common/chrome_switches.h
index 001e963..1270ac4 100644
--- a/chrome/common/chrome_switches.h
+++ b/chrome/common/chrome_switches.h
@@ -67,6 +67,7 @@ extern const char kDisableDatabases[];
extern const char kDisableDesktopNotifications[];
extern const char kDisableDevTools[];
extern const char kDisableDeviceOrientation[];
+extern const char kDisableEnforcedThrottling[];
extern const char kDisableExperimentalWebGL[];
extern const char kDisableExtensionsFileAccessCheck[];
extern const char kDisableExtensions[];
diff --git a/chrome/renderer/localized_error.cc b/chrome/renderer/localized_error.cc
index 0f8a45e..618b995 100644
--- a/chrome/renderer/localized_error.cc
+++ b/chrome/renderer/localized_error.cc
@@ -170,6 +170,13 @@ const LocalizedErrorMap net_error_options[] = {
IDS_ERRORPAGES_DETAILS_SSL_PROTOCOL_ERROR,
SUGGEST_LEARNMORE,
},
+ {net::ERR_TEMPORARILY_THROTTLED,
+ IDS_ERRORPAGES_TITLE_ACCESS_DENIED,
+ IDS_ERRORPAGES_HEADING_ACCESS_DENIED,
+ IDS_ERRORPAGES_SUMMARY_TEMPORARILY_THROTTLED,
+ IDS_ERRORPAGES_DETAILS_TEMPORARILY_THROTTLED,
+ SUGGEST_NONE,
+ },
};
const LocalizedErrorMap http_error_options[] = {
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);
};