Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(417)

Side by Side Diff: net/base/backoff_entry.cc

Issue 2910473005: Deprecate NonThreadSafe in net/ in favor of SequenceChecker/ThreadChecker. (Closed)
Patch Set: rebase on r476634 Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/base/backoff_entry.h ('k') | net/base/network_change_notifier_win.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/numerics/safe_math.h" 12 #include "base/numerics/safe_math.h"
13 #include "base/rand_util.h" 13 #include "base/rand_util.h"
14 #include "base/time/tick_clock.h" 14 #include "base/time/tick_clock.h"
15 15
16 namespace net { 16 namespace net {
17 17
18 BackoffEntry::BackoffEntry(const BackoffEntry::Policy* policy) 18 BackoffEntry::BackoffEntry(const BackoffEntry::Policy* policy)
19 : BackoffEntry(policy, nullptr) {} 19 : BackoffEntry(policy, nullptr) {}
20 20
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): Enable 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 // DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
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
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
OLDNEW
« no previous file with comments | « net/base/backoff_entry.h ('k') | net/base/network_change_notifier_win.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698