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

Unified Diff: components/sync/engine_impl/cycle/data_type_tracker.h

Issue 2475043002: [Sync] Sync client should to exponential backoff when receive partial failure (Closed)
Patch Set: review by self Created 4 years, 1 month 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
Index: components/sync/engine_impl/cycle/data_type_tracker.h
diff --git a/components/sync/engine_impl/cycle/data_type_tracker.h b/components/sync/engine_impl/cycle/data_type_tracker.h
index 9afd434a482e654302d9ff6f9423231d0ea9a89f..bef09bb112a9d217eb7968a8197d473b768d9943 100644
--- a/components/sync/engine_impl/cycle/data_type_tracker.h
+++ b/components/sync/engine_impl/cycle/data_type_tracker.h
@@ -21,6 +21,27 @@ namespace syncer {
class InvalidationInterface;
+struct WaitInterval {
+ enum BlockingMode {
+ // Uninitialized state, should not be set in practice.
+ UNKNOWN = -1,
+ // We enter a series of increasingly longer WaitIntervals if we experience
+ // repeated transient failures. We retry at the end of each interval.
+ EXPONENTIAL_BACKOFF,
+ // A server-initiated throttled interval. We do not allow any syncing
+ // during such an interval.
+ THROTTLED,
+ };
+ WaitInterval();
+ ~WaitInterval();
+ WaitInterval(BlockingMode mode, base::TimeDelta length);
+
+ static const char* GetModeString(BlockingMode mode);
+
+ BlockingMode mode;
+ base::TimeDelta length;
+};
+
// A class to track the per-type scheduling data.
class DataTypeTracker {
public:
@@ -94,16 +115,31 @@ class DataTypeTracker {
// Returns true if the type is currently throttled.
bool IsThrottled() const;
+ // Returns true if the type is currently backed off.
+ bool IsBackedOff() const;
+
// Returns the time until this type's throttling interval expires. Should not
// be called unless IsThrottled() returns true. The returned value will be
// increased to zero if it would otherwise have been negative.
base::TimeDelta GetTimeUntilUnthrottle(base::TimeTicks now) const;
+ // Returns the time until this type's backoff interval expires. Should not
+ // be called unless IsBackedOff() returns true. The returned value will be
+ // increased to zero if it would otherwise have been negative.
+ base::TimeDelta GetTimeUntilUnbackoff(base::TimeTicks now) const;
+
+ // Returns the last backoff interval.
+ base::TimeDelta GetLastUnbackoffInterval() const;
Nicolas Zea 2016/11/09 00:21:25 Should "Unbackoff" be "Backoff"? I'm not sure what
Gang Wu 2016/11/10 21:56:51 This is for SyncSchedulerImpl to exponential the b
+
// Throttles the type from |now| until |now| + |duration|.
void ThrottleType(base::TimeDelta duration, base::TimeTicks now);
- // Unthrottles the type if |now| >= the throttle expiry time.
- void UpdateThrottleState(base::TimeTicks now);
+ // Backoffs the type from |now| until |now| + |duration|.
+ void BackoffType(base::TimeDelta duration, base::TimeTicks now);
+
+ // Unthrottles or Unbackoffs the type if |now| >= |unblock_time_| expiry
+ // time.
+ void UpdateThrottleOrBackoffState(base::TimeTicks now);
// Update the local change nudge delay for this type.
void UpdateLocalNudgeDelay(base::TimeDelta delay);
@@ -133,9 +169,13 @@ class DataTypeTracker {
// Set to true if this type need to get update to resolve conflict issue.
bool sync_required_to_resolve_conflict_;
- // If !unthrottle_time_.is_null(), this type is throttled and may not download
- // or commit data until the specified time.
- base::TimeTicks unthrottle_time_;
+ // If !unblock_time_.is_null(), this type is throttled or backed off, check
+ // |wait_interval_->mode| for specific reason. Now the datatype may not
+ // download or commit data until the specified time.
+ base::TimeTicks unblock_time_;
+
+ // Current wait state. Null if we're not in backoff or throttling.
+ std::unique_ptr<WaitInterval> wait_interval_;
// A helper to keep track invalidations we dropped due to overflow.
std::unique_ptr<InvalidationInterface> last_dropped_invalidation_;

Powered by Google App Engine
This is Rietveld 408576698