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

Unified Diff: sync/test/fake_server/unique_client_entity.cc

Issue 414953002: Make client tag IDs consistent in sync fake server (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 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
Index: sync/test/fake_server/unique_client_entity.cc
diff --git a/sync/test/fake_server/unique_client_entity.cc b/sync/test/fake_server/unique_client_entity.cc
index 39d3a4c23d04069c4672d3ca937db02b6fe31332..66f0d4f3d47e880f3b83e36ee4199507558647ec 100644
--- a/sync/test/fake_server/unique_client_entity.cc
+++ b/sync/test/fake_server/unique_client_entity.cc
@@ -28,9 +28,7 @@ FakeServerEntity* UniqueClientEntity::CreateNew(
<< "A UniqueClientEntity must have a client-defined unique tag.";
ModelType model_type =
syncer::GetModelTypeFromSpecifics(client_entity.specifics());
- string id = client_entity.version() == 0 ?
- FakeServerEntity::CreateId(model_type, base::GenerateGUID()) :
- client_entity.id_string();
+ string id = EffectiveIdForClientTaggedEntity(client_entity);
return new UniqueClientEntity(id,
model_type,
client_entity.version(),
@@ -45,7 +43,8 @@ FakeServerEntity* UniqueClientEntity::CreateNew(
FakeServerEntity* UniqueClientEntity::CreateUpdatedVersion(
const sync_pb::SyncEntity& client_entity,
FakeServerEntity* current_server_entity) {
- return new UniqueClientEntity(client_entity.id_string(),
+ string id = EffectiveIdForClientTaggedEntity(client_entity);
+ return new UniqueClientEntity(id,
current_server_entity->GetModelType(),
client_entity.version(),
client_entity.name(),
@@ -55,6 +54,14 @@ FakeServerEntity* UniqueClientEntity::CreateUpdatedVersion(
client_entity.mtime());
}
+// static
+std::string UniqueClientEntity::EffectiveIdForClientTaggedEntity(
+ const sync_pb::SyncEntity& entity) {
+ return FakeServerEntity::CreateId(
+ syncer::GetModelTypeFromSpecifics(entity.specifics()),
+ entity.client_defined_unique_tag());
+}
+
UniqueClientEntity::UniqueClientEntity(
const string& id,
const ModelType& model_type,
« sync/test/fake_server/fake_server.cc ('K') | « sync/test/fake_server/unique_client_entity.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698