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

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

Issue 19674007: Revert 212129 "Cleaning up TODO(joi) entries in //net." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 7 years, 5 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 | Annotate | Revision Log
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/rand_util.h" 12 #include "base/rand_util.h"
13 13
14 namespace net { 14 namespace net {
15 15
16 BackoffEntry::BackoffEntry(const BackoffEntry::Policy* const policy) 16 BackoffEntry::BackoffEntry(const BackoffEntry::Policy* const policy)
17 : policy_(policy) { 17 : policy_(policy) {
18 DCHECK(policy_); 18 DCHECK(policy_);
19 Reset(); 19 Reset();
20 } 20 }
21 21
22 BackoffEntry::~BackoffEntry() { 22 BackoffEntry::~BackoffEntry() {
23 // TODO(joi): Remove this once our clients (e.g. URLRequestThrottlerManager)
24 // always destroy from the I/O thread.
25 DetachFromThread();
23 } 26 }
24 27
25 void BackoffEntry::InformOfRequest(bool succeeded) { 28 void BackoffEntry::InformOfRequest(bool succeeded) {
26 if (!succeeded) { 29 if (!succeeded) {
27 ++failure_count_; 30 ++failure_count_;
28 exponential_backoff_release_time_ = CalculateReleaseTime(); 31 exponential_backoff_release_time_ = CalculateReleaseTime();
29 } else { 32 } else {
30 // We slowly decay the number of times delayed instead of 33 // We slowly decay the number of times delayed instead of
31 // resetting it to 0 in order to stay stable if we receive 34 // resetting it to 0 in order to stay stable if we receive
32 // successes interleaved between lots of failures. Note that in 35 // successes interleaved between lots of failures. Note that in
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 delay_int = std::min(delay_int, policy_->maximum_backoff_ms); 145 delay_int = std::min(delay_int, policy_->maximum_backoff_ms);
143 146
144 // Never reduce previously set release horizon, e.g. due to Retry-After 147 // Never reduce previously set release horizon, e.g. due to Retry-After
145 // header. 148 // header.
146 return std::max( 149 return std::max(
147 ImplGetTimeNow() + base::TimeDelta::FromMilliseconds(delay_int), 150 ImplGetTimeNow() + base::TimeDelta::FromMilliseconds(delay_int),
148 exponential_backoff_release_time_); 151 exponential_backoff_release_time_);
149 } 152 }
150 153
151 } // namespace net 154 } // namespace net
OLDNEW
« no previous file with comments | « trunk/src/chrome/browser/io_thread.cc ('k') | trunk/src/net/url_request/url_request_throttler_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698