| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/rand_util.h" | 10 #include "base/rand_util.h" |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 | 67 |
| 68 bool URLRequestThrottlerEntry::IsEntryOutdated() const { | 68 bool URLRequestThrottlerEntry::IsEntryOutdated() const { |
| 69 CHECK(this); // to help track crbug.com/71721 | 69 CHECK(this); // to help track crbug.com/71721 |
| 70 if (entry_lifetime_ms_ == -1) | 70 if (entry_lifetime_ms_ == -1) |
| 71 return false; | 71 return false; |
| 72 | 72 |
| 73 base::TimeTicks now = GetTimeNow(); | 73 base::TimeTicks now = GetTimeNow(); |
| 74 | 74 |
| 75 // If there are send events in the sliding window period, we still need this | 75 // If there are send events in the sliding window period, we still need this |
| 76 // entry. | 76 // entry. |
| 77 if (send_log_.size() > 0 && | 77 if (!send_log_.empty() && |
| 78 send_log_.back() + sliding_window_period_ > now) { | 78 send_log_.back() + sliding_window_period_ > now) { |
| 79 return false; | 79 return false; |
| 80 } | 80 } |
| 81 | 81 |
| 82 int64 unused_since_ms = | 82 int64 unused_since_ms = |
| 83 (now - exponential_backoff_release_time_).InMilliseconds(); | 83 (now - exponential_backoff_release_time_).InMilliseconds(); |
| 84 | 84 |
| 85 // Release time is further than now, we are managing it. | 85 // Release time is further than now, we are managing it. |
| 86 if (unused_since_ms < 0) | 86 if (unused_since_ms < 0) |
| 87 return false; | 87 return false; |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 238 | 238 |
| 239 if (maximum_backoff_ms_ < value_ms || value_ms < 0) | 239 if (maximum_backoff_ms_ < value_ms || value_ms < 0) |
| 240 return; | 240 return; |
| 241 | 241 |
| 242 exponential_backoff_release_time_ = std::max( | 242 exponential_backoff_release_time_ = std::max( |
| 243 (GetTimeNow() + base::TimeDelta::FromMilliseconds(value_ms)), | 243 (GetTimeNow() + base::TimeDelta::FromMilliseconds(value_ms)), |
| 244 exponential_backoff_release_time_); | 244 exponential_backoff_release_time_); |
| 245 } | 245 } |
| 246 | 246 |
| 247 } // namespace net | 247 } // namespace net |
| OLD | NEW |