| 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 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 reject_request = true; | 160 reject_request = true; |
| 161 } | 161 } |
| 162 | 162 |
| 163 int reject_count = reject_request ? 1 : 0; | 163 int reject_count = reject_request ? 1 : 0; |
| 164 UMA_HISTOGRAM_ENUMERATION( | 164 UMA_HISTOGRAM_ENUMERATION( |
| 165 "Throttling.RequestThrottled", reject_count, 2); | 165 "Throttling.RequestThrottled", reject_count, 2); |
| 166 | 166 |
| 167 return reject_request; | 167 return reject_request; |
| 168 } | 168 } |
| 169 | 169 |
| 170 int64 URLRequestThrottlerEntry::ReserveSendingTimeForNextRequest( | 170 int64_t URLRequestThrottlerEntry::ReserveSendingTimeForNextRequest( |
| 171 const base::TimeTicks& earliest_time) { | 171 const base::TimeTicks& earliest_time) { |
| 172 base::TimeTicks now = ImplGetTimeNow(); | 172 base::TimeTicks now = ImplGetTimeNow(); |
| 173 | 173 |
| 174 // If a lot of requests were successfully made recently, | 174 // If a lot of requests were successfully made recently, |
| 175 // sliding_window_release_time_ may be greater than | 175 // sliding_window_release_time_ may be greater than |
| 176 // exponential_backoff_release_time_. | 176 // exponential_backoff_release_time_. |
| 177 base::TimeTicks recommended_sending_time = | 177 base::TimeTicks recommended_sending_time = |
| 178 std::max(std::max(now, earliest_time), | 178 std::max(std::max(now, earliest_time), |
| 179 std::max(GetBackoffEntry()->GetReleaseTime(), | 179 std::max(GetBackoffEntry()->GetReleaseTime(), |
| 180 sliding_window_release_time_)); | 180 sliding_window_release_time_)); |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 282 BackoffEntry* URLRequestThrottlerEntry::GetBackoffEntry() { | 282 BackoffEntry* URLRequestThrottlerEntry::GetBackoffEntry() { |
| 283 return &backoff_entry_; | 283 return &backoff_entry_; |
| 284 } | 284 } |
| 285 | 285 |
| 286 // static | 286 // static |
| 287 bool URLRequestThrottlerEntry::ExplicitUserRequest(const int load_flags) { | 287 bool URLRequestThrottlerEntry::ExplicitUserRequest(const int load_flags) { |
| 288 return (load_flags & LOAD_MAYBE_USER_GESTURE) != 0; | 288 return (load_flags & LOAD_MAYBE_USER_GESTURE) != 0; |
| 289 } | 289 } |
| 290 | 290 |
| 291 } // namespace net | 291 } // namespace net |
| OLD | NEW |