| Index: components/sync/engine_impl/net/loopback_server/permanent_entity.cc
|
| diff --git a/components/sync/test/fake_server/permanent_entity.cc b/components/sync/engine_impl/net/loopback_server/permanent_entity.cc
|
| similarity index 66%
|
| copy from components/sync/test/fake_server/permanent_entity.cc
|
| copy to components/sync/engine_impl/net/loopback_server/permanent_entity.cc
|
| index 23cccf3fef99bfd1646920bc3f07126ae9f665dd..d77ca1a9a186f420dd83a067ece37e2743ddbebb 100644
|
| --- a/components/sync/test/fake_server/permanent_entity.cc
|
| +++ b/components/sync/engine_impl/net/loopback_server/permanent_entity.cc
|
| @@ -2,15 +2,16 @@
|
| // 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/permanent_entity.h"
|
| +#include "components/sync/engine_impl/net/loopback_server/permanent_entity.h"
|
|
|
| +#include <memory>
|
| #include <string>
|
|
|
| #include "base/logging.h"
|
| #include "base/memory/ptr_util.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;
|
|
|
| @@ -20,12 +21,12 @@ using syncer::ModelType;
|
| // referred to as top level enities.
|
| static const char kRootParentTag[] = "0";
|
|
|
| -namespace fake_server {
|
| +namespace syncer {
|
|
|
| -PermanentEntity::~PermanentEntity() {}
|
| +PermanentEntity::~PermanentEntity() { }
|
|
|
| // static
|
| -std::unique_ptr<FakeServerEntity> PermanentEntity::Create(
|
| +std::unique_ptr<LoopbackServerEntity> PermanentEntity::Create(
|
| const ModelType& model_type,
|
| const string& server_tag,
|
| const string& name,
|
| @@ -39,49 +40,53 @@ std::unique_ptr<FakeServerEntity> PermanentEntity::Create(
|
| CHECK(parent_server_tag != kRootParentTag) << "Top-level entities should not "
|
| << "be created with this factory.";
|
|
|
| - string id = FakeServerEntity::CreateId(model_type, server_tag);
|
| - string parent_id = FakeServerEntity::CreateId(model_type, parent_server_tag);
|
| + string id = LoopbackServerEntity::CreateId(model_type, server_tag);
|
| + string parent_id = LoopbackServerEntity::CreateId(model_type,
|
| + parent_server_tag);
|
| sync_pb::EntitySpecifics entity_specifics;
|
| AddDefaultFieldValue(model_type, &entity_specifics);
|
| - return std::unique_ptr<FakeServerEntity>(new PermanentEntity(
|
| - id, model_type, name, parent_id, server_tag, entity_specifics));
|
| + return std::unique_ptr<LoopbackServerEntity>(new PermanentEntity(
|
| + id, 0, model_type, name, parent_id, server_tag, entity_specifics));
|
| }
|
|
|
| // static
|
| -std::unique_ptr<FakeServerEntity> PermanentEntity::CreateTopLevel(
|
| +std::unique_ptr<LoopbackServerEntity> PermanentEntity::CreateTopLevel(
|
| const ModelType& model_type) {
|
| CHECK(model_type != syncer::UNSPECIFIED) << "The entity's ModelType is "
|
| << "invalid.";
|
| string server_tag = syncer::ModelTypeToRootTag(model_type);
|
| string name = syncer::ModelTypeToString(model_type);
|
| - string id = FakeServerEntity::GetTopLevelId(model_type);
|
| + string id = LoopbackServerEntity::GetTopLevelId(model_type);
|
| sync_pb::EntitySpecifics entity_specifics;
|
| AddDefaultFieldValue(model_type, &entity_specifics);
|
| - return std::unique_ptr<FakeServerEntity>(new PermanentEntity(
|
| - id, model_type, name, kRootParentTag, server_tag, entity_specifics));
|
| + return std::unique_ptr<LoopbackServerEntity>(new PermanentEntity(
|
| + id, 0, model_type, name, kRootParentTag, server_tag, entity_specifics));
|
| }
|
|
|
| // static
|
| -std::unique_ptr<FakeServerEntity> PermanentEntity::CreateUpdatedNigoriEntity(
|
| +std::unique_ptr<LoopbackServerEntity>
|
| +PermanentEntity::CreateUpdatedNigoriEntity(
|
| const sync_pb::SyncEntity& client_entity,
|
| - const FakeServerEntity& current_server_entity) {
|
| - ModelType model_type = current_server_entity.model_type();
|
| + const LoopbackServerEntity& current_server_entity) {
|
| + ModelType model_type = current_server_entity.GetModelType();
|
| CHECK(model_type == syncer::NIGORI) << "This factory only supports NIGORI "
|
| << "entities.";
|
|
|
| - return base::WrapUnique<FakeServerEntity>(new PermanentEntity(
|
| - current_server_entity.id(), model_type, current_server_entity.GetName(),
|
| + return base::WrapUnique<LoopbackServerEntity>(new PermanentEntity(
|
| + current_server_entity.GetId(), current_server_entity.GetVersion(),
|
| + model_type, current_server_entity.GetName(),
|
| current_server_entity.GetParentId(),
|
| syncer::ModelTypeToRootTag(model_type), client_entity.specifics()));
|
| }
|
|
|
| PermanentEntity::PermanentEntity(const string& id,
|
| + int64_t version,
|
| const ModelType& model_type,
|
| const string& name,
|
| const string& parent_id,
|
| const string& server_defined_unique_tag,
|
| const sync_pb::EntitySpecifics& specifics)
|
| - : FakeServerEntity(id, string(), model_type, 0, name),
|
| + : LoopbackServerEntity(id, model_type, version, name),
|
| server_defined_unique_tag_(server_defined_unique_tag),
|
| parent_id_(parent_id) {
|
| SetSpecifics(specifics);
|
| @@ -96,7 +101,7 @@ string PermanentEntity::GetParentId() const {
|
| }
|
|
|
| void PermanentEntity::SerializeAsProto(sync_pb::SyncEntity* proto) const {
|
| - FakeServerEntity::SerializeBaseProtoFields(proto);
|
| + LoopbackServerEntity::SerializeBaseProtoFields(proto);
|
| proto->set_server_defined_unique_tag(server_defined_unique_tag_);
|
| }
|
|
|
| @@ -108,4 +113,4 @@ bool PermanentEntity::IsPermanent() const {
|
| return true;
|
| }
|
|
|
| -} // namespace fake_server
|
| +} // namespace syncer
|
|
|