diff options
author | joi@chromium.org <joi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-25 22:30:21 +0000 |
---|---|---|
committer | joi@chromium.org <joi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-25 22:30:21 +0000 |
commit | 2fd33ee9acea0037b010901af1601616c21cc37d (patch) | |
tree | 9109f46ae1e4efe4ec8d345853064113e6379915 /chrome/common/net | |
parent | 49a9415f1fd04e05c2d75e884a0aced8e0d76063 (diff) | |
download | chromium_src-2fd33ee9acea0037b010901af1601616c21cc37d.zip chromium_src-2fd33ee9acea0037b010901af1601616c21cc37d.tar.gz chromium_src-2fd33ee9acea0037b010901af1601616c21cc37d.tar.bz2 |
Add an opt-out header for HTTP throttling. Never throttle for localhost.
Added net::IsLocalhost() function to net/base/net_utils.h
Unit tests for the above. Also fix flakiness in the ReceivedContentMalformed test that was caused by non-zero jitter.
Modify back-off policy to ignore first 4 errors to help avoid back-off from erroneously kicking in on flaky connections. Make maximum back-off period 15 minutes instead of 60. Added documentation of results of analyzing behavior this new policy will give.
Add a simple server for manual testing of the throttling feature.
BUG=66062
TEST=net_unittests
Review URL: http://codereview.chromium.org/6711046
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@79464 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common/net')
-rw-r--r-- | chrome/common/net/url_fetcher_unittest.cc | 38 |
1 files changed, 23 insertions, 15 deletions
diff --git a/chrome/common/net/url_fetcher_unittest.cc b/chrome/common/net/url_fetcher_unittest.cc index c52ad33..e4da035 100644 --- a/chrome/common/net/url_fetcher_unittest.cc +++ b/chrome/common/net/url_fetcher_unittest.cc @@ -576,10 +576,11 @@ TEST_F(URLFetcherProtectTest, Overload) { // Registers an entry for test url. It only allows 3 requests to be sent // in 200 milliseconds. + net::URLRequestThrottlerManager* manager = + net::URLRequestThrottlerManager::GetInstance(); scoped_refptr<net::URLRequestThrottlerEntry> entry( - new net::URLRequestThrottlerEntry(200, 3, 1, 2.0, 0.0, 256)); - net::URLRequestThrottlerManager::GetInstance()->OverrideEntryForTests( - url, entry); + new net::URLRequestThrottlerEntry(manager, 200, 3, 1, 2.0, 0.0, 256)); + manager->OverrideEntryForTests(url, entry); CreateFetcher(url); @@ -598,10 +599,11 @@ TEST_F(URLFetcherProtectTest, ServerUnavailable) { // new_backoff = 2.0 * old_backoff + 0 // and maximum backoff time is 256 milliseconds. // Maximum retries allowed is set to 11. + net::URLRequestThrottlerManager* manager = + net::URLRequestThrottlerManager::GetInstance(); scoped_refptr<net::URLRequestThrottlerEntry> entry( - new net::URLRequestThrottlerEntry(200, 3, 1, 2.0, 0.0, 256)); - net::URLRequestThrottlerManager::GetInstance()->OverrideEntryForTests( - url, entry); + new net::URLRequestThrottlerEntry(manager, 200, 3, 1, 2.0, 0.0, 256)); + manager->OverrideEntryForTests(url, entry); CreateFetcher(url); @@ -620,12 +622,14 @@ TEST_F(URLFetcherProtectTestPassedThrough, ServerUnavailablePropagateResponse) { // new_backoff = 2.0 * old_backoff + 0 // and maximum backoff time is 150000 milliseconds. // Maximum retries allowed is set to 11. + net::URLRequestThrottlerManager* manager = + net::URLRequestThrottlerManager::GetInstance(); scoped_refptr<net::URLRequestThrottlerEntry> entry( - new net::URLRequestThrottlerEntry(200, 3, 100, 2.0, 0.0, 150000)); + new net::URLRequestThrottlerEntry( + manager, 200, 3, 100, 2.0, 0.0, 150000)); // Total time if *not* for not doing automatic backoff would be 150s. // In reality it should be "as soon as server responds". - net::URLRequestThrottlerManager::GetInstance()->OverrideEntryForTests( - url, entry); + manager->OverrideEntryForTests(url, entry); CreateFetcher(url); @@ -664,10 +668,12 @@ TEST_F(URLFetcherCancelTest, ReleasesContext) { // new_backoff = 2.0 * old_backoff + 0 // The initial backoff is 2 seconds and maximum backoff is 4 seconds. // Maximum retries allowed is set to 2. + net::URLRequestThrottlerManager* manager = + net::URLRequestThrottlerManager::GetInstance(); scoped_refptr<net::URLRequestThrottlerEntry> entry( - new net::URLRequestThrottlerEntry(200, 3, 2000, 2.0, 0.0, 4000)); - net::URLRequestThrottlerManager::GetInstance()->OverrideEntryForTests( - url, entry); + new net::URLRequestThrottlerEntry( + manager, 200, 3, 2000, 2.0, 0.0, 4000)); + manager->OverrideEntryForTests(url, entry); // Create a separate thread that will create the URLFetcher. The current // (main) thread will do the IO, and when the fetch is complete it will @@ -692,10 +698,12 @@ TEST_F(URLFetcherCancelTest, CancelWhileDelayedStartTaskPending) { // Register an entry for test url. // Using a sliding window of 4 seconds, and max of 1 request, under a fast // run we expect to have a 4 second delay when posting the Start task. + net::URLRequestThrottlerManager* manager = + net::URLRequestThrottlerManager::GetInstance(); scoped_refptr<net::URLRequestThrottlerEntry> entry( - new net::URLRequestThrottlerEntry(4000, 1, 2000, 2.0, 0.0, 4000)); - net::URLRequestThrottlerManager::GetInstance()->OverrideEntryForTests( - url, entry); + new net::URLRequestThrottlerEntry( + manager, 4000, 1, 2000, 2.0, 0.0, 4000)); + manager->OverrideEntryForTests(url, entry); // Fake that a request has just started. entry->ReserveSendingTimeForNextRequest(base::TimeTicks()); |