diff options
author | rlarocque@chromium.org <rlarocque@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-06-26 22:58:00 +0000 |
---|---|---|
committer | rlarocque@chromium.org <rlarocque@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-06-26 22:58:00 +0000 |
commit | 65e022eeecdde17380365097d983b5cb2499bdf0 (patch) | |
tree | f13891293c73c03bf55406dcc8ede90d6a7833ba /sync/test | |
parent | c536d0ad364d28121e47c0d0237a0cc462a79342 (diff) | |
download | chromium_src-65e022eeecdde17380365097d983b5cb2499bdf0.zip chromium_src-65e022eeecdde17380365097d983b5cb2499bdf0.tar.gz chromium_src-65e022eeecdde17380365097d983b5cb2499bdf0.tar.bz2 |
sync: Stop supporting parent IDs for some types
Makes non-bookmarks nodes no longer send up a parent ID for each of
their commits. This is part of an update to the sync protocol that will
eventually allow both the client and server to remove support for type
root nodes.
Note that the client still expects to receive type root nodes from the
server. That expectation will be removed in a future CL.
BUG=373869
Review URL: https://codereview.chromium.org/310993002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@280148 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'sync/test')
-rw-r--r-- | sync/test/fake_server/fake_server_entity.cc | 11 | ||||
-rw-r--r-- | sync/test/fake_server/fake_server_entity.h | 9 | ||||
-rw-r--r-- | sync/test/fake_server/permanent_entity.cc | 2 | ||||
-rw-r--r-- | sync/test/fake_server/unique_client_entity.cc | 9 | ||||
-rw-r--r-- | sync/test/fake_server/unique_client_entity.h | 4 |
5 files changed, 20 insertions, 15 deletions
diff --git a/sync/test/fake_server/fake_server_entity.cc b/sync/test/fake_server/fake_server_entity.cc index b2aa6f9..602a266 100644 --- a/sync/test/fake_server/fake_server_entity.cc +++ b/sync/test/fake_server/fake_server_entity.cc @@ -64,6 +64,13 @@ string FakeServerEntity::CreateId(const ModelType& model_type, } // static +std::string FakeServerEntity::GetTopLevelId(const ModelType& model_type) { + return FakeServerEntity::CreateId( + model_type, + syncer::ModelTypeToRootTag(model_type)); +} + +// static ModelType FakeServerEntity::GetModelTypeFromId(const string& id) { vector<string> tokens; size_t token_count = Tokenize(id, kIdSeparator, &tokens); @@ -80,8 +87,8 @@ FakeServerEntity::FakeServerEntity(const string& id, const ModelType& model_type, int64 version, const string& name) - : id_(id), - model_type_(model_type), + : model_type_(model_type), + id_(id), version_(version), name_(name) {} diff --git a/sync/test/fake_server/fake_server_entity.h b/sync/test/fake_server/fake_server_entity.h index 7f30bb0..b7c5990 100644 --- a/sync/test/fake_server/fake_server_entity.h +++ b/sync/test/fake_server/fake_server_entity.h @@ -26,6 +26,9 @@ class FakeServerEntity { static std::string CreateId(const syncer::ModelType& model_type, const std::string& inner_id); + // Returns the ID string of the top level node for the specified type. + static std::string GetTopLevelId(const syncer::ModelType& model_type); + virtual ~FakeServerEntity(); const std::string& GetId() const; syncer::ModelType GetModelType() const; @@ -51,13 +54,13 @@ class FakeServerEntity { void SerializeBaseProtoFields(sync_pb::SyncEntity* sync_entity); + // The ModelType that categorizes this entity. + syncer::ModelType model_type_; + private: // The entity's ID. std::string id_; - // The ModelType that categorizes this entity. - syncer::ModelType model_type_; - // The version of this entity. int64 version_; diff --git a/sync/test/fake_server/permanent_entity.cc b/sync/test/fake_server/permanent_entity.cc index 3ceb5c8..5b1631c 100644 --- a/sync/test/fake_server/permanent_entity.cc +++ b/sync/test/fake_server/permanent_entity.cc @@ -56,7 +56,7 @@ FakeServerEntity* PermanentEntity::CreateTopLevel(const ModelType& model_type) { << "invalid."; string server_tag = syncer::ModelTypeToRootTag(model_type); string name = syncer::ModelTypeToString(model_type); - string id = FakeServerEntity::CreateId(model_type, server_tag); + string id = FakeServerEntity::GetTopLevelId(model_type); sync_pb::EntitySpecifics entity_specifics; AddDefaultFieldValue(model_type, &entity_specifics); return new PermanentEntity(id, diff --git a/sync/test/fake_server/unique_client_entity.cc b/sync/test/fake_server/unique_client_entity.cc index e9ce2e9..39d3a4c 100644 --- a/sync/test/fake_server/unique_client_entity.cc +++ b/sync/test/fake_server/unique_client_entity.cc @@ -11,6 +11,7 @@ #include "sync/internal_api/public/base/model_type.h" #include "sync/protocol/sync.pb.h" #include "sync/test/fake_server/fake_server_entity.h" +#include "sync/test/fake_server/permanent_entity.h" using std::string; @@ -34,7 +35,6 @@ FakeServerEntity* UniqueClientEntity::CreateNew( model_type, client_entity.version(), client_entity.name(), - client_entity.parent_id_string(), client_entity.client_defined_unique_tag(), client_entity.specifics(), client_entity.ctime(), @@ -49,7 +49,6 @@ FakeServerEntity* UniqueClientEntity::CreateUpdatedVersion( current_server_entity->GetModelType(), client_entity.version(), client_entity.name(), - client_entity.parent_id_string(), client_entity.client_defined_unique_tag(), client_entity.specifics(), client_entity.ctime(), @@ -61,13 +60,11 @@ UniqueClientEntity::UniqueClientEntity( const ModelType& model_type, int64 version, const string& name, - const string& parent_id, const string& client_defined_unique_tag, const sync_pb::EntitySpecifics& specifics, int64 creation_time, int64 last_modified_time) : FakeServerEntity(id, model_type, version, name), - parent_id_(parent_id), client_defined_unique_tag_(client_defined_unique_tag), specifics_(specifics), creation_time_(creation_time), @@ -76,7 +73,7 @@ UniqueClientEntity::UniqueClientEntity( string UniqueClientEntity::GetParentId() const { // The parent ID for this type of entity should always be its ModelType's // root node. - return parent_id_; + return FakeServerEntity::GetTopLevelId(model_type_); } sync_pb::SyncEntity* UniqueClientEntity::SerializeAsProto() { @@ -86,7 +83,7 @@ sync_pb::SyncEntity* UniqueClientEntity::SerializeAsProto() { sync_pb::EntitySpecifics* specifics = sync_entity->mutable_specifics(); specifics->CopyFrom(specifics_); - sync_entity->set_parent_id_string(parent_id_); + sync_entity->set_parent_id_string(GetParentId()); sync_entity->set_client_defined_unique_tag(client_defined_unique_tag_); sync_entity->set_ctime(creation_time_); sync_entity->set_mtime(last_modified_time_); diff --git a/sync/test/fake_server/unique_client_entity.h b/sync/test/fake_server/unique_client_entity.h index 6e876e3..fecf044 100644 --- a/sync/test/fake_server/unique_client_entity.h +++ b/sync/test/fake_server/unique_client_entity.h @@ -39,14 +39,12 @@ class UniqueClientEntity : public FakeServerEntity { const syncer::ModelType& model_type, int64 version, const std::string& name, - const std::string& parent_id, const std::string& client_defined_unique_tag, const sync_pb::EntitySpecifics& specifics, int64 creation_time, int64 last_modified_time); - // All member values have equivalent fields in SyncEntity. - std::string parent_id_; + // These member values have equivalent fields in SyncEntity. std::string client_defined_unique_tag_; sync_pb::EntitySpecifics specifics_; int64 creation_time_; |