Commit 041e9390 authored by xunjieli's avatar xunjieli Committed by Commit bot

Remove X-Chrome-Exponential-Throttling header

This CL removes X-Chrome-Exponential-Throttling header support from net/ .

BUG=352259

Review URL: https://codereview.chromium.org/1148603003

Cr-Commit-Position: refs/heads/master@{#330619}
parent 538f17a2
......@@ -1222,9 +1222,6 @@
'url_request/url_request_throttler_entry.cc',
'url_request/url_request_throttler_entry.h',
'url_request/url_request_throttler_entry_interface.h',
'url_request/url_request_throttler_header_adapter.cc',
'url_request/url_request_throttler_header_adapter.h',
'url_request/url_request_throttler_header_interface.h',
'url_request/url_request_throttler_manager.cc',
'url_request/url_request_throttler_manager.h',
'url_request/view_cache_helper.cc',
......
......@@ -45,7 +45,6 @@
#include "net/url_request/url_request_error_job.h"
#include "net/url_request/url_request_job_factory.h"
#include "net/url_request/url_request_redirect_job.h"
#include "net/url_request/url_request_throttler_header_adapter.h"
#include "net/url_request/url_request_throttler_manager.h"
#include "net/websockets/websocket_handshake_stream_base.h"
......@@ -308,11 +307,8 @@ void URLRequestHttpJob::NotifyHeadersComplete() {
// also need this info.
is_cached_content_ = response_info_->was_cached;
if (!is_cached_content_ && throttling_entry_.get()) {
URLRequestThrottlerHeaderAdapter response_adapter(GetResponseHeaders());
throttling_entry_->UpdateWithResponse(request_info_.url.host(),
&response_adapter);
}
if (!is_cached_content_ && throttling_entry_.get())
throttling_entry_->UpdateWithResponse(GetResponseCode());
// The ordering of these calls is not important.
ProcessStrictTransportSecurityHeader();
......
......@@ -16,7 +16,6 @@
#include "net/log/net_log.h"
#include "net/url_request/url_request.h"
#include "net/url_request/url_request_context.h"
#include "net/url_request/url_request_throttler_header_interface.h"
#include "net/url_request/url_request_throttler_manager.h"
namespace net {
......@@ -46,10 +45,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::kExponentialThrottlingHeader[] =
"X-Chrome-Exponential-Throttling";
const char URLRequestThrottlerEntry::kExponentialThrottlingDisableValue[] =
"disable";
// Returns NetLog parameters when a request is rejected by throttling.
base::Value* NetLogRejectedRequestCallback(
......@@ -222,19 +217,8 @@ base::TimeTicks
return GetBackoffEntry()->GetReleaseTime();
}
void URLRequestThrottlerEntry::UpdateWithResponse(
const std::string& host,
const URLRequestThrottlerHeaderInterface* response) {
if (IsConsideredError(response->GetResponseCode())) {
GetBackoffEntry()->InformOfRequest(false);
} else {
GetBackoffEntry()->InformOfRequest(true);
std::string throttling_header = response->GetNormalizedValue(
kExponentialThrottlingHeader);
if (!throttling_header.empty())
HandleThrottlingHeader(throttling_header, host);
}
void URLRequestThrottlerEntry::UpdateWithResponse(int status_code) {
GetBackoffEntry()->InformOfRequest(IsConsideredSuccess(status_code));
}
void URLRequestThrottlerEntry::ReceivedContentWasMalformed(int response_code) {
......@@ -247,7 +231,7 @@ void URLRequestThrottlerEntry::ReceivedContentWasMalformed(int response_code) {
//
// We do nothing for a response that is already being considered an error
// based on its status code (otherwise we would count 3 errors instead of 1).
if (!IsConsideredError(response_code)) {
if (IsConsideredSuccess(response_code)) {
GetBackoffEntry()->InformOfRequest(false);
GetBackoffEntry()->InformOfRequest(false);
}
......@@ -267,7 +251,7 @@ void URLRequestThrottlerEntry::Initialize() {
backoff_policy_.always_use_initial_delay = false;
}
bool URLRequestThrottlerEntry::IsConsideredError(int response_code) {
bool URLRequestThrottlerEntry::IsConsideredSuccess(int response_code) {
// We throttle only for the status codes most likely to indicate the server
// is failing because it is too busy or otherwise are likely to be
// because of DDoS.
......@@ -285,25 +269,14 @@ bool URLRequestThrottlerEntry::IsConsideredError(int response_code) {
// have not made it to the destination server and so we do not actually
// know that it is down or busy. One degenerate case could be a proxy on
// localhost, where you are not actually connected to the network.
return (response_code == 500 ||
response_code == 503 ||
response_code == 509);
return !(response_code == 500 || response_code == 503 ||
response_code == 509);
}
base::TimeTicks URLRequestThrottlerEntry::ImplGetTimeNow() const {
return base::TimeTicks::Now();
}
void URLRequestThrottlerEntry::HandleThrottlingHeader(
const std::string& header_value,
const std::string& host) {
if (header_value == kExponentialThrottlingDisableValue) {
DisableBackoffThrottling();
if (manager_)
manager_->AddToOptOutList(host);
}
}
const BackoffEntry* URLRequestThrottlerEntry::GetBackoffEntry() const {
return &backoff_entry_;
}
......
......@@ -58,14 +58,6 @@ class NET_EXPORT URLRequestThrottlerEntry
// Time after which the entry is considered outdated.
static const int kDefaultEntryLifetimeMs;
// Name of the header that sites can use to opt out of exponential back-off
// throttling.
static const char kExponentialThrottlingHeader[];
// Value for exponential throttling header that can be used to opt out of
// exponential back-off throttling.
static const char kExponentialThrottlingDisableValue[];
// The manager object's lifetime must enclose the lifetime of this object.
URLRequestThrottlerEntry(URLRequestThrottlerManager* manager,
const std::string& url_id);
......@@ -98,9 +90,7 @@ class NET_EXPORT URLRequestThrottlerEntry
int64 ReserveSendingTimeForNextRequest(
const base::TimeTicks& earliest_time) override;
base::TimeTicks GetExponentialBackoffReleaseTime() const override;
void UpdateWithResponse(
const std::string& host,
const URLRequestThrottlerHeaderInterface* response) override;
void UpdateWithResponse(int status_code) override;
void ReceivedContentWasMalformed(int response_code) override;
protected:
......@@ -108,17 +98,13 @@ class NET_EXPORT URLRequestThrottlerEntry
void Initialize();
// Returns true if the given response code is considered an error for
// Returns true if the given response code is considered a success for
// throttling purposes.
bool IsConsideredError(int response_code);
bool IsConsideredSuccess(int response_code);
// Equivalent to TimeTicks::Now(), virtual to be mockable for testing purpose.
virtual base::TimeTicks ImplGetTimeNow() const;
// Used internally to handle the opt-out header.
void HandleThrottlingHeader(const std::string& header_value,
const std::string& host);
// Retrieves the back-off entry object we're using. Used to enable a
// unit testing seam for dependency injection in tests.
virtual const BackoffEntry* GetBackoffEntry() const;
......
......@@ -51,9 +51,7 @@ class NET_EXPORT URLRequestThrottlerEntryInterface
virtual base::TimeTicks GetExponentialBackoffReleaseTime() const = 0;
// This method needs to be called each time a response is received.
virtual void UpdateWithResponse(
const std::string& host,
const URLRequestThrottlerHeaderInterface* response) = 0;
virtual void UpdateWithResponse(int status_code) = 0;
// Lets higher-level modules, that know how to parse particular response
// bodies, notify of receiving malformed content for the given URL. This will
......
// Copyright (c) 2011 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.
#include "net/url_request/url_request_throttler_header_adapter.h"
#include "net/http/http_response_headers.h"
namespace net {
URLRequestThrottlerHeaderAdapter::URLRequestThrottlerHeaderAdapter(
HttpResponseHeaders* headers)
: response_header_(headers) {
}
URLRequestThrottlerHeaderAdapter::~URLRequestThrottlerHeaderAdapter() {}
std::string URLRequestThrottlerHeaderAdapter::GetNormalizedValue(
const std::string& key) const {
std::string return_value;
response_header_->GetNormalizedHeader(key, &return_value);
return return_value;
}
int URLRequestThrottlerHeaderAdapter::GetResponseCode() const {
return response_header_->response_code();
}
} // namespace net
// Copyright (c) 2011 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.
#ifndef NET_URL_REQUEST_URL_REQUEST_THROTTLER_HEADER_ADAPTER_H_
#define NET_URL_REQUEST_URL_REQUEST_THROTTLER_HEADER_ADAPTER_H_
#include <string>
#include "base/compiler_specific.h"
#include "base/memory/ref_counted.h"
#include "net/url_request/url_request_throttler_header_interface.h"
namespace net {
class HttpResponseHeaders;
// Adapter for the HTTP header interface of the URL request throttler component.
class URLRequestThrottlerHeaderAdapter
: public URLRequestThrottlerHeaderInterface {
public:
explicit URLRequestThrottlerHeaderAdapter(HttpResponseHeaders* headers);
~URLRequestThrottlerHeaderAdapter() override;
// Implementation of URLRequestThrottlerHeaderInterface
std::string GetNormalizedValue(const std::string& key) const override;
int GetResponseCode() const override;
private:
const scoped_refptr<HttpResponseHeaders> response_header_;
};
} // namespace net
#endif // NET_URL_REQUEST_URL_REQUEST_THROTTLER_HEADER_ADAPTER_H_
// Copyright (c) 2010 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.
#ifndef NET_URL_REQUEST_URL_REQUEST_THROTTLER_HEADER_INTERFACE_H_
#define NET_URL_REQUEST_URL_REQUEST_THROTTLER_HEADER_INTERFACE_H_
#include <string>
namespace net {
// Interface to an HTTP header to enforce we have the methods we need.
class URLRequestThrottlerHeaderInterface {
public:
virtual ~URLRequestThrottlerHeaderInterface() {}
// Method that enables us to fetch the header value by its key.
// ex: location: www.example.com -> key = "location" value = "www.example.com"
// If the key does not exist, it returns an empty string.
virtual std::string GetNormalizedValue(const std::string& key) const = 0;
// Returns the HTTP response code associated with the request.
virtual int GetResponseCode() const = 0;
};
} // namespace net
#endif // NET_URL_REQUEST_URL_REQUEST_THROTTLER_HEADER_INTERFACE_H_
......@@ -75,12 +75,9 @@ scoped_refptr<URLRequestThrottlerEntryInterface>
// We only disable back-off throttling on an entry that we have
// just constructed. This is to allow unit tests to explicitly override
// the entry for localhost URLs. Given that we do not attempt to
// disable throttling for entries already handed out (see comment
// in AddToOptOutList), this is not a problem.
// the entry for localhost URLs.
std::string host = url.host();
if (opt_out_hosts_.find(host) != opt_out_hosts_.end() ||
IsLocalhost(host)) {
if (IsLocalhost(host)) {
if (!logged_for_localhost_disabled_ && IsLocalhost(host)) {
logged_for_localhost_disabled_ = true;
net_log_.AddEvent(NetLog::TYPE_THROTTLING_DISABLED_FOR_HOST,
......@@ -89,8 +86,7 @@ scoped_refptr<URLRequestThrottlerEntryInterface>
// TODO(joi): Once sliding window is separate from back-off throttling,
// we can simply return a dummy implementation of
// URLRequestThrottlerEntryInterface here that never blocks anything (and
// not keep entries in url_entries_ for opted-out sites).
// URLRequestThrottlerEntryInterface here that never blocks anything.
entry->DisableBackoffThrottling();
}
}
......@@ -98,21 +94,6 @@ scoped_refptr<URLRequestThrottlerEntryInterface>
return entry;
}
void URLRequestThrottlerManager::AddToOptOutList(const std::string& host) {
// There is an edge case here that we are not handling, to keep things
// simple. If a host starts adding the opt-out header to its responses
// after there are already one or more entries in url_entries_ for that
// host, the pre-existing entries may still perform back-off throttling.
// In practice, this would almost never occur.
if (opt_out_hosts_.find(host) == opt_out_hosts_.end()) {
UMA_HISTOGRAM_COUNTS("Throttling.SiteOptedOut", 1);
net_log_.EndEvent(NetLog::TYPE_THROTTLING_DISABLED_FOR_HOST,
NetLog::StringCallback("host", &host));
opt_out_hosts_.insert(host);
}
}
void URLRequestThrottlerManager::OverrideEntryForTests(
const GURL& url,
URLRequestThrottlerEntry* entry) {
......
......@@ -47,11 +47,6 @@ class NET_EXPORT URLRequestThrottlerManager
scoped_refptr<URLRequestThrottlerEntryInterface> RegisterRequestUrl(
const GURL& url);
// Adds the given host to a list of sites for which exponential back-off
// throttling will be disabled. Subdomains are not included, so they
// must be added separately.
void AddToOptOutList(const std::string& host);
// Registers a new entry in this service and overrides the existing entry (if
// any) for the URL. The service will hold a reference to the entry.
// It is only used by unit tests.
......@@ -117,10 +112,6 @@ class NET_EXPORT URLRequestThrottlerManager
typedef std::map<std::string, scoped_refptr<URLRequestThrottlerEntry> >
UrlEntryMap;
// We maintain a set of hosts that have opted out of exponential
// back-off throttling.
typedef std::set<std::string> OptOutHosts;
// Maximum number of entries that we are willing to collect in our map.
static const unsigned int kMaximumNumberOfEntries;
// Number of requests that will be made between garbage collection.
......@@ -130,9 +121,6 @@ class NET_EXPORT URLRequestThrottlerManager
// URLRequestThrottlerEntry.
UrlEntryMap url_entries_;
// Set of hosts that have opted out.
OptOutHosts opt_out_hosts_;
// This keeps track of how many requests have been made. Used with
// GarbageCollectEntries.
unsigned int requests_since_last_gc_;
......
......@@ -427,8 +427,7 @@ class Requester : public DiscreteTimeSimulation::Actor {
server_->mock_request(),
server_->context().network_delegate())) {
int status_code = server_->HandleRequest();
MockURLRequestThrottlerHeaderAdapter response_headers(status_code);
throttler_entry_->UpdateWithResponse(std::string(), &response_headers);
throttler_entry_->UpdateWithResponse(status_code);
if (status_code == 200) {
if (results_)
......
......@@ -18,36 +18,4 @@ base::TimeTicks TestTickClock::NowTicks() {
return now_ticks_;
}
MockURLRequestThrottlerHeaderAdapter::MockURLRequestThrottlerHeaderAdapter(
int response_code)
: fake_response_code_(response_code) {
}
MockURLRequestThrottlerHeaderAdapter::MockURLRequestThrottlerHeaderAdapter(
const std::string& retry_value,
const std::string& opt_out_value,
int response_code)
: fake_retry_value_(retry_value),
fake_opt_out_value_(opt_out_value),
fake_response_code_(response_code) {
}
MockURLRequestThrottlerHeaderAdapter::~MockURLRequestThrottlerHeaderAdapter() {
}
std::string MockURLRequestThrottlerHeaderAdapter::GetNormalizedValue(
const std::string& key) const {
if (key ==
URLRequestThrottlerEntry::kExponentialThrottlingHeader &&
!fake_opt_out_value_.empty()) {
return fake_opt_out_value_;
}
return std::string();
}
int MockURLRequestThrottlerHeaderAdapter::GetResponseCode() const {
return fake_response_code_;
}
} // namespace net
......@@ -11,7 +11,6 @@
#include "base/time/tick_clock.h"
#include "base/time/time.h"
#include "net/base/backoff_entry.h"
#include "net/url_request/url_request_throttler_header_interface.h"
namespace net {
......@@ -29,35 +28,6 @@ class TestTickClock : public base::TickClock {
DISALLOW_COPY_AND_ASSIGN(TestTickClock);
};
// Mocks the URLRequestThrottlerHeaderInterface, allowing testing code to
// pass arbitrary fake headers to the throttling code.
class MockURLRequestThrottlerHeaderAdapter
: public URLRequestThrottlerHeaderInterface {
public:
// Constructs mock response headers with the given |response_code| and no
// custom response header fields.
explicit MockURLRequestThrottlerHeaderAdapter(int response_code);
// Constructs mock response headers with the given |response_code| and
// with a custom-retry header value |retry_value| if it is non-empty, and
// a custom opt-out header value |opt_out_value| if it is non-empty.
MockURLRequestThrottlerHeaderAdapter(const std::string& retry_value,
const std::string& opt_out_value,
int response_code);
~MockURLRequestThrottlerHeaderAdapter() override;
// URLRequestThrottlerHeaderInterface overrides.
std::string GetNormalizedValue(const std::string& key) const override;
int GetResponseCode() const override;
private:
std::string fake_retry_value_;
std::string fake_opt_out_value_;
int fake_response_code_;
DISALLOW_COPY_AND_ASSIGN(MockURLRequestThrottlerHeaderAdapter);
};
} // namespace net
#endif // NET_URL_REQUEST_URL_REQUEST_THROTTLER_TEST_SUPPORT_H_
......@@ -18,7 +18,6 @@
#include "net/url_request/url_request.h"
#include "net/url_request/url_request_context.h"
#include "net/url_request/url_request_test_util.h"
#include "net/url_request/url_request_throttler_header_interface.h"
#include "net/url_request/url_request_throttler_test_support.h"
#include "testing/gtest/include/gtest/gtest.h"
......@@ -235,30 +234,26 @@ TEST_F(URLRequestThrottlerEntryTest, InterfaceNotDuringExponentialBackoff) {
}
TEST_F(URLRequestThrottlerEntryTest, InterfaceUpdateFailure) {
MockURLRequestThrottlerHeaderAdapter failure_response(503);
entry_->UpdateWithResponse(std::string(), &failure_response);
entry_->UpdateWithResponse(503);
EXPECT_GT(entry_->GetExponentialBackoffReleaseTime(),
entry_->ImplGetTimeNow())
<< "A failure should increase the release_time";
}
TEST_F(URLRequestThrottlerEntryTest, InterfaceUpdateSuccess) {
MockURLRequestThrottlerHeaderAdapter success_response(200);
entry_->UpdateWithResponse(std::string(), &success_response);
entry_->UpdateWithResponse(200);
EXPECT_EQ(entry_->GetExponentialBackoffReleaseTime(),
entry_->ImplGetTimeNow())
<< "A success should not add any delay";
}
TEST_F(URLRequestThrottlerEntryTest, InterfaceUpdateSuccessThenFailure) {
MockURLRequestThrottlerHeaderAdapter failure_response(503);
MockURLRequestThrottlerHeaderAdapter success_response(200);
entry_->UpdateWithResponse(std::string(), &success_response);
entry_->UpdateWithResponse(std::string(), &failure_response);
entry_->UpdateWithResponse(200);
entry_->UpdateWithResponse(503);
EXPECT_GT(entry_->GetExponentialBackoffReleaseTime(),
entry_->ImplGetTimeNow())
<< "This scenario should add delay";
entry_->UpdateWithResponse(std::string(), &success_response);
entry_->UpdateWithResponse(200);
}
TEST_F(URLRequestThrottlerEntryTest, IsEntryReallyOutdated) {
......@@ -283,8 +278,7 @@ TEST_F(URLRequestThrottlerEntryTest, IsEntryReallyOutdated) {
TEST_F(URLRequestThrottlerEntryTest, MaxAllowedBackoff) {
for (int i = 0; i < 30; ++i) {
MockURLRequestThrottlerHeaderAdapter response_adapter(503);
entry_->UpdateWithResponse(std::string(), &response_adapter);
entry_->UpdateWithResponse(503);
}
TimeDelta delay = entry_->GetExponentialBackoffReleaseTime() - now_;
......@@ -293,9 +287,8 @@ TEST_F(URLRequestThrottlerEntryTest, MaxAllowedBackoff) {
}
TEST_F(URLRequestThrottlerEntryTest, MalformedContent) {
MockURLRequestThrottlerHeaderAdapter response_adapter(503);
for (int i = 0; i < 5; ++i)
entry_->UpdateWithResponse(std::string(), &response_adapter);
entry_->UpdateWithResponse(503);
TimeTicks release_after_failures = entry_->GetExponentialBackoffReleaseTime();
......@@ -305,8 +298,7 @@ TEST_F(URLRequestThrottlerEntryTest, MalformedContent) {
// is what happens in practice (if a body is received, then a non-500
// response must also have been received).
entry_->ReceivedContentWasMalformed(200);
MockURLRequestThrottlerHeaderAdapter success_adapter(200);
entry_->UpdateWithResponse(std::string(), &success_adapter);
entry_->UpdateWithResponse(200);
EXPECT_GT(entry_->GetExponentialBackoffReleaseTime(), release_after_failures);
}
......@@ -361,10 +353,8 @@ class URLRequestThrottlerManagerTest : public testing::Test {
const URLRequest& request) {
EXPECT_FALSE(entry->ShouldRejectRequest(request,
context_.network_delegate()));
MockURLRequestThrottlerHeaderAdapter failure_adapter(503);
for (int i = 0; i < 10; ++i) {
// Host doesn't really matter in this scenario so we skip it.
entry->UpdateWithResponse(std::string(), &failure_adapter);
entry->UpdateWithResponse(503);
}
EXPECT_NE(opted_out, entry->ShouldRejectRequest(
request, context_.network_delegate()));
......@@ -452,40 +442,25 @@ TEST_F(URLRequestThrottlerManagerTest, IsHostBeingRegistered) {
EXPECT_EQ(3, manager.GetNumberOfEntries());
}
TEST_F(URLRequestThrottlerManagerTest, OptOutHeader) {
TEST_F(URLRequestThrottlerManagerTest, LocalHostOptedOut) {
MockURLRequestThrottlerManager manager;
scoped_refptr<URLRequestThrottlerEntryInterface> entry =
manager.RegisterRequestUrl(GURL("http://www.google.com/yodude"));
// Fake a response with the opt-out header.
MockURLRequestThrottlerHeaderAdapter response_adapter(
std::string(),
MockURLRequestThrottlerEntry::kExponentialThrottlingDisableValue,
200);
entry->UpdateWithResponse("www.google.com", &response_adapter);
// Ensure that the same entry on error always allows everything.
ExpectEntryAllowsAllOnErrorIfOptedOut(entry.get(), true, *request_);
// Ensure that a freshly created entry (for a different URL on an
// already opted-out host) also gets "always allow" behavior.
scoped_refptr<URLRequestThrottlerEntryInterface> other_entry =
manager.RegisterRequestUrl(GURL("http://www.google.com/bingobob"));
ExpectEntryAllowsAllOnErrorIfOptedOut(other_entry.get(), true, *request_);
// Fake a response with the opt-out header incorrectly specified.
scoped_refptr<URLRequestThrottlerEntryInterface> no_opt_out_entry =
manager.RegisterRequestUrl(GURL("http://www.nike.com/justdoit"));
MockURLRequestThrottlerHeaderAdapter wrong_adapter(
std::string(), "yesplease", 200);
no_opt_out_entry->UpdateWithResponse("www.nike.com", &wrong_adapter);
ExpectEntryAllowsAllOnErrorIfOptedOut(
no_opt_out_entry.get(), false, *request_);
// A localhost entry should always be opted out.
scoped_refptr<URLRequestThrottlerEntryInterface> localhost_entry =
manager.RegisterRequestUrl(GURL("http://localhost/hello"));
ExpectEntryAllowsAllOnErrorIfOptedOut(localhost_entry.get(), true, *request_);
EXPECT_FALSE(localhost_entry->ShouldRejectRequest(
(*request_), context_.network_delegate()));
for (int i = 0; i < 10; ++i) {
localhost_entry->UpdateWithResponse(503);
}
EXPECT_FALSE(localhost_entry->ShouldRejectRequest(
(*request_), context_.network_delegate()));
// We're not mocking out GetTimeNow() in this scenario
// so add a 100 ms buffer to avoid flakiness (that should always
// give enough time to get from the TimeTicks::Now() call here
// to the TimeTicks::Now() call in the entry class).
EXPECT_GT(TimeTicks::Now() + TimeDelta::FromMilliseconds(100),
localhost_entry->GetExponentialBackoffReleaseTime());
}
TEST_F(URLRequestThrottlerManagerTest, ClearOnNetworkChange) {
......@@ -493,10 +468,8 @@ TEST_F(URLRequestThrottlerManagerTest, ClearOnNetworkChange) {
MockURLRequestThrottlerManager manager;
scoped_refptr<URLRequestThrottlerEntryInterface> entry_before =
manager.RegisterRequestUrl(GURL("http://www.example.com/"));
MockURLRequestThrottlerHeaderAdapter failure_adapter(503);
for (int j = 0; j < 10; ++j) {
// Host doesn't really matter in this scenario so we skip it.
entry_before->UpdateWithResponse(std::string(), &failure_adapter);
entry_before->UpdateWithResponse(503);
}
EXPECT_TRUE(entry_before->ShouldRejectRequest(*request_,
context_.network_delegate()));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment