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 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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) const { |
154 bool reject_request = false; | 154 bool reject_request = false; |
155 if (!is_backoff_disabled_ && !ExplicitUserRequest(request.load_flags()) && | 155 if (!is_backoff_disabled_ && !ExplicitUserRequest(request.load_flags()) && |
156 (!request.context()->network_delegate() || | 156 request.CanThrottle() && GetBackoffEntry()->ShouldRejectRequest()) { |
erikwright (departed)
2013/02/25 15:07:23
I don't think this is right. Either we can just no
| |
157 request.context()->network_delegate()->CanThrottleRequest(request)) && | |
158 GetBackoffEntry()->ShouldRejectRequest()) { | |
159 int num_failures = GetBackoffEntry()->failure_count(); | 157 int num_failures = GetBackoffEntry()->failure_count(); |
160 int release_after_ms = | 158 int release_after_ms = |
161 GetBackoffEntry()->GetTimeUntilRelease().InMilliseconds(); | 159 GetBackoffEntry()->GetTimeUntilRelease().InMilliseconds(); |
162 | 160 |
163 net_log_.AddEvent( | 161 net_log_.AddEvent( |
164 NetLog::TYPE_THROTTLING_REJECTED_REQUEST, | 162 NetLog::TYPE_THROTTLING_REJECTED_REQUEST, |
165 base::Bind(&NetLogRejectedRequestCallback, | 163 base::Bind(&NetLogRejectedRequestCallback, |
166 &url_id_, num_failures, release_after_ms)); | 164 &url_id_, num_failures, release_after_ms)); |
167 | 165 |
168 reject_request = true; | 166 reject_request = true; |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
312 BackoffEntry* URLRequestThrottlerEntry::GetBackoffEntry() { | 310 BackoffEntry* URLRequestThrottlerEntry::GetBackoffEntry() { |
313 return &backoff_entry_; | 311 return &backoff_entry_; |
314 } | 312 } |
315 | 313 |
316 // static | 314 // static |
317 bool URLRequestThrottlerEntry::ExplicitUserRequest(const int load_flags) { | 315 bool URLRequestThrottlerEntry::ExplicitUserRequest(const int load_flags) { |
318 return (load_flags & LOAD_MAYBE_USER_GESTURE) != 0; | 316 return (load_flags & LOAD_MAYBE_USER_GESTURE) != 0; |
319 } | 317 } |
320 | 318 |
321 } // namespace net | 319 } // namespace net |
OLD | NEW |