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

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

Issue 18261003: Cleaning up TODO(joi) entries in //net. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge LKGR. 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
« no previous file with comments | « chrome/browser/io_thread.cc ('k') | net/url_request/url_request_throttler_manager.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/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();
26 } 23 }
27 24
28 void BackoffEntry::InformOfRequest(bool succeeded) { 25 void BackoffEntry::InformOfRequest(bool succeeded) {
29 if (!succeeded) { 26 if (!succeeded) {
30 ++failure_count_; 27 ++failure_count_;
31 exponential_backoff_release_time_ = CalculateReleaseTime(); 28 exponential_backoff_release_time_ = CalculateReleaseTime();
32 } else { 29 } else {
33 // We slowly decay the number of times delayed instead of 30 // We slowly decay the number of times delayed instead of
34 // resetting it to 0 in order to stay stable if we receive 31 // resetting it to 0 in order to stay stable if we receive
35 // successes interleaved between lots of failures. Note that in 32 // successes interleaved between lots of failures. Note that in
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 delay_int = std::min(delay_int, policy_->maximum_backoff_ms); 142 delay_int = std::min(delay_int, policy_->maximum_backoff_ms);
146 143
147 // Never reduce previously set release horizon, e.g. due to Retry-After 144 // Never reduce previously set release horizon, e.g. due to Retry-After
148 // header. 145 // header.
149 return std::max( 146 return std::max(
150 ImplGetTimeNow() + base::TimeDelta::FromMilliseconds(delay_int), 147 ImplGetTimeNow() + base::TimeDelta::FromMilliseconds(delay_int),
151 exponential_backoff_release_time_); 148 exponential_backoff_release_time_);
152 } 149 }
153 150
154 } // namespace net 151 } // namespace net
OLDNEW
« no previous file with comments | « chrome/browser/io_thread.cc ('k') | net/url_request/url_request_throttler_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698