| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "net/url_request/url_request_throttler_entry.h" | 5 #include "net/url_request/url_request_throttler_entry.h" |
| 6 | 6 |
| 7 #include <cmath> | 7 #include <cmath> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/metrics/field_trial.h" | 10 #include "base/metrics/field_trial.h" |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 | 143 |
| 144 void URLRequestThrottlerEntry::DisableBackoffThrottling() { | 144 void URLRequestThrottlerEntry::DisableBackoffThrottling() { |
| 145 is_backoff_disabled_ = true; | 145 is_backoff_disabled_ = true; |
| 146 } | 146 } |
| 147 | 147 |
| 148 void URLRequestThrottlerEntry::DetachManager() { | 148 void URLRequestThrottlerEntry::DetachManager() { |
| 149 manager_ = NULL; | 149 manager_ = NULL; |
| 150 } | 150 } |
| 151 | 151 |
| 152 bool URLRequestThrottlerEntry::ShouldRejectRequest( | 152 bool URLRequestThrottlerEntry::ShouldRejectRequest( |
| 153 const URLRequest& request) const { | 153 const URLRequest& request, |
| 154 NetworkDelegate* network_delegate) const { |
| 154 bool reject_request = false; | 155 bool reject_request = false; |
| 155 if (!is_backoff_disabled_ && !ExplicitUserRequest(request.load_flags()) && | 156 if (!is_backoff_disabled_ && !ExplicitUserRequest(request.load_flags()) && |
| 156 (!request.context()->network_delegate() || | 157 (!network_delegate || network_delegate->CanThrottleRequest(request)) && |
| 157 request.context()->network_delegate()->CanThrottleRequest(request)) && | |
| 158 GetBackoffEntry()->ShouldRejectRequest()) { | 158 GetBackoffEntry()->ShouldRejectRequest()) { |
| 159 int num_failures = GetBackoffEntry()->failure_count(); | 159 int num_failures = GetBackoffEntry()->failure_count(); |
| 160 int release_after_ms = | 160 int release_after_ms = |
| 161 GetBackoffEntry()->GetTimeUntilRelease().InMilliseconds(); | 161 GetBackoffEntry()->GetTimeUntilRelease().InMilliseconds(); |
| 162 | 162 |
| 163 net_log_.AddEvent( | 163 net_log_.AddEvent( |
| 164 NetLog::TYPE_THROTTLING_REJECTED_REQUEST, | 164 NetLog::TYPE_THROTTLING_REJECTED_REQUEST, |
| 165 base::Bind(&NetLogRejectedRequestCallback, | 165 base::Bind(&NetLogRejectedRequestCallback, |
| 166 &url_id_, num_failures, release_after_ms)); | 166 &url_id_, num_failures, release_after_ms)); |
| 167 | 167 |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 312 BackoffEntry* URLRequestThrottlerEntry::GetBackoffEntry() { | 312 BackoffEntry* URLRequestThrottlerEntry::GetBackoffEntry() { |
| 313 return &backoff_entry_; | 313 return &backoff_entry_; |
| 314 } | 314 } |
| 315 | 315 |
| 316 // static | 316 // static |
| 317 bool URLRequestThrottlerEntry::ExplicitUserRequest(const int load_flags) { | 317 bool URLRequestThrottlerEntry::ExplicitUserRequest(const int load_flags) { |
| 318 return (load_flags & LOAD_MAYBE_USER_GESTURE) != 0; | 318 return (load_flags & LOAD_MAYBE_USER_GESTURE) != 0; |
| 319 } | 319 } |
| 320 | 320 |
| 321 } // namespace net | 321 } // namespace net |
| OLD | NEW |