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/base/backoff_entry.h" | 5 #include "net/base/backoff_entry.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cmath> | 8 #include <cmath> |
9 #include <limits> | 9 #include <limits> |
10 | 10 |
(...skipping 10 matching lines...) Expand all Loading... | |
21 BackoffEntry::BackoffEntry(const BackoffEntry::Policy* policy, | 21 BackoffEntry::BackoffEntry(const BackoffEntry::Policy* policy, |
22 base::TickClock* clock) | 22 base::TickClock* clock) |
23 : policy_(policy), clock_(clock) { | 23 : policy_(policy), clock_(clock) { |
24 DCHECK(policy_); | 24 DCHECK(policy_); |
25 Reset(); | 25 Reset(); |
26 } | 26 } |
27 | 27 |
28 BackoffEntry::~BackoffEntry() { | 28 BackoffEntry::~BackoffEntry() { |
29 // TODO(joi): Remove this once our clients (e.g. URLRequestThrottlerManager) | 29 // TODO(joi): Remove this once our clients (e.g. URLRequestThrottlerManager) |
30 // always destroy from the I/O thread. | 30 // always destroy from the I/O thread. |
31 DetachFromThread(); | 31 DETACH_FROM_THREAD(thread_checker_); |
mmenke
2017/05/31 19:28:08
Is this needed? thread_checker_ doesn't check on
gab
2017/05/31 20:46:36
Done.
| |
32 } | 32 } |
33 | 33 |
34 void BackoffEntry::InformOfRequest(bool succeeded) { | 34 void BackoffEntry::InformOfRequest(bool succeeded) { |
35 if (!succeeded) { | 35 if (!succeeded) { |
36 ++failure_count_; | 36 ++failure_count_; |
37 exponential_backoff_release_time_ = CalculateReleaseTime(); | 37 exponential_backoff_release_time_ = CalculateReleaseTime(); |
38 } else { | 38 } else { |
39 // We slowly decay the number of times delayed instead of | 39 // We slowly decay the number of times delayed instead of |
40 // resetting it to 0 in order to stay stable if we receive | 40 // resetting it to 0 in order to stay stable if we receive |
41 // successes interleaved between lots of failures. Note that in | 41 // successes interleaved between lots of failures. Note that in |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
177 // for overflow with both. | 177 // for overflow with both. |
178 int64_t release_time_us = std::min(calculated_release_time_us.ValueOrDefault( | 178 int64_t release_time_us = std::min(calculated_release_time_us.ValueOrDefault( |
179 std::numeric_limits<int64_t>::max()), | 179 std::numeric_limits<int64_t>::max()), |
180 maximum_release_time_us.ValueOrDefault( | 180 maximum_release_time_us.ValueOrDefault( |
181 std::numeric_limits<int64_t>::max())); | 181 std::numeric_limits<int64_t>::max())); |
182 | 182 |
183 return base::TimeTicks() + base::TimeDelta::FromMicroseconds(release_time_us); | 183 return base::TimeTicks() + base::TimeDelta::FromMicroseconds(release_time_us); |
184 } | 184 } |
185 | 185 |
186 } // namespace net | 186 } // namespace net |
OLD | NEW |