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

Unified Diff: components/sync/engine_impl/net/loopback_server/unique_client_entity.cc

Issue 2106743002: WIP: Local sync only... (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix after rebase. Created 4 years, 3 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: components/sync/engine_impl/net/loopback_server/unique_client_entity.cc
diff --git a/components/sync/test/fake_server/unique_client_entity.cc b/components/sync/engine_impl/net/loopback_server/unique_client_entity.cc
similarity index 56%
copy from components/sync/test/fake_server/unique_client_entity.cc
copy to components/sync/engine_impl/net/loopback_server/unique_client_entity.cc
index 62af22a541dc135c1e055e3b71c0a0a0036bb35f..b3c452628eb5ab02396b2aa641a4da5056182656 100644
--- a/components/sync/test/fake_server/unique_client_entity.cc
+++ b/components/sync/engine_impl/net/loopback_server/unique_client_entity.cc
@@ -2,7 +2,7 @@
// 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/unique_client_entity.h"
+#include "components/sync/engine_impl/net/loopback_server/unique_client_entity.h"
#include <stdint.h>
@@ -11,10 +11,10 @@
#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/engine_impl/net/loopback_server/permanent_entity.h"
#include "components/sync/protocol/sync.pb.h"
#include "components/sync/syncable/syncable_util.h"
-#include "components/sync/test/fake_server/fake_server_entity.h"
-#include "components/sync/test/fake_server/permanent_entity.h"
using std::string;
@@ -22,12 +22,12 @@ using syncer::GetModelTypeFromSpecifics;
using syncer::ModelType;
using syncer::syncable::GenerateSyncableHash;
-namespace fake_server {
+namespace syncer {
namespace {
-// A version must be passed when creating a FakeServerEntity, but this value
-// is overrideen immediately when saving the entity in FakeServer.
+// A version must be passed when creating a LoopbackServerEntity, but this value
+// is overrideen immediately when saving the entity in LoopbackServer.
const int64_t kUnusedVersion = 0L;
// Default time (creation and last modified) used when creating entities.
@@ -37,55 +37,40 @@ const int64_t kDefaultTime = 1234L;
UniqueClientEntity::UniqueClientEntity(
const string& id,
- const string& client_defined_unique_tag,
ModelType model_type,
int64_t version,
const string& name,
+ const string& client_defined_unique_tag,
const sync_pb::EntitySpecifics& specifics,
int64_t creation_time,
int64_t last_modified_time)
- : FakeServerEntity(id,
- client_defined_unique_tag,
- model_type,
- version,
- name),
+ : LoopbackServerEntity(id, model_type, version, name),
+ client_defined_unique_tag_(client_defined_unique_tag),
creation_time_(creation_time),
last_modified_time_(last_modified_time) {
SetSpecifics(specifics);
}
-UniqueClientEntity::~UniqueClientEntity() {}
+UniqueClientEntity::~UniqueClientEntity() { }
// static
-std::unique_ptr<FakeServerEntity> UniqueClientEntity::Create(
+std::unique_ptr<LoopbackServerEntity> UniqueClientEntity::Create(
const sync_pb::SyncEntity& client_entity) {
CHECK(client_entity.has_client_defined_unique_tag())
<< "A UniqueClientEntity must have a client-defined unique tag.";
ModelType model_type =
syncer::GetModelTypeFromSpecifics(client_entity.specifics());
string id = EffectiveIdForClientTaggedEntity(client_entity);
- return std::unique_ptr<FakeServerEntity>(new UniqueClientEntity(
- id, client_entity.client_defined_unique_tag(), model_type,
- client_entity.version(), client_entity.name(), client_entity.specifics(),
+ return std::unique_ptr<LoopbackServerEntity>(new UniqueClientEntity(
+ id, model_type, client_entity.version(), client_entity.name(),
+ client_entity.client_defined_unique_tag(), client_entity.specifics(),
client_entity.ctime(), client_entity.mtime()));
}
// static
-std::unique_ptr<FakeServerEntity> UniqueClientEntity::CreateForInjection(
- const string& name,
- const sync_pb::EntitySpecifics& entity_specifics) {
- ModelType model_type = GetModelTypeFromSpecifics(entity_specifics);
- string client_defined_unique_tag = GenerateSyncableHash(model_type, name);
- string id = FakeServerEntity::CreateId(model_type, client_defined_unique_tag);
- return std::unique_ptr<FakeServerEntity>(new UniqueClientEntity(
- id, client_defined_unique_tag, model_type, kUnusedVersion, name,
- entity_specifics, kDefaultTime, kDefaultTime));
-}
-
-// static
std::string UniqueClientEntity::EffectiveIdForClientTaggedEntity(
const sync_pb::SyncEntity& entity) {
- return FakeServerEntity::CreateId(
+ return LoopbackServerEntity::CreateId(
syncer::GetModelTypeFromSpecifics(entity.specifics()),
entity.client_defined_unique_tag());
}
@@ -97,14 +82,15 @@ bool UniqueClientEntity::RequiresParentId() const {
string UniqueClientEntity::GetParentId() const {
// The parent ID for this type of entity should always be its ModelType's
// root node.
- return FakeServerEntity::GetTopLevelId(model_type());
+ return LoopbackServerEntity::GetTopLevelId(GetModelType());
}
void UniqueClientEntity::SerializeAsProto(sync_pb::SyncEntity* proto) const {
- FakeServerEntity::SerializeBaseProtoFields(proto);
+ LoopbackServerEntity::SerializeBaseProtoFields(proto);
+ proto->set_client_defined_unique_tag(client_defined_unique_tag_);
proto->set_ctime(creation_time_);
proto->set_mtime(last_modified_time_);
}
-} // namespace fake_server
+} // namespace syncer

Powered by Google App Engine
This is Rietveld 408576698