diff options
author | joi@chromium.org <joi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-23 23:09:50 +0000 |
---|---|---|
committer | joi@chromium.org <joi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-23 23:09:50 +0000 |
commit | e2e2875340bbece2d2ef4dd14bde39dee08c88ac (patch) | |
tree | ad8d563752454700e9b992067691f6598bbcde3b | |
parent | dc37b00ad97e68b6c149b38b49415664825701b4 (diff) | |
download | chromium_src-e2e2875340bbece2d2ef4dd14bde39dee08c88ac.zip chromium_src-e2e2875340bbece2d2ef4dd14bde39dee08c88ac.tar.gz chromium_src-e2e2875340bbece2d2ef4dd14bde39dee08c88ac.tar.bz2 |
Remove X-Retry-After support.
This is part of simplifying URLRequestThrottler* now that it is
specific to extensions. It also appears that nobody is using this
header.
BUG=119760
Review URL: http://codereview.chromium.org/10190002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@133558 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | net/base/net_log_event_type_list.h | 7 | ||||
-rwxr-xr-x | net/tools/testserver/backoff_server.py | 9 | ||||
-rw-r--r-- | net/url_request/url_request_throttler_entry.cc | 56 | ||||
-rw-r--r-- | net/url_request/url_request_throttler_entry.h | 9 | ||||
-rw-r--r-- | net/url_request/url_request_throttler_test_support.cc | 7 | ||||
-rw-r--r-- | net/url_request/url_request_throttler_unittest.cc | 21 |
6 files changed, 3 insertions, 106 deletions
diff --git a/net/base/net_log_event_type_list.h b/net/base/net_log_event_type_list.h index aa8dfc7..757fb4c 100644 --- a/net/base/net_log_event_type_list.h +++ b/net/base/net_log_event_type_list.h @@ -1286,13 +1286,6 @@ EVENT_TYPE(THROTTLING_DISABLED_FOR_HOST) // } EVENT_TYPE(THROTTLING_REJECTED_REQUEST) -// Emitted when throttling entry receives an X-Retry-After header. -// { -// "url": <URL that was being requested>, -// "retry_after_ms": <Milliseconds until retry-after expires> -// } -EVENT_TYPE(THROTTLING_GOT_CUSTOM_RETRY_AFTER) - // ------------------------------------------------------------------------ // DnsTransaction // ------------------------------------------------------------------------ diff --git a/net/tools/testserver/backoff_server.py b/net/tools/testserver/backoff_server.py index 3c6db1f..ca2c57cb 100755 --- a/net/tools/testserver/backoff_server.py +++ b/net/tools/testserver/backoff_server.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -# Copyright (c) 2011 The Chromium Authors. All rights reserved. +# Copyright (c) 2012 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. @@ -78,21 +78,14 @@ class RequestHandler(BaseHTTPServer.BaseHTTPRequestHandler): params = urlparse.parse_qs(urlparse.urlparse(self.path).query) - def SendCustomRetryIfRequested(): - if params and 'custom-retry-after' in params: - custom_retry = params['custom-retry-after'][0] - self.send_header('X-Retry-After', custom_retry) - if not params or not 'code' in params or params['code'][0] == '200': self.send_response(200) self.send_header('Content-Type', 'text/plain') - SendCustomRetryIfRequested() self.end_headers() self.wfile.write('OK') else: status_code = int(params['code'][0]) self.send_response(status_code) - SendCustomRetryIfRequested() self.end_headers() self.wfile.write('Error %d' % int(status_code)) diff --git a/net/url_request/url_request_throttler_entry.cc b/net/url_request/url_request_throttler_entry.cc index 3ef2db0..3154f9c 100644 --- a/net/url_request/url_request_throttler_entry.cc +++ b/net/url_request/url_request_throttler_entry.cc @@ -44,7 +44,6 @@ const double URLRequestThrottlerEntry::kDefaultMultiplyFactor = 1.4; const double URLRequestThrottlerEntry::kDefaultJitterFactor = 0.4; const int URLRequestThrottlerEntry::kDefaultMaximumBackoffMs = 15 * 60 * 1000; const int URLRequestThrottlerEntry::kDefaultEntryLifetimeMs = 2 * 60 * 1000; -const char URLRequestThrottlerEntry::kRetryHeaderName[] = "X-Retry-After"; const char URLRequestThrottlerEntry::kExponentialThrottlingHeader[] = "X-Chrome-Exponential-Throttling"; const char URLRequestThrottlerEntry::kExponentialThrottlingDisableValue[] = @@ -75,27 +74,6 @@ class RejectedRequestParameters : public NetLog::EventParameters { int release_after_ms_; }; -// NetLog parameters when a response contains an X-Retry-After header. -class RetryAfterParameters : public NetLog::EventParameters { - public: - RetryAfterParameters(const std::string& url_id, - int retry_after_ms) - : url_id_(url_id), - retry_after_ms_(retry_after_ms) { - } - - virtual Value* ToValue() const { - DictionaryValue* dict = new DictionaryValue(); - dict->SetString("url", url_id_); - dict->SetInteger("retry_after_ms", retry_after_ms_); - return dict; - } - - private: - std::string url_id_; - int retry_after_ms_; -}; - URLRequestThrottlerEntry::URLRequestThrottlerEntry( URLRequestThrottlerManager* manager, const std::string& url_id) @@ -264,10 +242,6 @@ void URLRequestThrottlerEntry::UpdateWithResponse( } else { GetBackoffEntry()->InformOfRequest(true); - std::string retry_header = response->GetNormalizedValue(kRetryHeaderName); - if (!retry_header.empty()) - HandleCustomRetryAfter(retry_header); - std::string throttling_header = response->GetNormalizedValue( kExponentialThrottlingHeader); if (!throttling_header.empty()) @@ -337,36 +311,6 @@ base::TimeTicks URLRequestThrottlerEntry::ImplGetTimeNow() const { return base::TimeTicks::Now(); } -void URLRequestThrottlerEntry::HandleCustomRetryAfter( - const std::string& header_value) { - // Input parameter is the number of seconds to wait in a floating point value. - double time_in_sec = 0; - bool conversion_is_ok = base::StringToDouble(header_value, &time_in_sec); - - // Conversion of custom retry-after header value failed. - if (!conversion_is_ok) - return; - - // We must use an int value later so we transform this in milliseconds. - int64 value_ms = static_cast<int64>(0.5 + time_in_sec * 1000); - - // We do not check for an upper bound; the server can set any Retry-After it - // desires. Recovery from error would involve restarting the browser. - if (value_ms < 0) - return; - - net_log_.AddEvent( - NetLog::TYPE_THROTTLING_GOT_CUSTOM_RETRY_AFTER, - make_scoped_refptr(new RetryAfterParameters(url_id_, value_ms))); - - base::TimeDelta value = base::TimeDelta::FromMilliseconds(value_ms); - GetBackoffEntry()->SetCustomReleaseTime(ImplGetTimeNow() + value); - - UMA_HISTOGRAM_CUSTOM_TIMES( - "Throttling.CustomRetryAfterMs", value, - base::TimeDelta::FromSeconds(1), base::TimeDelta::FromHours(12), 50); -} - void URLRequestThrottlerEntry::HandleThrottlingHeader( const std::string& header_value, const std::string& host) { diff --git a/net/url_request/url_request_throttler_entry.h b/net/url_request/url_request_throttler_entry.h index 8a2589b..5c73c85 100644 --- a/net/url_request/url_request_throttler_entry.h +++ b/net/url_request/url_request_throttler_entry.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -58,10 +58,6 @@ class NET_EXPORT URLRequestThrottlerEntry // Time after which the entry is considered outdated. static const int kDefaultEntryLifetimeMs; - // Name of the header that servers can use to ask clients to delay their - // next request. - static const char kRetryHeaderName[]; - // Name of the header that sites can use to opt out of exponential back-off // throttling. static const char kExponentialThrottlingHeader[]; @@ -118,9 +114,6 @@ class NET_EXPORT URLRequestThrottlerEntry // Equivalent to TimeTicks::Now(), virtual to be mockable for testing purpose. virtual base::TimeTicks ImplGetTimeNow() const; - // Used internally to increase release time following a retry-after header. - void HandleCustomRetryAfter(const std::string& header_value); - // Used internally to handle the opt-out header. void HandleThrottlingHeader(const std::string& header_value, const std::string& host); diff --git a/net/url_request/url_request_throttler_test_support.cc b/net/url_request/url_request_throttler_test_support.cc index 1c418c2..b6088ec 100644 --- a/net/url_request/url_request_throttler_test_support.cc +++ b/net/url_request/url_request_throttler_test_support.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -42,11 +42,6 @@ MockURLRequestThrottlerHeaderAdapter::~MockURLRequestThrottlerHeaderAdapter() { std::string MockURLRequestThrottlerHeaderAdapter::GetNormalizedValue( const std::string& key) const { - if (key == URLRequestThrottlerEntry::kRetryHeaderName && - !fake_retry_value_.empty()) { - return fake_retry_value_; - } - if (key == URLRequestThrottlerEntry::kExponentialThrottlingHeader && !fake_opt_out_value_.empty()) { diff --git a/net/url_request/url_request_throttler_unittest.cc b/net/url_request/url_request_throttler_unittest.cc index 8ea46b0..88243db 100644 --- a/net/url_request/url_request_throttler_unittest.cc +++ b/net/url_request/url_request_throttler_unittest.cc @@ -180,7 +180,6 @@ class URLRequestThrottlerEntryTest : public testing::Test { // List of all histograms we care about in these unit tests. const char* kHistogramNames[] = { - "Throttling.CustomRetryAfterMs", "Throttling.FailureCountAtSuccess", "Throttling.PerceivedDowntime", "Throttling.RequestThrottled", @@ -255,26 +254,6 @@ TEST_F(URLRequestThrottlerEntryTest, InterfaceNotDuringExponentialBackoff) { ASSERT_EQ(0, samples_["Throttling.RequestThrottled"].counts(1)); } -TEST_F(URLRequestThrottlerEntryTest, InterfaceUpdateRetryAfter) { - // If the response we received has a retry-after field, - // the request should be delayed. - MockURLRequestThrottlerHeaderAdapter header_w_delay_header("5.5", "", 200); - entry_->UpdateWithResponse("", &header_w_delay_header); - EXPECT_GT(entry_->GetExponentialBackoffReleaseTime(), entry_->fake_time_now_) - << "When the server put a positive value in retry-after we should " - "increase release_time"; - - entry_->ResetToBlank(now_); - MockURLRequestThrottlerHeaderAdapter header_w_negative_header( - "-5.5", "", 200); - entry_->UpdateWithResponse("", &header_w_negative_header); - EXPECT_EQ(entry_->GetExponentialBackoffReleaseTime(), entry_->fake_time_now_) - << "When given a negative value, it should not change the release_time"; - - CalculateHistogramDeltas(); - ASSERT_EQ(1, samples_["Throttling.CustomRetryAfterMs"].TotalCount()); -} - TEST_F(URLRequestThrottlerEntryTest, InterfaceUpdateFailure) { MockURLRequestThrottlerHeaderAdapter failure_response(503); entry_->UpdateWithResponse("", &failure_response); |