| Index: net/url_request/url_request_throttler_entry.cc
|
| diff --git a/net/url_request/url_request_throttler_entry.cc b/net/url_request/url_request_throttler_entry.cc
|
| index fdaaf7ff0d89f9a612521e4ab61f7cf6bc589242..b28e1c03d502f69c9ec7ac89df890514b29cd485 100644
|
| --- a/net/url_request/url_request_throttler_entry.cc
|
| +++ b/net/url_request/url_request_throttler_entry.cc
|
| @@ -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_;
|
| }
|
|
|