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

Unified Diff: sync/engine/directory_update_handler.cc

Issue 232003005: [Sync] Add support for retrying a getupdates due to a context change (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments Created 6 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
Index: sync/engine/directory_update_handler.cc
diff --git a/sync/engine/directory_update_handler.cc b/sync/engine/directory_update_handler.cc
index 55095202fa800d363e1b9d2fd931f10df3273007..72cdf121d213350f16151377e93c00b31b19f9d4 100644
--- a/sync/engine/directory_update_handler.cc
+++ b/sync/engine/directory_update_handler.cc
@@ -37,19 +37,12 @@ void DirectoryUpdateHandler::GetDataTypeContext(
dir_->GetDataTypeContext(&trans, type_, context);
}
-void DirectoryUpdateHandler::ProcessGetUpdatesResponse(
+SyncerError DirectoryUpdateHandler::ProcessGetUpdatesResponse(
const sync_pb::DataTypeProgressMarker& progress_marker,
const sync_pb::DataTypeContext& mutated_context,
const SyncEntityList& applicable_updates,
sessions::StatusController* status) {
syncable::ModelNeutralWriteTransaction trans(FROM_HERE, SYNCER, dir_);
- UpdateSyncEntities(&trans, applicable_updates, status);
-
- if (IsValidProgressMarker(progress_marker)) {
- ExpireEntriesIfNeeded(&trans, progress_marker);
- UpdateProgressMarker(progress_marker);
- }
-
if (mutated_context.has_context()) {
sync_pb::DataTypeContext local_context;
dir_->GetDataTypeContext(&trans, type_, &local_context);
@@ -61,8 +54,21 @@ void DirectoryUpdateHandler::ProcessGetUpdatesResponse(
local_context.context() != mutated_context.context()) {
dir_->SetDataTypeContext(&trans, type_, mutated_context);
// TODO(zea): trigger the datatype's UpdateDataTypeContext method.
+ } else if (mutated_context.version() < local_context.version()) {
+ // A GetUpdates using the old context was in progress when the context was
+ // set. Fail this get updates cycle, to force a retry.
+ DVLOG(1) << "GU Context conflict detected, forcing GU retry.";
+ return DATATYPE_TRIGGERED_RETRY;
}
}
+
+ UpdateSyncEntities(&trans, applicable_updates, status);
+
+ if (IsValidProgressMarker(progress_marker)) {
+ ExpireEntriesIfNeeded(&trans, progress_marker);
+ UpdateProgressMarker(progress_marker);
+ }
+ return SYNCER_OK;
}
void DirectoryUpdateHandler::ApplyUpdates(sessions::StatusController* status) {

Powered by Google App Engine
This is Rietveld 408576698