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

Side by Side Diff: components/sync/engine_impl/net/loopback_server/tombstone_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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/sync/test/fake_server/tombstone_entity.h" 5 #include "components/sync/engine_impl/net/loopback_server/tombstone_entity.h"
6 6
7 #include <memory>
7 #include <string> 8 #include <string>
8 9
9 #include "components/sync/base/model_type.h" 10 #include "components/sync/base/model_type.h"
11 #include "components/sync/engine_impl/net/loopback_server/loopback_server_entity .h"
10 #include "components/sync/protocol/sync.pb.h" 12 #include "components/sync/protocol/sync.pb.h"
11 #include "components/sync/test/fake_server/fake_server_entity.h"
12 13
13 using std::string; 14 using std::string;
14 15
15 using syncer::ModelType; 16 using syncer::ModelType;
16 17
17 namespace fake_server { 18 namespace syncer {
18 19
19 TombstoneEntity::~TombstoneEntity() {} 20 TombstoneEntity::~TombstoneEntity() { }
20 21
21 // static 22 // static
22 std::unique_ptr<FakeServerEntity> TombstoneEntity::Create( 23 std::unique_ptr<LoopbackServerEntity> TombstoneEntity::Create(
23 const string& id, 24 const sync_pb::SyncEntity& entity) {
24 const string& client_defined_unique_tag) { 25 const ModelType model_type = GetModelTypeFromId(entity.id_string());
25 const ModelType model_type = GetModelTypeFromId(id); 26 CHECK_NE(model_type, syncer::UNSPECIFIED)
26 CHECK_NE(model_type, syncer::UNSPECIFIED) << "Invalid ID was given: " << id; 27 << "Invalid ID was given: " << entity.id_string();
27 return std::unique_ptr<FakeServerEntity>( 28 return std::unique_ptr<LoopbackServerEntity>(
28 new TombstoneEntity(id, client_defined_unique_tag, model_type)); 29 new TombstoneEntity(entity.id_string(), entity.version(), model_type));
29 } 30 }
30 31
31 TombstoneEntity::TombstoneEntity(const string& id, 32 TombstoneEntity::TombstoneEntity(const string& id,
32 const string& client_defined_unique_tag, 33 int64_t version,
33 const ModelType& model_type) 34 const ModelType& model_type)
34 : FakeServerEntity(id, client_defined_unique_tag, model_type, 0, string()) { 35 : LoopbackServerEntity(id, model_type, version, string()) {
35 sync_pb::EntitySpecifics specifics; 36 sync_pb::EntitySpecifics specifics;
36 AddDefaultFieldValue(model_type, &specifics); 37 AddDefaultFieldValue(model_type, &specifics);
37 SetSpecifics(specifics); 38 SetSpecifics(specifics);
38 } 39 }
39 40
40 bool TombstoneEntity::RequiresParentId() const { 41 bool TombstoneEntity::RequiresParentId() const {
41 return false; 42 return false;
42 } 43 }
43 44
44 string TombstoneEntity::GetParentId() const { 45 string TombstoneEntity::GetParentId() const {
45 return string(); 46 return string();
46 } 47 }
47 48
48 void TombstoneEntity::SerializeAsProto(sync_pb::SyncEntity* proto) const { 49 void TombstoneEntity::SerializeAsProto(sync_pb::SyncEntity* proto) const {
49 FakeServerEntity::SerializeBaseProtoFields(proto); 50 LoopbackServerEntity::SerializeBaseProtoFields(proto);
50 } 51 }
51 52
52 bool TombstoneEntity::IsDeleted() const { 53 bool TombstoneEntity::IsDeleted() const {
53 return true; 54 return true;
54 } 55 }
55 56
56 } // namespace fake_server 57 } // namespace syncer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698