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

Unified Diff: net/base/backoff_entry.h

Issue 10173005: BackoffEntry: Add the option to always use a delay. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Remove expects failing on trybots due to roundoff Created 8 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | net/base/backoff_entry.cc » ('j') | remoting/host/chromoting_host.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/base/backoff_entry.h
===================================================================
--- net/base/backoff_entry.h (revision 133709)
+++ net/base/backoff_entry.h (working copy)
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef NET_BASE_BACKOFF_ITEM_H_
-#define NET_BASE_BACKOFF_ITEM_H_
+#ifndef NET_BASE_BACKOFF_ENTRY_H_
+#define NET_BASE_BACKOFF_ENTRY_H_
#pragma once
#include "base/threading/non_thread_safe.h"
@@ -17,8 +17,7 @@
//
// This utility class knows nothing about network specifics; it is
// intended for reuse in various networking scenarios.
-class NET_EXPORT_PRIVATE BackoffEntry
- : NON_EXPORTED_BASE(public base::NonThreadSafe) {
+class NET_EXPORT BackoffEntry : NON_EXPORTED_BASE(public base::NonThreadSafe) {
public:
// The set of parameters that define a back-off policy.
struct Policy {
@@ -26,8 +25,11 @@
// exponential back-off rules.
int num_errors_to_ignore;
- // Initial delay for exponential back-off.
- int initial_backoff_ms;
+ // Initial delay. The interpretation of this value depends on
+ // always_use_initial_delay. It's either how long we wait between
+ // requests before backoff starts, or how much we delay the first request
+ // after backoff starts.
+ int initial_delay_ms;
// Factor by which the waiting time will be multiplied.
double multiply_factor;
@@ -43,6 +45,15 @@
// Time to keep an entry from being discarded even when it
// has no significant state, -1 to never discard.
int64 entry_lifetime_ms;
+
+ // If true, we always use a delay of initial_delay_ms, even before
+ // we've seen num_errors_to_ignore errors. Otherwise, initial_delay_ms
+ // is the first delay once we start exponential backoff.
+ //
+ // So if we're ignoring 1 error, we'll see (N, N, Nm, Nm^2, ...) if true,
+ // and (0, 0, N, Nm, ...) when false, where N is initial_backoff_ms and
+ // m is multiply_factor, assuming we've already seen one success.
+ bool always_use_initial_delay;
};
// Lifetime of policy must enclose lifetime of BackoffEntry. The
@@ -62,13 +73,16 @@
// state) will no longer reject requests.
base::TimeTicks GetReleaseTime() const;
+ // Returns the time until a request can be sent.
+ base::TimeDelta GetTimeUntilRelease() const;
+
// Causes this object reject requests until the specified absolute time.
// This can be used to e.g. implement support for a Retry-After header.
void SetCustomReleaseTime(const base::TimeTicks& release_time);
// Returns true if this object has no significant state (i.e. you could
// just as well start with a fresh BackoffEntry object), and hasn't
- // had for Policy::entry_lifetime_ms_.
+ // had for Policy::entry_lifetime_ms.
bool CanDiscard() const;
// Resets this entry to a fresh (as if just constructed) state.
@@ -89,7 +103,7 @@
// allowed to start sending requests again.
base::TimeTicks exponential_backoff_release_time_;
- // Counts request errors; reset on success.
+ // Counts request errors; decremented on success.
int failure_count_;
const Policy* const policy_;
@@ -99,4 +113,4 @@
} // namespace net
-#endif // NET_BASE_BACKOFF_ITEM_H_
+#endif // NET_BASE_BACKOFF_ENTRY_H_
« no previous file with comments | « no previous file | net/base/backoff_entry.cc » ('j') | remoting/host/chromoting_host.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698