| 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) {
|
|
|