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

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

Issue 2887343002: wip 3 (Closed)
Patch Set: cleanup Created 3 years, 6 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> PersistentTombstoneEntity::Create(
17 const sync_pb::SyncEntity& entity) { 17 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>
28 PersistentTombstoneEntity::CreateForInjection(
29 const std::string& id,
30 const std::string& client_defined_unique_tag) {
31 const ModelType model_type = GetModelTypeFromId(id);
32 CHECK_NE(model_type, syncer::UNSPECIFIED) << "Invalid ID was given: " << id;
33 return std::unique_ptr<LoopbackServerEntity>(new PersistentTombstoneEntity(
34 id, 0, model_type, client_defined_unique_tag));
23 } 35 }
24 36
25 PersistentTombstoneEntity::PersistentTombstoneEntity( 37 PersistentTombstoneEntity::PersistentTombstoneEntity(
26 const string& id, 38 const string& id,
27 int64_t version, 39 int64_t version,
28 const ModelType& model_type) 40 const ModelType& model_type,
29 : LoopbackServerEntity(id, model_type, version, string()) { 41 const std::string& client_defined_unique_tag)
42 : LoopbackServerEntity(id, model_type, version, string()),
43 client_defined_unique_tag_(client_defined_unique_tag) {
30 sync_pb::EntitySpecifics specifics; 44 sync_pb::EntitySpecifics specifics;
31 AddDefaultFieldValue(model_type, &specifics); 45 AddDefaultFieldValue(model_type, &specifics);
32 SetSpecifics(specifics); 46 SetSpecifics(specifics);
33 } 47 }
34 48
35 bool PersistentTombstoneEntity::RequiresParentId() const { 49 bool PersistentTombstoneEntity::RequiresParentId() const {
36 return false; 50 return false;
37 } 51 }
38 52
39 string PersistentTombstoneEntity::GetParentId() const { 53 string PersistentTombstoneEntity::GetParentId() const {
40 return string(); 54 return string();
41 } 55 }
42 56
43 void PersistentTombstoneEntity::SerializeAsProto( 57 void PersistentTombstoneEntity::SerializeAsProto(
44 sync_pb::SyncEntity* proto) const { 58 sync_pb::SyncEntity* proto) const {
45 LoopbackServerEntity::SerializeBaseProtoFields(proto); 59 LoopbackServerEntity::SerializeBaseProtoFields(proto);
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