| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "components/sync/engine_impl/loopback_server/persistent_tombstone_entit
y.h" |
| 6 |
| 7 #include <memory> |
| 8 #include <string> |
| 9 |
| 10 #include "components/sync/base/model_type.h" |
| 11 #include "components/sync/engine_impl/loopback_server/loopback_server_entity.h" |
| 12 #include "components/sync/protocol/sync.pb.h" |
| 13 |
| 14 using std::string; |
| 15 |
| 16 using syncer::ModelType; |
| 17 |
| 18 namespace syncer { |
| 19 |
| 20 PersistentTombstoneEntity::~PersistentTombstoneEntity() {} |
| 21 |
| 22 // static |
| 23 std::unique_ptr<LoopbackServerEntity> PersistentTombstoneEntity::Create( |
| 24 const sync_pb::SyncEntity& entity) { |
| 25 const ModelType model_type = GetModelTypeFromId(entity.id_string()); |
| 26 CHECK_NE(model_type, syncer::UNSPECIFIED) << "Invalid ID was given: " |
| 27 << entity.id_string(); |
| 28 return std::unique_ptr<LoopbackServerEntity>(new PersistentTombstoneEntity( |
| 29 entity.id_string(), entity.version(), model_type)); |
| 30 } |
| 31 |
| 32 PersistentTombstoneEntity::PersistentTombstoneEntity( |
| 33 const string& id, |
| 34 int64_t version, |
| 35 const ModelType& model_type) |
| 36 : LoopbackServerEntity(id, model_type, version, string()) { |
| 37 sync_pb::EntitySpecifics specifics; |
| 38 AddDefaultFieldValue(model_type, &specifics); |
| 39 SetSpecifics(specifics); |
| 40 } |
| 41 |
| 42 bool PersistentTombstoneEntity::RequiresParentId() const { |
| 43 return false; |
| 44 } |
| 45 |
| 46 string PersistentTombstoneEntity::GetParentId() const { |
| 47 return string(); |
| 48 } |
| 49 |
| 50 void PersistentTombstoneEntity::SerializeAsProto( |
| 51 sync_pb::SyncEntity* proto) const { |
| 52 LoopbackServerEntity::SerializeBaseProtoFields(proto); |
| 53 } |
| 54 |
| 55 bool PersistentTombstoneEntity::IsDeleted() const { |
| 56 return true; |
| 57 } |
| 58 |
| 59 sync_pb::LoopbackServerEntity_Type |
| 60 PersistentTombstoneEntity::GetLoopbackServerEntityType() const { |
| 61 return sync_pb::LoopbackServerEntity_Type_TOMBSTONE; |
| 62 } |
| 63 |
| 64 } // namespace syncer |
| OLD | NEW |