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

Unified Diff: sync/sessions/nudge_tracker.cc

Issue 146113003: sync: GU retry with less explicit TimeTicks logic (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Update NudgeTracker before normal mode transition cycle Created 6 years, 11 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 | « sync/sessions/nudge_tracker.h ('k') | sync/sessions/nudge_tracker_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sync/sessions/nudge_tracker.cc
diff --git a/sync/sessions/nudge_tracker.cc b/sync/sessions/nudge_tracker.cc
index f96d3464826e86653fb04d515c7d9575d891f2be..212500aa38b4ac20990419455e7365c678688416 100644
--- a/sync/sessions/nudge_tracker.cc
+++ b/sync/sessions/nudge_tracker.cc
@@ -44,11 +44,11 @@ bool NudgeTracker::IsSyncRequired() const {
return false;
}
-bool NudgeTracker::IsGetUpdatesRequired(base::TimeTicks now) const {
+bool NudgeTracker::IsGetUpdatesRequired() const {
if (invalidations_out_of_sync_)
return true;
- if (IsRetryRequired(now))
+ if (IsRetryRequired())
return true;
for (TypeTrackerMap::const_iterator it = type_trackers_.begin();
@@ -60,16 +60,22 @@ bool NudgeTracker::IsGetUpdatesRequired(base::TimeTicks now) const {
return false;
}
-bool NudgeTracker::IsRetryRequired(base::TimeTicks now) const {
- return !next_retry_time_.is_null() && next_retry_time_ < now;
+bool NudgeTracker::IsRetryRequired() const {
+ if (sync_cycle_start_time_.is_null())
+ return false;
+
+ if (current_retry_time_.is_null())
+ return false;
+
+ return current_retry_time_ < sync_cycle_start_time_;
}
-void NudgeTracker::RecordSuccessfulSyncCycle(base::TimeTicks now) {
+void NudgeTracker::RecordSuccessfulSyncCycle() {
updates_source_ = sync_pb::GetUpdatesCallerInfo::UNKNOWN;
- last_successful_sync_time_ = now;
- if (next_retry_time_ < now)
- next_retry_time_ = base::TimeTicks();
+ // If a retry was required, we've just serviced it. Unset the flag.
+ if (IsRetryRequired())
+ current_retry_time_ = base::TimeTicks();
// A successful cycle while invalidations are enabled puts us back into sync.
invalidations_out_of_sync_ = !invalidations_enabled_;
@@ -239,6 +245,29 @@ void NudgeTracker::FillProtoMessage(
type_trackers_.find(type)->second.FillGetUpdatesTriggersMessage(msg);
}
+void NudgeTracker::SetSyncCycleStartTime(base::TimeTicks now) {
+ sync_cycle_start_time_ = now;
+
+ // If current_retry_time_ is still set, that means we have an old retry time
+ // left over from a previous cycle. For example, maybe we tried to perform
+ // this retry, hit a network connection error, and now we're in exponential
+ // backoff. In that case, we want this sync cycle to include the GU retry
+ // flag so we leave this variable set regardless of whether or not there is an
+ // overwrite pending.
+ if (!current_retry_time_.is_null()) {
+ return;
+ }
+
+ // If do not have a current_retry_time_, but we do have a next_retry_time_ and
+ // it is ready to go, then we set it as the current_retry_time_. It will stay
+ // there until a GU retry has succeeded.
+ if (!next_retry_time_.is_null() &&
+ next_retry_time_ < sync_cycle_start_time_) {
+ current_retry_time_ = next_retry_time_;
+ next_retry_time_ = base::TimeTicks();
+ }
+}
+
void NudgeTracker::SetHintBufferSize(size_t size) {
for (TypeTrackerMap::iterator it = type_trackers_.begin();
it != type_trackers_.end(); ++it) {
@@ -246,5 +275,9 @@ void NudgeTracker::SetHintBufferSize(size_t size) {
}
}
+void NudgeTracker::SetNextRetryTime(base::TimeTicks retry_time) {
+ next_retry_time_ = retry_time;
+}
+
} // namespace sessions
} // namespace syncer
« no previous file with comments | « sync/sessions/nudge_tracker.h ('k') | sync/sessions/nudge_tracker_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698