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

Unified Diff: sync/engine/get_updates_processor.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_unittest.cc ('k') | sync/engine/get_updates_processor_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sync/engine/get_updates_processor.cc
diff --git a/sync/engine/get_updates_processor.cc b/sync/engine/get_updates_processor.cc
index eb1d7be2e82987f9cff188b52a485e0f260421d7..d0aa9b989fd5c2c1f642211e98f0b2a1988a4762 100644
--- a/sync/engine/get_updates_processor.cc
+++ b/sync/engine/get_updates_processor.cc
@@ -60,17 +60,16 @@ SyncerError HandleGetEncryptionKeyResponse(
// divides them according to their type. Outputs a map from model types to
// received SyncEntities. The output map will have entries (possibly empty)
// for all types in |requested_types|.
-void PartitionUpdatesByType(
- const sync_pb::GetUpdatesResponse& updates,
- ModelTypeSet requested_types,
- TypeSyncEntityMap* updates_by_type) {
- int update_count = updates.entries().size();
+void PartitionUpdatesByType(const sync_pb::GetUpdatesResponse& gu_response,
+ ModelTypeSet requested_types,
+ TypeSyncEntityMap* updates_by_type) {
+ int update_count = gu_response.entries().size();
for (ModelTypeSet::Iterator it = requested_types.First();
it.Good(); it.Inc()) {
updates_by_type->insert(std::make_pair(it.Get(), SyncEntityList()));
}
for (int i = 0; i < update_count; ++i) {
- const sync_pb::SyncEntity& update = updates.entries(i);
+ const sync_pb::SyncEntity& update = gu_response.entries(i);
ModelType type = GetModelType(update);
if (!IsRealDataType(type)) {
NOTREACHED() << "Received update with invalid type.";
@@ -111,6 +110,27 @@ void PartitionProgressMarkersByType(
}
}
+void PartitionContextMutationsByType(
+ const sync_pb::GetUpdatesResponse& gu_response,
+ ModelTypeSet request_types,
+ TypeToIndexMap* index_map) {
+ for (int i = 0; i < gu_response.context_mutations_size(); ++i) {
+ int field_number = gu_response.context_mutations(i).data_type_id();
+ ModelType model_type = GetModelTypeFromSpecificsFieldNumber(field_number);
+ if (!IsRealDataType(model_type)) {
+ DLOG(WARNING) << "Unknown field number " << field_number;
+ continue;
+ }
+ if (!request_types.Has(model_type)) {
+ DLOG(WARNING)
+ << "Skipping unexpected context mutation for non-enabled type "
+ << ModelTypeToString(model_type);
+ continue;
+ }
+ index_map->insert(std::make_pair(model_type, i));
+ }
+}
+
// Initializes the parts of the GetUpdatesMessage that depend on shared state,
// like the ShouldRequestEncryptionKey() status. This is kept separate from the
// other of the message-building functions to make the rest of the code easier
@@ -178,7 +198,13 @@ void GetUpdatesProcessor::PrepareGetUpdates(
get_updates->add_from_progress_marker();
handler_it->second->GetDownloadProgress(progress_marker);
progress_marker->clear_gc_directive();
+
+ sync_pb::DataTypeContext context;
+ handler_it->second->GetDataTypeContext(&context);
+ if (!context.context().empty())
+ get_updates->add_client_contexts()->Swap(&context);
}
+
delegate_.HelpPopulateGuMessage(get_updates);
}
@@ -286,6 +312,9 @@ bool GetUpdatesProcessor::ProcessGetUpdatesResponse(
return false;
}
+ TypeToIndexMap context_by_type;
+ PartitionContextMutationsByType(gu_response, gu_types, &context_by_type);
+
// Iterate over these maps in parallel, processing updates for each type.
TypeToIndexMap::iterator progress_marker_iter =
progress_index_by_type.begin();
@@ -299,9 +328,15 @@ bool GetUpdatesProcessor::ProcessGetUpdatesResponse(
UpdateHandlerMap::iterator update_handler_iter =
update_handler_map_->find(type);
+ sync_pb::DataTypeContext context;
+ TypeToIndexMap::iterator context_iter = context_by_type.find(type);
+ if (context_iter != context_by_type.end())
+ context.CopyFrom(gu_response.context_mutations(context_iter->second));
+
if (update_handler_iter != update_handler_map_->end()) {
update_handler_iter->second->ProcessGetUpdatesResponse(
gu_response.new_progress_marker(progress_marker_iter->second),
+ context,
updates_iter->second,
status_controller);
} else {
« no previous file with comments | « sync/engine/directory_update_handler_unittest.cc ('k') | sync/engine/get_updates_processor_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698