Index: net/base/backoff_entry.cc |
diff --git a/net/base/backoff_entry.cc b/net/base/backoff_entry.cc |
index e7b7b558b70fc0e839044675f5af2412d5f86fed..0d8eb716f94d7fb4e5c68c3f35bf208bf2437fbc 100644 |
--- a/net/base/backoff_entry.cc |
+++ b/net/base/backoff_entry.cc |
@@ -17,7 +17,7 @@ BackoffEntry::BackoffEntry(const BackoffEntry::Policy* const policy) |
policy_(policy) { |
DCHECK(policy_); |
- // Can't use GetTimeNow() as it's virtual. |
+ // Can't use ImplGetTimeNow() as it's virtual. |
wtc
2011/05/25 23:12:06
IMPORTANT: I wonder if the constructor should just
Jói
2011/05/26 14:53:42
Good point, I fixed this so that the constructor c
|
exponential_backoff_release_time_ = base::TimeTicks::Now(); |
} |
@@ -42,21 +42,22 @@ void BackoffEntry::InformOfRequest(bool succeeded) { |
if (failure_count_ > 0) |
--failure_count_; |
- // The reason why we are not just cutting the release time to GetTimeNow() |
- // is on the one hand, it would unset a release time set by |
- // SetCustomReleaseTime and on the other we would like to push every |
- // request up to our "horizon" when dealing with multiple in-flight |
- // requests. Ex: If we send three requests and we receive 2 failures and |
- // 1 success. The success that follows those failures will not reset the |
- // release time, further requests will then need to wait the delay caused |
- // by the 2 failures. |
+ // The reason why we are not just cutting the release time to |
+ // ImplGetTimeNow() is on the one hand, it would unset a release |
+ // time set by SetCustomReleaseTime and on the other we would like |
+ // to push every request up to our "horizon" when dealing with |
+ // multiple in-flight requests. Ex: If we send three requests and |
+ // we receive 2 failures and 1 success. The success that follows |
+ // those failures will not reset the release time, further |
+ // requests will then need to wait the delay caused by the 2 |
+ // failures. |
exponential_backoff_release_time_ = std::max( |
- GetTimeNow(), exponential_backoff_release_time_); |
+ ImplGetTimeNow(), exponential_backoff_release_time_); |
} |
} |
bool BackoffEntry::ShouldRejectRequest() const { |
- return exponential_backoff_release_time_ > GetTimeNow(); |
+ return exponential_backoff_release_time_ > ImplGetTimeNow(); |
} |
base::TimeTicks BackoffEntry::GetReleaseTime() const { |
@@ -71,7 +72,7 @@ bool BackoffEntry::CanDiscard() const { |
if (policy_->entry_lifetime_ms == -1) |
return false; |
- base::TimeTicks now = GetTimeNow(); |
+ base::TimeTicks now = ImplGetTimeNow(); |
int64 unused_since_ms = |
(now - exponential_backoff_release_time_).InMilliseconds(); |
@@ -92,7 +93,16 @@ bool BackoffEntry::CanDiscard() const { |
return unused_since_ms >= policy_->entry_lifetime_ms; |
} |
-base::TimeTicks BackoffEntry::GetTimeNow() const { |
+void BackoffEntry::Reset() { |
+ failure_count_ = 0; |
+ exponential_backoff_release_time_ = ImplGetTimeNow(); |
+} |
+ |
+int BackoffEntry::failure_count() const { |
+ return failure_count_; |
+} |
+ |
+base::TimeTicks BackoffEntry::ImplGetTimeNow() const { |
return base::TimeTicks::Now(); |
} |
@@ -102,7 +112,7 @@ base::TimeTicks BackoffEntry::CalculateReleaseTime() const { |
if (effective_failure_count == 0) { |
// Never reduce previously set release horizon, e.g. due to Retry-After |
// header. |
- return std::max(GetTimeNow(), exponential_backoff_release_time_); |
+ return std::max(ImplGetTimeNow(), exponential_backoff_release_time_); |
} |
// The delay is calculated with this formula: |
@@ -119,8 +129,9 @@ base::TimeTicks BackoffEntry::CalculateReleaseTime() const { |
// Never reduce previously set release horizon, e.g. due to Retry-After |
// header. |
- return std::max(GetTimeNow() + base::TimeDelta::FromMilliseconds(delay_int), |
- exponential_backoff_release_time_); |
+ return std::max( |
+ ImplGetTimeNow() + base::TimeDelta::FromMilliseconds(delay_int), |
+ exponential_backoff_release_time_); |
} |
} // namespace net |