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

Side by Side 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: 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "sync/engine/get_updates_processor.h" 5 #include "sync/engine/get_updates_processor.h"
6 6
7 #include <map> 7 #include <map>
8 8
9 #include "base/debug/trace_event.h" 9 #include "base/debug/trace_event.h"
10 #include "sync/engine/get_updates_delegate.h" 10 #include "sync/engine/get_updates_delegate.h"
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 sync_pb::GetUpdatesMessage* get_updates = message->mutable_get_updates(); 171 sync_pb::GetUpdatesMessage* get_updates = message->mutable_get_updates();
172 172
173 for (ModelTypeSet::Iterator it = gu_types.First(); it.Good(); it.Inc()) { 173 for (ModelTypeSet::Iterator it = gu_types.First(); it.Good(); it.Inc()) {
174 UpdateHandlerMap::iterator handler_it = update_handler_map_->find(it.Get()); 174 UpdateHandlerMap::iterator handler_it = update_handler_map_->find(it.Get());
175 DCHECK(handler_it != update_handler_map_->end()) 175 DCHECK(handler_it != update_handler_map_->end())
176 << "Failed to look up handler for " << ModelTypeToString(it.Get()); 176 << "Failed to look up handler for " << ModelTypeToString(it.Get());
177 sync_pb::DataTypeProgressMarker* progress_marker = 177 sync_pb::DataTypeProgressMarker* progress_marker =
178 get_updates->add_from_progress_marker(); 178 get_updates->add_from_progress_marker();
179 handler_it->second->GetDownloadProgress(progress_marker); 179 handler_it->second->GetDownloadProgress(progress_marker);
180 progress_marker->clear_gc_directive(); 180 progress_marker->clear_gc_directive();
181
182 sync_pb::DataTypeContext context;
183 handler_it->second->GetDataTypeContext(&context);
184 if (!context.context().empty())
185 get_updates->add_client_contexts()->Swap(&context);
181 } 186 }
187
182 delegate_.HelpPopulateGuMessage(get_updates); 188 delegate_.HelpPopulateGuMessage(get_updates);
183 } 189 }
184 190
185 SyncerError GetUpdatesProcessor::ExecuteDownloadUpdates( 191 SyncerError GetUpdatesProcessor::ExecuteDownloadUpdates(
186 ModelTypeSet request_types, 192 ModelTypeSet request_types,
187 sessions::SyncSession* session, 193 sessions::SyncSession* session,
188 sync_pb::ClientToServerMessage* msg) { 194 sync_pb::ClientToServerMessage* msg) {
189 sync_pb::ClientToServerResponse update_response; 195 sync_pb::ClientToServerResponse update_response;
190 sessions::StatusController* status = session->mutable_status_controller(); 196 sessions::StatusController* status = session->mutable_status_controller();
191 bool need_encryption_key = ShouldRequestEncryptionKey(session->context()); 197 bool need_encryption_key = ShouldRequestEncryptionKey(session->context());
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 } else { 313 } else {
308 DLOG(WARNING) 314 DLOG(WARNING)
309 << "Ignoring received updates of a type we can't handle. " 315 << "Ignoring received updates of a type we can't handle. "
310 << "Type is: " << ModelTypeToString(type); 316 << "Type is: " << ModelTypeToString(type);
311 continue; 317 continue;
312 } 318 }
313 } 319 }
314 DCHECK(progress_marker_iter == progress_index_by_type.end() && 320 DCHECK(progress_marker_iter == progress_index_by_type.end() &&
315 updates_iter == updates_by_type.end()); 321 updates_iter == updates_by_type.end());
316 322
323 for (int i = 0; i < gu_response.context_mutations_size(); ++i) {
324 const sync_pb::DataTypeContext& context = gu_response.context_mutations(i);
325 syncer::ModelType type =
326 GetModelTypeFromSpecificsFieldNumber(context.type());
327 if (!syncer::IsRealDataType(type)) {
328 DLOG(WARNING) << "Received datatype context mutation with invalid type.";
329 continue;
330 }
331
332 UpdateHandlerMap::iterator update_handler_iter =
333 update_handler_map_->find(type);
334
335 if (update_handler_iter != update_handler_map_->end()) {
336 update_handler_iter->second->ProcessDataTypeContextMutation(context);
337 } else {
338 DLOG(WARNING)
339 << "Ignoring received context mutations of a type we can't handle. "
340 << "Type is: " << ModelTypeToString(type);
341 continue;
342 }
343 }
344
317 return true; 345 return true;
318 } 346 }
319 347
320 void GetUpdatesProcessor::ApplyUpdates( 348 void GetUpdatesProcessor::ApplyUpdates(
321 ModelTypeSet gu_types, 349 ModelTypeSet gu_types,
322 sessions::StatusController* status_controller) { 350 sessions::StatusController* status_controller) {
323 delegate_.ApplyUpdates(gu_types, status_controller, update_handler_map_); 351 delegate_.ApplyUpdates(gu_types, status_controller, update_handler_map_);
324 } 352 }
325 353
326 void GetUpdatesProcessor::CopyClientDebugInfo( 354 void GetUpdatesProcessor::CopyClientDebugInfo(
327 sessions::DebugInfoGetter* debug_info_getter, 355 sessions::DebugInfoGetter* debug_info_getter,
328 sync_pb::DebugInfo* debug_info) { 356 sync_pb::DebugInfo* debug_info) {
329 DVLOG(1) << "Copying client debug info to send."; 357 DVLOG(1) << "Copying client debug info to send.";
330 debug_info_getter->GetDebugInfo(debug_info); 358 debug_info_getter->GetDebugInfo(debug_info);
331 } 359 }
332 360
333 } // namespace syncer 361 } // namespace syncer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698