diff options
author | pvalenzuela@chromium.org <pvalenzuela@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-06-12 21:52:39 +0000 |
---|---|---|
committer | pvalenzuela@chromium.org <pvalenzuela@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-06-12 21:52:39 +0000 |
commit | 3cffc92be8ca603c05a2e0bea159b3c0ab6fc020 (patch) | |
tree | 0d5c5650f54ffb03bae1041547c53d3d7609a0d1 /sync | |
parent | 5ca367ff0b48d5933a5d9ccd2ebaad2aeb61ef8f (diff) | |
download | chromium_src-3cffc92be8ca603c05a2e0bea159b3c0ab6fc020.zip chromium_src-3cffc92be8ca603c05a2e0bea159b3c0ab6fc020.tar.gz chromium_src-3cffc92be8ca603c05a2e0bea159b3c0ab6fc020.tar.bz2 |
Remove redundant param from Sync FakeServer infra
The BookmarkEntity class always represents a Bookmark, so there's no
reason to have a ModelType param as part of its constructor.
BUG=NONE
Review URL: https://codereview.chromium.org/319823002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@276814 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'sync')
-rw-r--r-- | sync/test/fake_server/bookmark_entity.cc | 34 | ||||
-rw-r--r-- | sync/test/fake_server/bookmark_entity.h | 1 | ||||
-rw-r--r-- | sync/test/fake_server/bookmark_entity_builder.cc | 2 |
3 files changed, 17 insertions, 20 deletions
diff --git a/sync/test/fake_server/bookmark_entity.cc b/sync/test/fake_server/bookmark_entity.cc index a0f33d6..ae7a3b5 100644 --- a/sync/test/fake_server/bookmark_entity.cc +++ b/sync/test/fake_server/bookmark_entity.cc @@ -14,10 +14,17 @@ using std::string; -using syncer::ModelType; - namespace fake_server { +namespace { + +// Returns true if and only if |client_entity| is a bookmark. +bool IsBookmark(const sync_pb::SyncEntity& client_entity) { + return syncer::GetModelType(client_entity) == syncer::BOOKMARKS; +} + +} // namespace + BookmarkEntity::~BookmarkEntity() { } // static @@ -25,18 +32,15 @@ FakeServerEntity* BookmarkEntity::CreateNew( const sync_pb::SyncEntity& client_entity, const string& parent_id, const string& client_guid) { - if (client_entity.version() != 0) { - return NULL; - } + CHECK(client_entity.version() == 0) << "New entities must have version = 0."; + CHECK(IsBookmark(client_entity)) << "The given entity must be a bookmark."; - ModelType model_type = - syncer::GetModelTypeFromSpecifics(client_entity.specifics()); - string id = FakeServerEntity::CreateId(model_type, base::GenerateGUID()); + string id = FakeServerEntity::CreateId(syncer::BOOKMARKS, + base::GenerateGUID()); string originator_cache_guid = client_guid; string originator_client_item_id = client_entity.id_string(); return new BookmarkEntity(id, - model_type, client_entity.version(), client_entity.name(), originator_cache_guid, @@ -54,9 +58,9 @@ FakeServerEntity* BookmarkEntity::CreateUpdatedVersion( const sync_pb::SyncEntity& client_entity, FakeServerEntity* current_server_entity, const string& parent_id) { - if (client_entity.version() == 0 || current_server_entity == NULL) { - return NULL; - } + CHECK(client_entity.version() != 0) << "Existing entities must not have a " + << "version = 0."; + CHECK(IsBookmark(client_entity)) << "The given entity must be a bookmark."; BookmarkEntity* current_bookmark_entity = static_cast<BookmarkEntity*>(current_server_entity); @@ -64,11 +68,8 @@ FakeServerEntity* BookmarkEntity::CreateUpdatedVersion( current_bookmark_entity->originator_cache_guid_; string originator_client_item_id = current_bookmark_entity->originator_client_item_id_; - ModelType model_type = - syncer::GetModelTypeFromSpecifics(client_entity.specifics()); return new BookmarkEntity(client_entity.id_string(), - model_type, client_entity.version(), client_entity.name(), originator_cache_guid, @@ -83,7 +84,6 @@ FakeServerEntity* BookmarkEntity::CreateUpdatedVersion( BookmarkEntity::BookmarkEntity( const string& id, - const ModelType& model_type, int64 version, const string& name, const string& originator_cache_guid, @@ -94,7 +94,7 @@ BookmarkEntity::BookmarkEntity( const string& parent_id, int64 creation_time, int64 last_modified_time) - : FakeServerEntity(id, model_type, version, name), + : FakeServerEntity(id, syncer::BOOKMARKS, version, name), originator_cache_guid_(originator_cache_guid), originator_client_item_id_(originator_client_item_id), unique_position_(unique_position), diff --git a/sync/test/fake_server/bookmark_entity.h b/sync/test/fake_server/bookmark_entity.h index 3f108ba..388dba8 100644 --- a/sync/test/fake_server/bookmark_entity.h +++ b/sync/test/fake_server/bookmark_entity.h @@ -37,7 +37,6 @@ class BookmarkEntity : public FakeServerEntity { const std::string& parent_id); BookmarkEntity(const std::string& id, - const syncer::ModelType& model_type, int64 version, const std::string& name, const std::string& originator_cache_guid, diff --git a/sync/test/fake_server/bookmark_entity_builder.cc b/sync/test/fake_server/bookmark_entity_builder.cc index 04e7e97..5abad58 100644 --- a/sync/test/fake_server/bookmark_entity_builder.cc +++ b/sync/test/fake_server/bookmark_entity_builder.cc @@ -20,7 +20,6 @@ using std::string; -using syncer::ModelType; using syncer::syncable::GenerateSyncableBookmarkHash; // A version must be passed when creating a FakeServerEntity, but this value @@ -65,7 +64,6 @@ scoped_ptr<FakeServerEntity> BookmarkEntityBuilder::Build() { return make_scoped_ptr<FakeServerEntity>( new BookmarkEntity(id_, - model_type_, kUnusedVersion, name_, originator_cache_guid_, |