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

Unified Diff: sync/engine/model_type_worker.cc

Issue 1893813002: [Sync] Adjust new entity version before commit. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@DeviceInfoFixes
Patch Set: Rebase Created 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sync/engine/model_type_worker.h ('k') | sync/engine/model_type_worker_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sync/engine/model_type_worker.cc
diff --git a/sync/engine/model_type_worker.cc b/sync/engine/model_type_worker.cc
index 4b1d2f7ec6c1d019669de0cca372c47686e700b3..a34b94cc58e4b7f2c9e84291cde40ef38acbf442 100644
--- a/sync/engine/model_type_worker.cc
+++ b/sync/engine/model_type_worker.cc
@@ -237,8 +237,8 @@ std::unique_ptr<CommitContribution> ModelTypeWorker::GetContribution(
sync_pb::SyncEntity* commit_entity = commit_entities.Add();
int64_t sequence_number = -1;
- entity->PrepareCommitProto(commit_entity, &sequence_number);
- HelpInitializeCommitEntity(commit_entity);
+ entity->PopulateCommitProto(commit_entity, &sequence_number);
+ AdjustCommitProto(commit_entity);
sequence_numbers.push_back(sequence_number);
space_remaining--;
@@ -301,13 +301,12 @@ bool ModelTypeWorker::CanCommitItems() const {
return true;
}
-void ModelTypeWorker::HelpInitializeCommitEntity(
- sync_pb::SyncEntity* sync_entity) {
+void ModelTypeWorker::AdjustCommitProto(sync_pb::SyncEntity* sync_entity) {
DCHECK(CanCommitItems());
// Initial commits need our help to generate a client ID.
- if (!sync_entity->has_id_string()) {
- DCHECK_EQ(kUncommittedVersion, sync_entity->version());
+ if (sync_entity->version() == kUncommittedVersion) {
+ DCHECK(!sync_entity->has_id_string());
// TODO(stanisc): This is incorrect for bookmarks for two reasons:
// 1) Won't be able to match previously committed bookmarks to the ones
// with server ID.
@@ -316,6 +315,9 @@ void ModelTypeWorker::HelpInitializeCommitEntity(
// would result in a duplication.
// We should generate client ID on the frontend side instead.
sync_entity->set_id_string(base::GenerateGUID());
+ sync_entity->set_version(0);
+ } else {
+ DCHECK(sync_entity->has_id_string());
}
// Encrypt the specifics and hide the title if necessary.
« no previous file with comments | « sync/engine/model_type_worker.h ('k') | sync/engine/model_type_worker_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698