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

Unified Diff: sync/sessions/nudge_tracker.cc

Issue 387983004: sync: Support non-blocking initial sync in proto (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase + fix comment Created 6 years, 5 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
Index: sync/sessions/nudge_tracker.cc
diff --git a/sync/sessions/nudge_tracker.cc b/sync/sessions/nudge_tracker.cc
index e4ebc23940059566b1979c8196208c6cb222b422..a0bdbda7c801b36290f2d598bc54a45c7a6277c3 100644
--- a/sync/sessions/nudge_tracker.cc
+++ b/sync/sessions/nudge_tracker.cc
@@ -106,6 +106,12 @@ void NudgeTracker::RecordRemoteInvalidation(
tracker_it->second->RecordRemoteInvalidation(invalidation.Pass());
}
+void NudgeTracker::RecordInitialSyncRequired(syncer::ModelType type) {
+ TypeTrackerMap::iterator tracker_it = type_trackers_.find(type);
+ DCHECK(tracker_it != type_trackers_.end());
+ tracker_it->second->RecordInitialSyncRequired();
+}
+
void NudgeTracker::OnInvalidationsEnabled() {
invalidations_enabled_ = true;
}
@@ -228,6 +234,7 @@ sync_pb::GetUpdatesCallerInfo::GetUpdatesSource NudgeTracker::GetLegacySource()
bool has_invalidation_pending = false;
bool has_refresh_request_pending = false;
bool has_commit_pending = false;
+ bool is_initial_sync_required = false;
bool has_retry = IsRetryRequired();
for (TypeTrackerMap::const_iterator it = type_trackers_.begin();
@@ -242,12 +249,19 @@ sync_pb::GetUpdatesCallerInfo::GetUpdatesSource NudgeTracker::GetLegacySource()
if (!tracker.IsThrottled() && tracker.HasLocalChangePending()) {
has_commit_pending = true;
}
+ if (!tracker.IsThrottled() && tracker.IsInitialSyncRequired()) {
+ is_initial_sync_required = true;
+ }
}
if (has_invalidation_pending) {
return sync_pb::GetUpdatesCallerInfo::NOTIFICATION;
} else if (has_refresh_request_pending) {
return sync_pb::GetUpdatesCallerInfo::DATATYPE_REFRESH;
+ } else if (is_initial_sync_required) {
+ // Not quite accurate, but good enough for our purposes. This setting of
+ // SOURCE is just a backward-compatibility hack anyway.
+ return sync_pb::GetUpdatesCallerInfo::DATATYPE_REFRESH;
} else if (has_commit_pending) {
return sync_pb::GetUpdatesCallerInfo::LOCAL;
} else if (has_retry) {

Powered by Google App Engine
This is Rietveld 408576698