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

Unified Diff: components/sync/engine_impl/net/loopback_server/loopback_server_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/loopback_server_entity.cc
diff --git a/components/sync/test/fake_server/fake_server_entity.cc b/components/sync/engine_impl/net/loopback_server/loopback_server_entity.cc
similarity index 60%
copy from components/sync/test/fake_server/fake_server_entity.cc
copy to components/sync/engine_impl/net/loopback_server/loopback_server_entity.cc
index 3f58ca533148bc93d8e5d1b1e573c77456697b39..d9226b3dee7184bd80748f6f76c76b736c420143 100644
--- a/components/sync/test/fake_server/fake_server_entity.cc
+++ b/components/sync/engine_impl/net/loopback_server/loopback_server_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/fake_server_entity.h"
+#include "components/sync/engine_impl/net/loopback_server/loopback_server_entity.h"
#include <stdint.h>
@@ -18,10 +18,10 @@
#include "base/strings/string_split.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
-#include "components/sync/base/model_type.h"
-#include "components/sync/protocol/sync.pb.h"
#include "net/base/net_errors.h"
#include "net/http/http_status_code.h"
+#include "components/sync/base/model_type.h"
+#include "components/sync/protocol/sync.pb.h"
using std::string;
using std::vector;
@@ -35,59 +35,74 @@ using syncer::ModelType;
// the construction of some IDs.
const char kIdSeparator[] = "_";
-namespace fake_server {
+namespace syncer {
+
+LoopbackServerEntity::~LoopbackServerEntity() { }
-FakeServerEntity::~FakeServerEntity() {}
+const std::string& LoopbackServerEntity::GetId() const {
+ return id_;
+}
-int64_t FakeServerEntity::GetVersion() const {
+ModelType LoopbackServerEntity::GetModelType() const {
+ return model_type_;
+}
+
+int64_t LoopbackServerEntity::GetVersion() const {
return version_;
}
-void FakeServerEntity::SetVersion(int64_t version) {
+void LoopbackServerEntity::SetVersion(int64_t version) {
version_ = version;
}
-const std::string& FakeServerEntity::GetName() const {
+const std::string& LoopbackServerEntity::GetName() const {
return name_;
}
-void FakeServerEntity::SetName(const std::string& name) {
+void LoopbackServerEntity::SetName(const std::string& name) {
name_ = name;
}
-void FakeServerEntity::SetSpecifics(
+void LoopbackServerEntity::SetSpecifics(
const sync_pb::EntitySpecifics& updated_specifics) {
specifics_ = updated_specifics;
}
-bool FakeServerEntity::IsDeleted() const {
+sync_pb::EntitySpecifics LoopbackServerEntity::GetSpecifics() const {
+ return specifics_;
+}
+
+bool LoopbackServerEntity::IsDeleted() const {
return false;
}
-bool FakeServerEntity::IsFolder() const {
+bool LoopbackServerEntity::IsFolder() const {
return false;
}
-bool FakeServerEntity::IsPermanent() const {
+bool LoopbackServerEntity::IsPermanent() const {
return false;
}
// static
-string FakeServerEntity::CreateId(const ModelType& model_type,
+string LoopbackServerEntity::CreateId(const ModelType& model_type,
const string& inner_id) {
int field_number = GetSpecificsFieldNumberFromModelType(model_type);
- return base::StringPrintf("%d%s%s", field_number, kIdSeparator,
+ return base::StringPrintf("%d%s%s",
+ field_number,
+ kIdSeparator,
inner_id.c_str());
}
// static
-std::string FakeServerEntity::GetTopLevelId(const ModelType& model_type) {
- return FakeServerEntity::CreateId(model_type,
- syncer::ModelTypeToRootTag(model_type));
+std::string LoopbackServerEntity::GetTopLevelId(const ModelType& model_type) {
+ return LoopbackServerEntity::CreateId(
+ model_type,
+ syncer::ModelTypeToRootTag(model_type));
}
// static
-ModelType FakeServerEntity::GetModelTypeFromId(const string& id) {
+ModelType LoopbackServerEntity::GetModelTypeFromId(const string& id) {
vector<base::StringPiece> tokens = base::SplitStringPiece(
id, kIdSeparator, base::KEEP_WHITESPACE, base::SPLIT_WANT_NONEMPTY);
@@ -99,29 +114,19 @@ ModelType FakeServerEntity::GetModelTypeFromId(const string& id) {
return syncer::GetModelTypeFromSpecificsFieldNumber(field_number);
}
-FakeServerEntity::FakeServerEntity(const string& id,
- const string& client_defined_unique_tag,
+LoopbackServerEntity::LoopbackServerEntity(const string& id,
const ModelType& model_type,
int64_t version,
const string& name)
- : id_(id),
- client_defined_unique_tag_(client_defined_unique_tag),
- model_type_(model_type),
- version_(version),
- name_(name) {
- // There shouldn't be a unique_tag if the type is bookmarks.
- DCHECK(model_type != syncer::BOOKMARKS || client_defined_unique_tag.empty());
-}
+ : id_(id), model_type_(model_type), version_(version), name_(name) {}
-void FakeServerEntity::SerializeBaseProtoFields(
+void LoopbackServerEntity::SerializeBaseProtoFields(
sync_pb::SyncEntity* sync_entity) const {
sync_pb::EntitySpecifics* specifics = sync_entity->mutable_specifics();
specifics->CopyFrom(specifics_);
- // FakeServerEntity fields
+ // LoopbackServerEntity fields
sync_entity->set_id_string(id_);
- if (!client_defined_unique_tag_.empty())
- sync_entity->set_client_defined_unique_tag(client_defined_unique_tag_);
sync_entity->set_version(version_);
sync_entity->set_name(name_);
@@ -133,4 +138,4 @@ void FakeServerEntity::SerializeBaseProtoFields(
sync_entity->set_parent_id_string(GetParentId());
}
-} // namespace fake_server
+} // namespace syncer

Powered by Google App Engine
This is Rietveld 408576698