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

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

Issue 6932013: Fix logic for handling reports of malformed bodies. To end up counting (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge to head Created 9 years, 7 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 | « no previous file | net/url_request/url_request_throttler_entry.cc » ('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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 9
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 11 matching lines...) Expand all
22 } 22 }
23 23
24 BackoffEntry::~BackoffEntry() { 24 BackoffEntry::~BackoffEntry() {
25 // TODO(joi): Remove this once our clients (e.g. URLRequestThrottlerManager) 25 // TODO(joi): Remove this once our clients (e.g. URLRequestThrottlerManager)
26 // always destroy from the I/O thread. 26 // always destroy from the I/O thread.
27 DetachFromThread(); 27 DetachFromThread();
28 } 28 }
29 29
30 void BackoffEntry::InformOfRequest(bool succeeded) { 30 void BackoffEntry::InformOfRequest(bool succeeded) {
31 if (!succeeded) { 31 if (!succeeded) {
32 failure_count_++; 32 ++failure_count_;
33 exponential_backoff_release_time_ = CalculateReleaseTime(); 33 exponential_backoff_release_time_ = CalculateReleaseTime();
34 } else { 34 } else {
35 failure_count_ = 0; 35 // We slowly decay the number of times delayed instead of resetting it to 0
36 // in order to stay stable if we receive successes interleaved between lots
37 // of failures.
38 //
39 // TODO(joi): Revisit this; it might be most correct to go to zero
40 // but have a way to go back to "old error count +1" if there is
41 // another error soon after.
42 failure_count_ = std::max(0, --failure_count_);
36 43
37 // The reason why we are not just cutting the release time to GetTimeNow() 44 // The reason why we are not just cutting the release time to GetTimeNow()
38 // is on the one hand, it would unset a release time set by 45 // is on the one hand, it would unset a release time set by
39 // SetCustomReleaseTime and on the other we would like to push every 46 // SetCustomReleaseTime and on the other we would like to push every
40 // request up to our "horizon" when dealing with multiple in-flight 47 // request up to our "horizon" when dealing with multiple in-flight
41 // requests. Ex: If we send three requests and we receive 2 failures and 48 // requests. Ex: If we send three requests and we receive 2 failures and
42 // 1 success. The success that follows those failures will not reset the 49 // 1 success. The success that follows those failures will not reset the
43 // release time, further requests will then need to wait the delay caused 50 // release time, further requests will then need to wait the delay caused
44 // by the 2 failures. 51 // by the 2 failures.
45 exponential_backoff_release_time_ = std::max( 52 exponential_backoff_release_time_ = std::max(
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 delay_int = std::min(delay_int, 116 delay_int = std::min(delay_int,
110 static_cast<int64>(policy_->maximum_backoff_ms)); 117 static_cast<int64>(policy_->maximum_backoff_ms));
111 118
112 // Never reduce previously set release horizon, e.g. due to Retry-After 119 // Never reduce previously set release horizon, e.g. due to Retry-After
113 // header. 120 // header.
114 return std::max(GetTimeNow() + base::TimeDelta::FromMilliseconds(delay_int), 121 return std::max(GetTimeNow() + base::TimeDelta::FromMilliseconds(delay_int),
115 exponential_backoff_release_time_); 122 exponential_backoff_release_time_);
116 } 123 }
117 124
118 } // namespace net 125 } // namespace net
OLDNEW
« no previous file with comments | « no previous file | net/url_request/url_request_throttler_entry.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698