| 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 "extensions/browser/extension_throttle_entry.h" | 5 #include "extensions/browser/extension_throttle_entry.h" |
| 6 | 6 |
| 7 #include <cmath> | 7 #include <cmath> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 GetBackoffEntry()->ShouldRejectRequest()) { | 153 GetBackoffEntry()->ShouldRejectRequest()) { |
| 154 net_log_.AddEvent(net::NetLog::TYPE_THROTTLING_REJECTED_REQUEST, | 154 net_log_.AddEvent(net::NetLog::TYPE_THROTTLING_REJECTED_REQUEST, |
| 155 base::Bind(&NetLogRejectedRequestCallback, &url_id_, | 155 base::Bind(&NetLogRejectedRequestCallback, &url_id_, |
| 156 GetBackoffEntry()->failure_count(), | 156 GetBackoffEntry()->failure_count(), |
| 157 GetBackoffEntry()->GetTimeUntilRelease())); | 157 GetBackoffEntry()->GetTimeUntilRelease())); |
| 158 reject_request = true; | 158 reject_request = true; |
| 159 } | 159 } |
| 160 return reject_request; | 160 return reject_request; |
| 161 } | 161 } |
| 162 | 162 |
| 163 int64 ExtensionThrottleEntry::ReserveSendingTimeForNextRequest( | 163 int64_t ExtensionThrottleEntry::ReserveSendingTimeForNextRequest( |
| 164 const base::TimeTicks& earliest_time) { | 164 const base::TimeTicks& earliest_time) { |
| 165 base::TimeTicks now = ImplGetTimeNow(); | 165 base::TimeTicks now = ImplGetTimeNow(); |
| 166 | 166 |
| 167 // If a lot of requests were successfully made recently, | 167 // If a lot of requests were successfully made recently, |
| 168 // sliding_window_release_time_ may be greater than | 168 // sliding_window_release_time_ may be greater than |
| 169 // exponential_backoff_release_time_. | 169 // exponential_backoff_release_time_. |
| 170 base::TimeTicks recommended_sending_time = | 170 base::TimeTicks recommended_sending_time = |
| 171 std::max(std::max(now, earliest_time), | 171 std::max(std::max(now, earliest_time), |
| 172 std::max(GetBackoffEntry()->GetReleaseTime(), | 172 std::max(GetBackoffEntry()->GetReleaseTime(), |
| 173 sliding_window_release_time_)); | 173 sliding_window_release_time_)); |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 278 net::BackoffEntry* ExtensionThrottleEntry::GetBackoffEntry() { | 278 net::BackoffEntry* ExtensionThrottleEntry::GetBackoffEntry() { |
| 279 return &backoff_entry_; | 279 return &backoff_entry_; |
| 280 } | 280 } |
| 281 | 281 |
| 282 // static | 282 // static |
| 283 bool ExtensionThrottleEntry::ExplicitUserRequest(const int load_flags) { | 283 bool ExtensionThrottleEntry::ExplicitUserRequest(const int load_flags) { |
| 284 return (load_flags & net::LOAD_MAYBE_USER_GESTURE) != 0; | 284 return (load_flags & net::LOAD_MAYBE_USER_GESTURE) != 0; |
| 285 } | 285 } |
| 286 | 286 |
| 287 } // namespace extensions | 287 } // namespace extensions |
| OLD | NEW |