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

Side by Side Diff: components/sync/engine_impl/loopback_server/persistent_tombstone_entity.cc

Issue 2969643002: Reland - Replace FakeServer's implementation with LoopbackServer invocations. (Closed)
Patch Set: Rebased on master. Created 3 years, 5 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/engine_impl/loopback_server/persistent_tombstone_entit y.h" 5 #include "components/sync/engine_impl/loopback_server/persistent_tombstone_entit y.h"
6 6
7 using std::string; 7 using std::string;
8 8
9 using syncer::ModelType; 9 using syncer::ModelType;
10 10
11 namespace syncer { 11 namespace syncer {
12 12
13 PersistentTombstoneEntity::~PersistentTombstoneEntity() {} 13 PersistentTombstoneEntity::~PersistentTombstoneEntity() {}
14 14
15 // static 15 // static
16 std::unique_ptr<LoopbackServerEntity> PersistentTombstoneEntity::Create( 16 std::unique_ptr<LoopbackServerEntity>
17 const sync_pb::SyncEntity& entity) { 17 PersistentTombstoneEntity::CreateFromEntity(const sync_pb::SyncEntity& entity) {
18 const ModelType model_type = GetModelTypeFromId(entity.id_string()); 18 const ModelType model_type = GetModelTypeFromId(entity.id_string());
19 CHECK_NE(model_type, syncer::UNSPECIFIED) << "Invalid ID was given: " 19 CHECK_NE(model_type, syncer::UNSPECIFIED) << "Invalid ID was given: "
20 << entity.id_string(); 20 << entity.id_string();
21 return std::unique_ptr<LoopbackServerEntity>(new PersistentTombstoneEntity( 21 return std::unique_ptr<LoopbackServerEntity>(new PersistentTombstoneEntity(
22 entity.id_string(), entity.version(), model_type)); 22 entity.id_string(), entity.version(), model_type,
23 entity.client_defined_unique_tag()));
24 }
25
26 // static
27 std::unique_ptr<LoopbackServerEntity> PersistentTombstoneEntity::CreateNew(
28 const std::string& id,
29 const std::string& client_defined_unique_tag) {
30 const ModelType model_type = GetModelTypeFromId(id);
31 CHECK_NE(model_type, syncer::UNSPECIFIED) << "Invalid ID was given: " << id;
32 return std::unique_ptr<LoopbackServerEntity>(new PersistentTombstoneEntity(
33 id, 0, model_type, client_defined_unique_tag));
23 } 34 }
24 35
25 PersistentTombstoneEntity::PersistentTombstoneEntity( 36 PersistentTombstoneEntity::PersistentTombstoneEntity(
26 const string& id, 37 const string& id,
27 int64_t version, 38 int64_t version,
28 const ModelType& model_type) 39 const ModelType& model_type,
29 : LoopbackServerEntity(id, model_type, version, string()) { 40 const std::string& client_defined_unique_tag)
41 : LoopbackServerEntity(id, model_type, version, string()),
42 client_defined_unique_tag_(client_defined_unique_tag) {
30 sync_pb::EntitySpecifics specifics; 43 sync_pb::EntitySpecifics specifics;
31 AddDefaultFieldValue(model_type, &specifics); 44 AddDefaultFieldValue(model_type, &specifics);
32 SetSpecifics(specifics); 45 SetSpecifics(specifics);
33 } 46 }
34 47
35 bool PersistentTombstoneEntity::RequiresParentId() const { 48 bool PersistentTombstoneEntity::RequiresParentId() const {
36 return false; 49 return false;
37 } 50 }
38 51
39 string PersistentTombstoneEntity::GetParentId() const { 52 string PersistentTombstoneEntity::GetParentId() const {
40 return string(); 53 return string();
41 } 54 }
42 55
43 void PersistentTombstoneEntity::SerializeAsProto( 56 void PersistentTombstoneEntity::SerializeAsProto(
44 sync_pb::SyncEntity* proto) const { 57 sync_pb::SyncEntity* proto) const {
45 LoopbackServerEntity::SerializeBaseProtoFields(proto); 58 LoopbackServerEntity::SerializeBaseProtoFields(proto);
59 if (!client_defined_unique_tag_.empty())
60 proto->set_client_defined_unique_tag(client_defined_unique_tag_);
46 } 61 }
47 62
48 bool PersistentTombstoneEntity::IsDeleted() const { 63 bool PersistentTombstoneEntity::IsDeleted() const {
49 return true; 64 return true;
50 } 65 }
51 66
52 sync_pb::LoopbackServerEntity_Type 67 sync_pb::LoopbackServerEntity_Type
53 PersistentTombstoneEntity::GetLoopbackServerEntityType() const { 68 PersistentTombstoneEntity::GetLoopbackServerEntityType() const {
54 return sync_pb::LoopbackServerEntity_Type_TOMBSTONE; 69 return sync_pb::LoopbackServerEntity_Type_TOMBSTONE;
55 } 70 }
56 71
57 } // namespace syncer 72 } // namespace syncer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698