summaryrefslogtreecommitdiffstats
path: root/chrome/service
diff options
context:
space:
mode:
authorjoi@chromium.org <joi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-27 18:51:53 +0000
committerjoi@chromium.org <joi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-27 18:51:53 +0000
commit82c71ba49a999ffa2b9c57aefc664dfd9bbe8186 (patch)
treea119d96375aa37d2609cfc911ed5a9c84c594f4b /chrome/service
parent4d768302d3e793d3b717bedea907b6038e391bff (diff)
downloadchromium_src-82c71ba49a999ffa2b9c57aefc664dfd9bbe8186.zip
chromium_src-82c71ba49a999ffa2b9c57aefc664dfd9bbe8186.tar.gz
chromium_src-82c71ba49a999ffa2b9c57aefc664dfd9bbe8186.tar.bz2
Anti-DDoS enhancements: Log to net log, UMA stats, improved policy.
Count only certain error codes as failures. Don't count malformed body for codes already counted failures. Start with fresh entry when outdated, which makes policy slightly less aggressive. Add registration/unregistration to NetworkChangeNotifier, and reset throttling state on network changes, to avoid degenerate corner cases. Add UMA stats for throttling, and unit tests for them. Add hash-location-only URL to unit test. Enable testing of AJAX behavior via backoff_server. BUG=83775 TEST=net_unittests Review URL: http://codereview.chromium.org/6966038 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@87056 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/service')
-rw-r--r--chrome/service/cloud_print/cloud_print_url_fetcher.cc11
-rw-r--r--chrome/service/cloud_print/cloud_print_url_fetcher_unittest.cc4
2 files changed, 7 insertions, 8 deletions
diff --git a/chrome/service/cloud_print/cloud_print_url_fetcher.cc b/chrome/service/cloud_print/cloud_print_url_fetcher.cc
index 731acd3..13af5f7 100644
--- a/chrome/service/cloud_print/cloud_print_url_fetcher.cc
+++ b/chrome/service/cloud_print/cloud_print_url_fetcher.cc
@@ -102,12 +102,11 @@ void CloudPrintURLFetcher::OnURLFetchComplete(
}
// Retry the request if needed.
if (action == RETRY_REQUEST) {
- // If the response code is greater than or equal to 500, then the back-off
- // period has been increased at the network level; otherwise, explicitly
- // call ReceivedContentWasMalformed() to count the current request as a
- // failure and increase the back-off period.
- if (response_code < 500)
- request_->ReceivedContentWasMalformed();
+ // Explicitly call ReceivedContentWasMalformed() to ensure the current
+ // request gets counted as a failure for calculation of the back-off
+ // period. If it was already a failure by status code, this call will
+ // be ignored.
+ request_->ReceivedContentWasMalformed();
++num_retries_;
if ((-1 != source->max_retries()) &&
diff --git a/chrome/service/cloud_print/cloud_print_url_fetcher_unittest.cc b/chrome/service/cloud_print/cloud_print_url_fetcher_unittest.cc
index 6a2637d..9fd4318 100644
--- a/chrome/service/cloud_print/cloud_print_url_fetcher_unittest.cc
+++ b/chrome/service/cloud_print/cloud_print_url_fetcher_unittest.cc
@@ -324,7 +324,7 @@ TEST_F(CloudPrintURLFetcherOverloadTest, Protect) {
net::URLRequestThrottlerManager* manager =
net::URLRequestThrottlerManager::GetInstance();
scoped_refptr<net::URLRequestThrottlerEntry> entry(
- new net::URLRequestThrottlerEntry(manager, 200, 3, 1, 2.0, 0.0, 256));
+ new net::URLRequestThrottlerEntry(manager, "", 200, 3, 1, 2.0, 0.0, 256));
manager->OverrideEntryForTests(url, entry);
CreateFetcher(url, 11);
@@ -348,7 +348,7 @@ TEST_F(CloudPrintURLFetcherRetryBackoffTest, FLAKY_GiveUp) {
net::URLRequestThrottlerManager* manager =
net::URLRequestThrottlerManager::GetInstance();
scoped_refptr<net::URLRequestThrottlerEntry> entry(
- new net::URLRequestThrottlerEntry(manager, 200, 3, 1, 2.0, 0.0, 256));
+ new net::URLRequestThrottlerEntry(manager, "", 200, 3, 1, 2.0, 0.0, 256));
manager->OverrideEntryForTests(url, entry);
CreateFetcher(url, 11);