Chromium Code Reviews| Index: components/sync/engine_impl/model_type_worker.cc |
| diff --git a/components/sync/engine_impl/model_type_worker.cc b/components/sync/engine_impl/model_type_worker.cc |
| index 25422f64b1d5263f3a9f4e73fd65495db997067b..12d0e3fc680d1a6f73315627690629af303ed158 100644 |
| --- a/components/sync/engine_impl/model_type_worker.cc |
| +++ b/components/sync/engine_impl/model_type_worker.cc |
| @@ -26,11 +26,13 @@ namespace syncer { |
| ModelTypeWorker::ModelTypeWorker( |
| ModelType type, |
| + NonBlockingTypeDebugInfoEmitter* debug_info_emitter, |
| const sync_pb::ModelTypeState& initial_state, |
| std::unique_ptr<Cryptographer> cryptographer, |
| NudgeHandler* nudge_handler, |
| std::unique_ptr<ModelTypeProcessor> model_type_processor) |
| : type_(type), |
| + debug_info_emitter_(debug_info_emitter), |
| model_type_state_(initial_state), |
| model_type_processor_(std::move(model_type_processor)), |
| cryptographer_(std::move(cryptographer)), |
| @@ -96,6 +98,9 @@ SyncerError ModelTypeWorker::ProcessGetUpdatesResponse( |
| *model_type_state_.mutable_type_context() = mutated_context; |
| *model_type_state_.mutable_progress_marker() = progress_marker; |
| + UpdateCounters* counters = debug_info_emitter_->GetMutableUpdateCounters(); |
| + counters->num_updates_received += applicable_updates.size(); |
| + |
| for (const sync_pb::SyncEntity* update_entity : applicable_updates) { |
| // Skip updates for permanent folders. |
| // TODO(crbug.com/516866): might need to handle this for hierarchical types. |
| @@ -122,6 +127,15 @@ SyncerError ModelTypeWorker::ProcessGetUpdatesResponse( |
| WorkerEntityTracker* entity = GetOrCreateEntityTracker(data); |
| + if (!entity->UpdateContainsNewVersion(response_data)) { |
| + status->increment_num_reflected_updates_downloaded_by(1); |
| + ++counters->num_reflected_updates_received; |
| + } |
| + if (update_entity->deleted()) { |
| + status->increment_num_tombstone_updates_downloaded_by(1); |
| + ++counters->num_tombstone_updates_received; |
| + } |
| + |
|
Gang Wu
2016/10/17 19:26:30
same as https://cs.chromium.org/chromium/src/compo
|
| // Deleted entities must use the default instance of EntitySpecifics in |
| // order for EntityData to correctly reflect that they are deleted. |
| const sync_pb::EntitySpecifics& specifics = |
| @@ -152,6 +166,7 @@ SyncerError ModelTypeWorker::ProcessGetUpdatesResponse( |
| } |
| } |
| + debug_info_emitter_->EmitUpdateCountersUpdate(); |
| return SYNCER_OK; |
| } |
| @@ -179,6 +194,11 @@ void ModelTypeWorker::ApplyPendingUpdates() { |
| << base::StringPrintf("Delivering %" PRIuS " applicable updates.", |
| pending_updates_.size()); |
| model_type_processor_->OnUpdateReceived(model_type_state_, pending_updates_); |
| + |
| + // The new UpdateCounter counters. |
| + UpdateCounters* counters = debug_info_emitter_->GetMutableUpdateCounters(); |
| + counters->num_updates_applied += pending_updates_.size(); |
|
pavely
2016/10/19 18:18:59
Should there be Emit... call for this counter chan
Gang Wu
2016/10/20 21:35:36
Done.
|
| + |
| pending_updates_.clear(); |
| } |
| @@ -229,7 +249,8 @@ std::unique_ptr<CommitContribution> ModelTypeWorker::GetContribution( |
| return std::unique_ptr<CommitContribution>(); |
| return base::MakeUnique<NonBlockingTypeCommitContribution>( |
| - model_type_state_.type_context(), commit_entities, this); |
| + model_type_state_.type_context(), commit_entities, this, |
| + debug_info_emitter_); |
| } |
| void ModelTypeWorker::OnCommitResponse(CommitResponseDataList* response_list) { |