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

Unified Diff: net/base/backoff_entry.h

Issue 1023473003: Allow BackoffEntry to be serialized and deserialized. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address mmenke's final review nits Created 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | net/base/backoff_entry.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/base/backoff_entry.h
diff --git a/net/base/backoff_entry.h b/net/base/backoff_entry.h
index dbc7488b7a4bd8005b5d699da8158d3a5459685c..be9d510474e9bd7bb0988b114ebee4cb93f6fad8 100644
--- a/net/base/backoff_entry.h
+++ b/net/base/backoff_entry.h
@@ -5,6 +5,7 @@
#ifndef NET_BASE_BACKOFF_ENTRY_H_
#define NET_BASE_BACKOFF_ENTRY_H_
+#include "base/macros.h"
#include "base/threading/non_thread_safe.h"
#include "base/time/time.h"
#include "net/base/net_export.h"
@@ -22,7 +23,8 @@ namespace net {
// intended for reuse in various networking scenarios.
class NET_EXPORT BackoffEntry : NON_EXPORTED_BASE(public base::NonThreadSafe) {
public:
- // The set of parameters that define a back-off policy.
+ // The set of parameters that define a back-off policy. When modifying this,
+ // increment SERIALIZATION_VERSION_NUMBER in backoff_entry_serializer.cc.
struct Policy {
// Number of initial errors (in sequence) to ignore before applying
// exponential back-off rules.
@@ -80,9 +82,15 @@ class NET_EXPORT BackoffEntry : NON_EXPORTED_BASE(public base::NonThreadSafe) {
// state) will no longer reject requests.
base::TimeTicks GetReleaseTime() const;
- // Returns the time until a request can be sent.
+ // Returns the time until a request can be sent (will be zero if the release
+ // time is in the past).
base::TimeDelta GetTimeUntilRelease() const;
+ // Converts |backoff_duration| to a release time, by adding it to
+ // GetTimeTicksNow(), limited by maximum_backoff_ms.
+ base::TimeTicks BackoffDurationToReleaseTime(
+ base::TimeDelta backoff_duration) 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);
@@ -98,6 +106,9 @@ class NET_EXPORT BackoffEntry : NON_EXPORTED_BASE(public base::NonThreadSafe) {
// Returns the failure count for this entry.
int failure_count() const { return failure_count_; }
+ // Returns the TickClock passed in to the constructor. May be NULL.
+ base::TickClock* tick_clock() const { return clock_; }
+
private:
// Calculates when requests should again be allowed through.
base::TimeTicks CalculateReleaseTime() const;
« no previous file with comments | « no previous file | net/base/backoff_entry.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698