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

Unified Diff: sync/engine/directory_update_handler.cc

Issue 215973007: [Sync] Add plumbing of context from client to server (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix compile Created 6 years, 9 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/engine/directory_update_handler.h ('k') | sync/engine/directory_update_handler_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sync/engine/directory_update_handler.cc
diff --git a/sync/engine/directory_update_handler.cc b/sync/engine/directory_update_handler.cc
index 9d97765195fc1064861d9cef1064b90d276b2a6d..55095202fa800d363e1b9d2fd931f10df3273007 100644
--- a/sync/engine/directory_update_handler.cc
+++ b/sync/engine/directory_update_handler.cc
@@ -31,8 +31,15 @@ void DirectoryUpdateHandler::GetDownloadProgress(
dir_->GetDownloadProgress(type_, progress_marker);
}
+void DirectoryUpdateHandler::GetDataTypeContext(
+ sync_pb::DataTypeContext* context) const {
+ syncable::ModelNeutralWriteTransaction trans(FROM_HERE, SYNCER, dir_);
+ dir_->GetDataTypeContext(&trans, type_, context);
+}
+
void 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_);
@@ -42,6 +49,20 @@ void DirectoryUpdateHandler::ProcessGetUpdatesResponse(
ExpireEntriesIfNeeded(&trans, progress_marker);
UpdateProgressMarker(progress_marker);
}
+
+ if (mutated_context.has_context()) {
+ sync_pb::DataTypeContext local_context;
+ dir_->GetDataTypeContext(&trans, type_, &local_context);
+
+ // Only update the local context if it is still relevant. If the local
+ // version is higher, it means a local change happened while the mutation
+ // was in flight, and the local context takes priority.
+ if (mutated_context.version() >= local_context.version() &&
+ local_context.context() != mutated_context.context()) {
+ dir_->SetDataTypeContext(&trans, type_, mutated_context);
+ // TODO(zea): trigger the datatype's UpdateDataTypeContext method.
+ }
+ }
}
void DirectoryUpdateHandler::ApplyUpdates(sessions::StatusController* status) {
« no previous file with comments | « sync/engine/directory_update_handler.h ('k') | sync/engine/directory_update_handler_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698