| Index: components/sync/engine_impl/net/loopback_server/bookmark_entity.cc
|
| diff --git a/components/sync/test/fake_server/bookmark_entity.cc b/components/sync/engine_impl/net/loopback_server/bookmark_entity.cc
|
| similarity index 72%
|
| copy from components/sync/test/fake_server/bookmark_entity.cc
|
| copy to components/sync/engine_impl/net/loopback_server/bookmark_entity.cc
|
| index b7e1eccd9852702661988a612df5279d4365b7f1..16213f861a2a704cd012a3221766d46e37f27be7 100644
|
| --- a/components/sync/test/fake_server/bookmark_entity.cc
|
| +++ b/components/sync/engine_impl/net/loopback_server/bookmark_entity.cc
|
| @@ -2,20 +2,21 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| -#include "components/sync/test/fake_server/bookmark_entity.h"
|
| +#include "components/sync/engine_impl/net/loopback_server/bookmark_entity.h"
|
|
|
| #include <stdint.h>
|
|
|
| +#include <memory>
|
| #include <string>
|
|
|
| #include "base/guid.h"
|
| #include "components/sync/base/model_type.h"
|
| +#include "components/sync/engine_impl/net/loopback_server/loopback_server_entity.h"
|
| #include "components/sync/protocol/sync.pb.h"
|
| -#include "components/sync/test/fake_server/fake_server_entity.h"
|
|
|
| using std::string;
|
|
|
| -namespace fake_server {
|
| +namespace syncer {
|
|
|
| namespace {
|
|
|
| @@ -26,10 +27,10 @@ bool IsBookmark(const sync_pb::SyncEntity& client_entity) {
|
|
|
| } // namespace
|
|
|
| -BookmarkEntity::~BookmarkEntity() {}
|
| +BookmarkEntity::~BookmarkEntity() { }
|
|
|
| // static
|
| -std::unique_ptr<FakeServerEntity> BookmarkEntity::CreateNew(
|
| +std::unique_ptr<LoopbackServerEntity> BookmarkEntity::CreateNew(
|
| const sync_pb::SyncEntity& client_entity,
|
| const string& parent_id,
|
| const string& client_guid) {
|
| @@ -37,21 +38,21 @@ std::unique_ptr<FakeServerEntity> BookmarkEntity::CreateNew(
|
| CHECK(IsBookmark(client_entity)) << "The given entity must be a bookmark.";
|
|
|
| const string id =
|
| - FakeServerEntity::CreateId(syncer::BOOKMARKS, base::GenerateGUID());
|
| + LoopbackServerEntity::CreateId(syncer::BOOKMARKS, base::GenerateGUID());
|
| const string originator_cache_guid = client_guid;
|
| const string originator_client_item_id = client_entity.id_string();
|
|
|
| - return std::unique_ptr<FakeServerEntity>(new BookmarkEntity(
|
| - id, client_entity.version(), client_entity.name(), originator_cache_guid,
|
| + return std::unique_ptr<LoopbackServerEntity>(new BookmarkEntity(
|
| + id, 0, client_entity.name(), originator_cache_guid,
|
| originator_client_item_id, client_entity.unique_position(),
|
| client_entity.specifics(), client_entity.folder(), parent_id,
|
| client_entity.ctime(), client_entity.mtime()));
|
| }
|
|
|
| // static
|
| -std::unique_ptr<FakeServerEntity> BookmarkEntity::CreateUpdatedVersion(
|
| +std::unique_ptr<LoopbackServerEntity> BookmarkEntity::CreateUpdatedVersion(
|
| const sync_pb::SyncEntity& client_entity,
|
| - const FakeServerEntity& current_server_entity,
|
| + const LoopbackServerEntity& current_server_entity,
|
| const string& parent_id) {
|
| CHECK(client_entity.version() != 0) << "Existing entities must not have a "
|
| << "version = 0.";
|
| @@ -64,14 +65,27 @@ std::unique_ptr<FakeServerEntity> BookmarkEntity::CreateUpdatedVersion(
|
| const string originator_client_item_id =
|
| current_bookmark_entity.originator_client_item_id_;
|
|
|
| - return std::unique_ptr<FakeServerEntity>(new BookmarkEntity(
|
| - client_entity.id_string(), client_entity.version(), client_entity.name(),
|
| + return std::unique_ptr<LoopbackServerEntity>(new BookmarkEntity(
|
| + client_entity.id_string(), 0, client_entity.name(),
|
| originator_cache_guid, originator_client_item_id,
|
| client_entity.unique_position(), client_entity.specifics(),
|
| client_entity.folder(), parent_id, client_entity.ctime(),
|
| client_entity.mtime()));
|
| }
|
|
|
| +// static
|
| +std::unique_ptr<LoopbackServerEntity> BookmarkEntity::CreateFromEntity(
|
| + const sync_pb::SyncEntity& client_entity) {
|
| + CHECK(IsBookmark(client_entity)) << "The given entity must be a bookmark.";
|
| +
|
| + return std::unique_ptr<LoopbackServerEntity>(new BookmarkEntity(
|
| + client_entity.id_string(), client_entity.version(), client_entity.name(),
|
| + client_entity.originator_cache_guid(),
|
| + client_entity.originator_client_item_id(),
|
| + client_entity.unique_position(), client_entity.specifics(),
|
| + client_entity.folder(), client_entity.parent_id_string(),
|
| + client_entity.ctime(), client_entity.mtime()));
|
| +}
|
| BookmarkEntity::BookmarkEntity(const string& id,
|
| int64_t version,
|
| const string& name,
|
| @@ -83,7 +97,7 @@ BookmarkEntity::BookmarkEntity(const string& id,
|
| const string& parent_id,
|
| int64_t creation_time,
|
| int64_t last_modified_time)
|
| - : FakeServerEntity(id, string(), syncer::BOOKMARKS, version, name),
|
| + : LoopbackServerEntity(id, syncer::BOOKMARKS, version, name),
|
| originator_cache_guid_(originator_cache_guid),
|
| originator_client_item_id_(originator_client_item_id),
|
| unique_position_(unique_position),
|
| @@ -108,7 +122,7 @@ string BookmarkEntity::GetParentId() const {
|
| }
|
|
|
| void BookmarkEntity::SerializeAsProto(sync_pb::SyncEntity* proto) const {
|
| - FakeServerEntity::SerializeBaseProtoFields(proto);
|
| + LoopbackServerEntity::SerializeBaseProtoFields(proto);
|
|
|
| proto->set_originator_cache_guid(originator_cache_guid_);
|
| proto->set_originator_client_item_id(originator_client_item_id_);
|
| @@ -124,4 +138,4 @@ bool BookmarkEntity::IsFolder() const {
|
| return is_folder_;
|
| }
|
|
|
| -} // namespace fake_server
|
| +} // namespace syncer
|
|
|