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

Unified Diff: components/sync/engine_impl/worker_entity_tracker.cc

Issue 2562673003: [Sync] WorkerEntityTracker: Ensure that update and commit response have valid id. (Closed)
Patch Set: Created 4 years 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 | « components/sync/engine_impl/model_type_worker.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/sync/engine_impl/worker_entity_tracker.cc
diff --git a/components/sync/engine_impl/worker_entity_tracker.cc b/components/sync/engine_impl/worker_entity_tracker.cc
index a6ba849d5381456907e2cd877ba2ef4d56a3fe64..8632e291579bc76960c53f2c65d1817a947b45f0 100644
--- a/components/sync/engine_impl/worker_entity_tracker.cc
+++ b/components/sync/engine_impl/worker_entity_tracker.cc
@@ -29,13 +29,10 @@ void WorkerEntityTracker::PopulateCommitProto(
sync_pb::SyncEntity* commit_entity) const {
DCHECK(HasPendingCommit());
- if (!id_.empty()) {
- commit_entity->set_id_string(id_);
- }
-
const EntityData& entity = pending_commit_->entity.value();
DCHECK_EQ(client_tag_hash_, entity.client_tag_hash);
+ commit_entity->set_id_string(id_);
commit_entity->set_client_defined_unique_tag(client_tag_hash_);
commit_entity->set_version(base_version_);
commit_entity->set_deleted(entity.is_deleted());
@@ -111,6 +108,7 @@ void WorkerEntityTracker::ReceiveCommitResponse(CommitResponseData* ack) {
<< " id: " << id_;
// Commit responses, especially after the first commit, can update our ID.
+ DCHECK(!ack->id.empty());
id_ = ack->id;
highest_commit_response_version_ = ack->response_version;
@@ -132,6 +130,7 @@ void WorkerEntityTracker::ReceiveUpdate(const UpdateResponseData& update) {
return;
highest_gu_response_version_ = update.response_version;
+ DCHECK(!update.entity->id.empty());
id_ = update.entity->id;
// Got an applicable update newer than any pending updates. It must be safe
« no previous file with comments | « components/sync/engine_impl/model_type_worker.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698