Skip to content

Commit

Permalink
Remove NetworkDelegate::OnCanThrottleRequest
Browse files Browse the repository at this point in the history
This CL removes NetworkDelegate::OnCanThrottleRequest which is no longer
relevant and can be deleted.

TBR=startmorgan@chromium.org
TBR=davidben@chromium.org
BUG=500680

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

Cr-Commit-Position: refs/heads/master@{#335916}
  • Loading branch information
xunjieli authored and Commit bot committed Jun 24, 2015
1 parent b28d496 commit 41edcdd
Show file tree
Hide file tree
Showing 26 changed files with 16 additions and 144 deletions.
5 changes: 0 additions & 5 deletions android_webview/browser/net/aw_network_delegate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,4 @@ bool AwNetworkDelegate::OnCanAccessFile(const net::URLRequest& request,
return true;
}

bool AwNetworkDelegate::OnCanThrottleRequest(
const net::URLRequest& request) const {
return false;
}

} // namespace android_webview
1 change: 0 additions & 1 deletion android_webview/browser/net/aw_network_delegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ class AwNetworkDelegate : public net::NetworkDelegateImpl {
net::CookieOptions* options) override;
bool OnCanAccessFile(const net::URLRequest& request,
const base::FilePath& path) const override;
bool OnCanThrottleRequest(const net::URLRequest& request) const override;

DISALLOW_COPY_AND_ASSIGN(AwNetworkDelegate);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,6 @@ class BasicNetworkDelegate : public net::NetworkDelegateImpl {
return false;
}

bool OnCanThrottleRequest(const net::URLRequest& request) const override {
return false;
}

DISALLOW_COPY_AND_ASSIGN(BasicNetworkDelegate);
};

Expand Down
5 changes: 0 additions & 5 deletions components/cronet/android/url_request_context_adapter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,6 @@ class BasicNetworkDelegate : public net::NetworkDelegateImpl {
return false;
}

bool OnCanThrottleRequest(
const net::URLRequest& request) const override {
return false;
}

DISALLOW_COPY_AND_ASSIGN(BasicNetworkDelegate);
};

Expand Down
5 changes: 0 additions & 5 deletions content/shell/browser/shell_network_delegate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,6 @@ bool ShellNetworkDelegate::OnCanAccessFile(const net::URLRequest& request,
return true;
}

bool ShellNetworkDelegate::OnCanThrottleRequest(
const net::URLRequest& request) const {
return false;
}

bool ShellNetworkDelegate::OnFirstPartyOnlyCookieExperimentEnabled() const {
return base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kEnableExperimentalWebPlatformFeatures);
Expand Down
1 change: 0 additions & 1 deletion content/shell/browser/shell_network_delegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ class ShellNetworkDelegate : public net::NetworkDelegateImpl {
net::CookieOptions* options) override;
bool OnCanAccessFile(const net::URLRequest& request,
const base::FilePath& path) const override;
bool OnCanThrottleRequest(const net::URLRequest& request) const override;
bool OnFirstPartyOnlyCookieExperimentEnabled() const override;

DISALLOW_COPY_AND_ASSIGN(ShellNetworkDelegate);
Expand Down
5 changes: 0 additions & 5 deletions ios/web/shell/shell_network_delegate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,4 @@ bool ShellNetworkDelegate::OnCanAccessFile(const net::URLRequest& request,
return true;
}

bool ShellNetworkDelegate::OnCanThrottleRequest(
const net::URLRequest& request) const {
return false;
}

} // namespace web
1 change: 0 additions & 1 deletion ios/web/shell/shell_network_delegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ class ShellNetworkDelegate : public net::NetworkDelegateImpl {
net::CookieOptions* options) override;
bool OnCanAccessFile(const net::URLRequest& request,
const base::FilePath& path) const override;
bool OnCanThrottleRequest(const net::URLRequest& request) const override;

DISALLOW_COPY_AND_ASSIGN(ShellNetworkDelegate);
};
Expand Down
10 changes: 0 additions & 10 deletions net/base/layered_network_delegate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -229,16 +229,6 @@ void LayeredNetworkDelegate::OnCanAccessFileInternal(
const base::FilePath& path) const {
}

bool LayeredNetworkDelegate::OnCanThrottleRequest(
const URLRequest& request) const {
OnCanThrottleRequestInternal(request);
return nested_network_delegate_->CanThrottleRequest(request);
}

void LayeredNetworkDelegate::OnCanThrottleRequestInternal(
const URLRequest& request) const {
}

bool LayeredNetworkDelegate::OnCanEnablePrivacyMode(
const GURL& url,
const GURL& first_party_for_cookies) const {
Expand Down
3 changes: 0 additions & 3 deletions net/base/layered_network_delegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ class NET_EXPORT LayeredNetworkDelegate : public NetworkDelegate {
CookieOptions* options) final;
bool OnCanAccessFile(const URLRequest& request,
const base::FilePath& path) const final;
bool OnCanThrottleRequest(const URLRequest& request) const final;
bool OnCanEnablePrivacyMode(const GURL& url,
const GURL& first_party_for_cookies) const final;
bool OnFirstPartyOnlyCookieExperimentEnabled() const final;
Expand Down Expand Up @@ -147,8 +146,6 @@ class NET_EXPORT LayeredNetworkDelegate : public NetworkDelegate {
virtual void OnCanAccessFileInternal(const URLRequest& request,
const base::FilePath& path) const;

virtual void OnCanThrottleRequestInternal(const URLRequest& request) const;

virtual void OnCanEnablePrivacyModeInternal(
const GURL& url,
const GURL& first_party_for_cookies) const;
Expand Down
11 changes: 0 additions & 11 deletions net/base/layered_network_delegate_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -136,11 +136,6 @@ class TestNetworkDelegateImpl : public NetworkDelegateImpl {
return false;
}

bool OnCanThrottleRequest(const URLRequest& request) const override {
IncrementAndCompareCounter("on_can_throttle_request_count");
return false;
}

bool OnCanEnablePrivacyMode(
const GURL& url,
const GURL& first_party_for_cookies) const override {
Expand Down Expand Up @@ -214,7 +209,6 @@ class TestLayeredNetworkDelegate : public LayeredNetworkDelegate {
EXPECT_FALSE(OnCanGetCookies(*request, CookieList()));
EXPECT_FALSE(OnCanSetCookie(*request, std::string(), NULL));
EXPECT_FALSE(OnCanAccessFile(*request, base::FilePath()));
EXPECT_FALSE(OnCanThrottleRequest(*request));
EXPECT_FALSE(OnCanEnablePrivacyMode(GURL(), GURL()));
EXPECT_FALSE(OnCancelURLRequestWithPolicyViolatingReferrerHeader(
*request, GURL(), GURL()));
Expand Down Expand Up @@ -332,11 +326,6 @@ class TestLayeredNetworkDelegate : public LayeredNetworkDelegate {
EXPECT_EQ(1, (*counters_)["on_can_access_file_count"]);
}

void OnCanThrottleRequestInternal(const URLRequest& request) const override {
++(*counters_)["on_can_throttle_request_count"];
EXPECT_EQ(1, (*counters_)["on_can_throttle_request_count"]);
}

void OnCanEnablePrivacyModeInternal(
const GURL& url,
const GURL& first_party_for_cookies) const override {
Expand Down
5 changes: 0 additions & 5 deletions net/base/network_delegate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -153,11 +153,6 @@ bool NetworkDelegate::CanAccessFile(const URLRequest& request,
return OnCanAccessFile(request, path);
}

bool NetworkDelegate::CanThrottleRequest(const URLRequest& request) const {
DCHECK(CalledOnValidThread());
return OnCanThrottleRequest(request);
}

bool NetworkDelegate::CanEnablePrivacyMode(
const GURL& url,
const GURL& first_party_for_cookies) const {
Expand Down
6 changes: 0 additions & 6 deletions net/base/network_delegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ class NET_EXPORT NetworkDelegate : public base::NonThreadSafe {
CookieOptions* options);
bool CanAccessFile(const URLRequest& request,
const base::FilePath& path) const;
bool CanThrottleRequest(const URLRequest& request) const;
bool CanEnablePrivacyMode(const GURL& url,
const GURL& first_party_for_cookies) const;

Expand Down Expand Up @@ -258,11 +257,6 @@ class NET_EXPORT NetworkDelegate : public base::NonThreadSafe {
virtual bool OnCanAccessFile(const URLRequest& request,
const base::FilePath& path) const = 0;

// Returns true if the given request may be rejected when the
// URLRequestThrottlerManager believes the server servicing the
// request is overloaded or down.
virtual bool OnCanThrottleRequest(const URLRequest& request) const = 0;

// Returns true if the given |url| has to be requested over connection that
// is not tracked by the server. Usually is false, unless user privacy
// settings block cookies from being get or set.
Expand Down
5 changes: 0 additions & 5 deletions net/base/network_delegate_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,6 @@ bool NetworkDelegateImpl::OnCanAccessFile(const URLRequest& request,
return false;
}

bool NetworkDelegateImpl::OnCanThrottleRequest(
const URLRequest& request) const {
return false;
}

bool NetworkDelegateImpl::OnCanEnablePrivacyMode(
const GURL& url,
const GURL& first_party_for_cookies) const {
Expand Down
5 changes: 0 additions & 5 deletions net/base/network_delegate_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -172,11 +172,6 @@ class NET_EXPORT NetworkDelegateImpl : public NetworkDelegate {
bool OnCanAccessFile(const URLRequest& request,
const base::FilePath& path) const override;

// Returns true if the given request may be rejected when the
// URLRequestThrottlerManager believes the server servicing the
// request is overloaded or down.
bool OnCanThrottleRequest(const URLRequest& request) const override;

// Returns true if the given |url| has to be requested over connection that
// is not tracked by the server. Usually is false, unless user privacy
// settings block cookies from being get or set.
Expand Down
3 changes: 0 additions & 3 deletions net/proxy/network_delegate_error_observer_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,6 @@ class TestNetworkDelegate : public NetworkDelegateImpl {
const base::FilePath& path) const override {
return true;
}
bool OnCanThrottleRequest(const URLRequest& request) const override {
return false;
}

bool got_pac_error_;
};
Expand Down
3 changes: 0 additions & 3 deletions net/proxy/proxy_script_fetcher_impl_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -178,9 +178,6 @@ class BasicNetworkDelegate : public NetworkDelegateImpl {
const base::FilePath& path) const override {
return true;
}
bool OnCanThrottleRequest(const URLRequest& request) const override {
return false;
}

DISALLOW_COPY_AND_ASSIGN(BasicNetworkDelegate);
};
Expand Down
6 changes: 0 additions & 6 deletions net/url_request/url_request_context_builder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,6 @@ class BasicNetworkDelegate : public NetworkDelegateImpl {
return true;
}

bool OnCanThrottleRequest(const URLRequest& request) const override {
// Returning true will only enable throttling if there's also a
// URLRequestThrottlerManager, which there isn't, by default.
return true;
}

DISALLOW_COPY_AND_ASSIGN(BasicNetworkDelegate);
};

Expand Down
3 changes: 1 addition & 2 deletions net/url_request/url_request_http_job.cc
Original file line number Diff line number Diff line change
Expand Up @@ -495,8 +495,7 @@ void URLRequestHttpJob::StartTransactionInternal() {
base::Unretained(this)));

if (!throttling_entry_.get() ||
!throttling_entry_->ShouldRejectRequest(*request_,
network_delegate())) {
!throttling_entry_->ShouldRejectRequest(*request_)) {
rv = transaction_->Start(
&request_info_, start_callback_, request_->net_log());
start_time_ = base::TimeTicks::Now();
Expand Down
6 changes: 0 additions & 6 deletions net/url_request/url_request_test_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,6 @@ TestNetworkDelegate::TestNetworkDelegate()
has_load_timing_info_before_redirect_(false),
has_load_timing_info_before_auth_(false),
can_access_files_(true),
can_throttle_requests_(true),
first_party_only_cookies_enabled_(false),
cancel_request_with_policy_violating_referrer_(false),
will_be_intercepted_on_next_error_(false) {
Expand Down Expand Up @@ -608,11 +607,6 @@ bool TestNetworkDelegate::OnCanAccessFile(const URLRequest& request,
return can_access_files_;
}

bool TestNetworkDelegate::OnCanThrottleRequest(
const URLRequest& request) const {
return can_throttle_requests_;
}

bool TestNetworkDelegate::OnFirstPartyOnlyCookieExperimentEnabled() const {
return first_party_only_cookies_enabled_;
}
Expand Down
5 changes: 0 additions & 5 deletions net/url_request/url_request_test_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -276,9 +276,6 @@ class TestNetworkDelegate : public NetworkDelegateImpl {
first_party_only_cookies_enabled_ = val;
}

void set_can_throttle_requests(bool val) { can_throttle_requests_ = val; }
bool can_throttle_requests() const { return can_throttle_requests_; }

void set_cancel_request_with_policy_violating_referrer(bool val) {
cancel_request_with_policy_violating_referrer_ = val;
}
Expand Down Expand Up @@ -335,7 +332,6 @@ class TestNetworkDelegate : public NetworkDelegateImpl {
CookieOptions* options) override;
bool OnCanAccessFile(const URLRequest& request,
const base::FilePath& path) const override;
bool OnCanThrottleRequest(const URLRequest& request) const override;
bool OnFirstPartyOnlyCookieExperimentEnabled() const override;
bool OnCancelURLRequestWithPolicyViolatingReferrerHeader(
const URLRequest& request,
Expand Down Expand Up @@ -381,7 +377,6 @@ class TestNetworkDelegate : public NetworkDelegateImpl {
bool has_load_timing_info_before_auth_;

bool can_access_files_; // true by default
bool can_throttle_requests_; // true by default
bool first_party_only_cookies_enabled_; // false by default
bool cancel_request_with_policy_violating_referrer_; // false by default
bool will_be_intercepted_on_next_error_;
Expand Down
4 changes: 1 addition & 3 deletions net/url_request/url_request_throttler_entry.cc
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,9 @@ void URLRequestThrottlerEntry::DetachManager() {
}

bool URLRequestThrottlerEntry::ShouldRejectRequest(
const URLRequest& request,
NetworkDelegate* network_delegate) const {
const URLRequest& request) const {
bool reject_request = false;
if (!is_backoff_disabled_ && !ExplicitUserRequest(request.load_flags()) &&
(!network_delegate || network_delegate->CanThrottleRequest(request)) &&
GetBackoffEntry()->ShouldRejectRequest()) {
net_log_.AddEvent(
NetLog::TYPE_THROTTLING_REJECTED_REQUEST,
Expand Down
3 changes: 1 addition & 2 deletions net/url_request/url_request_throttler_entry.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,7 @@ class NET_EXPORT URLRequestThrottlerEntry
void DetachManager();

// Implementation of URLRequestThrottlerEntryInterface.
bool ShouldRejectRequest(const URLRequest& request,
NetworkDelegate* network_delegate) const override;
bool ShouldRejectRequest(const URLRequest& request) const override;
int64 ReserveSendingTimeForNextRequest(
const base::TimeTicks& earliest_time) override;
base::TimeTicks GetExponentialBackoffReleaseTime() const override;
Expand Down
7 changes: 2 additions & 5 deletions net/url_request/url_request_throttler_entry_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,11 @@ class NET_EXPORT URLRequestThrottlerEntryInterface

// Returns true when we have encountered server errors and are doing
// exponential back-off, unless the request has load flags that mean
// it is likely to be user-initiated, or the NetworkDelegate returns
// false for |CanThrottleRequest(request)|.
// it is likely to be user-initiated.
//
// URLRequestHttpJob checks this method prior to every request; it
// cancels requests if this method returns true.
virtual bool ShouldRejectRequest(
const URLRequest& request,
NetworkDelegate* network_delegate) const = 0;
virtual bool ShouldRejectRequest(const URLRequest& request) const = 0;

// Calculates a recommended sending time for the next request and reserves it.
// The sending time is not earlier than the current exponential back-off
Expand Down
4 changes: 1 addition & 3 deletions net/url_request/url_request_throttler_simulation_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -423,9 +423,7 @@ class Requester : public DiscreteTimeSimulation::Actor {

if (throttler_entry_->ImplGetTimeNow() - time_of_last_attempt_ >
effective_delay) {
if (!throttler_entry_->ShouldRejectRequest(
server_->mock_request(),
server_->context().network_delegate())) {
if (!throttler_entry_->ShouldRejectRequest(server_->mock_request())) {
int status_code = server_->HandleRequest();
throttler_entry_->UpdateWithResponse(status_code);

Expand Down
Loading

0 comments on commit 41edcdd

Please sign in to comment.