OLD | NEW |
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 #ifndef SYNC_TEST_FAKE_SERVER_PERMANENT_ENTITY_H_ | 5 #ifndef SYNC_TEST_FAKE_SERVER_PERMANENT_ENTITY_H_ |
6 #define SYNC_TEST_FAKE_SERVER_PERMANENT_ENTITY_H_ | 6 #define SYNC_TEST_FAKE_SERVER_PERMANENT_ENTITY_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "sync/internal_api/public/base/model_type.h" | 10 #include "sync/internal_api/public/base/model_type.h" |
11 #include "sync/protocol/sync.pb.h" | 11 #include "sync/protocol/sync.pb.h" |
12 #include "sync/test/fake_server/fake_server_entity.h" | 12 #include "sync/test/fake_server/fake_server_entity.h" |
13 | 13 |
14 namespace fake_server { | 14 namespace fake_server { |
15 | 15 |
16 // A server-created, permanent entity. | 16 // A server-created, permanent entity. |
17 class PermanentEntity : public FakeServerEntity { | 17 class PermanentEntity : public FakeServerEntity { |
18 public: | 18 public: |
19 ~PermanentEntity() override; | 19 ~PermanentEntity() override; |
20 | 20 |
21 // Factory function for PermanentEntity. |server_tag| should be a globally | 21 // Factory function for PermanentEntity. |server_tag| should be a globally |
22 // unique identifier. | 22 // unique identifier. |
23 static scoped_ptr<FakeServerEntity> Create( | 23 static std::unique_ptr<FakeServerEntity> Create( |
24 const syncer::ModelType& model_type, | 24 const syncer::ModelType& model_type, |
25 const std::string& server_tag, | 25 const std::string& server_tag, |
26 const std::string& name, | 26 const std::string& name, |
27 const std::string& parent_server_tag); | 27 const std::string& parent_server_tag); |
28 | 28 |
29 // Factory function for a top level PermanentEntity. Top level means that the | 29 // Factory function for a top level PermanentEntity. Top level means that the |
30 // entity's parent is the root entity (no PermanentEntity exists for root). | 30 // entity's parent is the root entity (no PermanentEntity exists for root). |
31 static scoped_ptr<FakeServerEntity> CreateTopLevel( | 31 static std::unique_ptr<FakeServerEntity> CreateTopLevel( |
32 const syncer::ModelType& model_type); | 32 const syncer::ModelType& model_type); |
33 | 33 |
34 // Factory function for creating an updated version of a PermanentEntity. | 34 // Factory function for creating an updated version of a PermanentEntity. |
35 // This function should only be called for the Nigori entity. | 35 // This function should only be called for the Nigori entity. |
36 static scoped_ptr<FakeServerEntity> CreateUpdatedNigoriEntity( | 36 static std::unique_ptr<FakeServerEntity> CreateUpdatedNigoriEntity( |
37 const sync_pb::SyncEntity& client_entity, | 37 const sync_pb::SyncEntity& client_entity, |
38 const FakeServerEntity& current_server_entity); | 38 const FakeServerEntity& current_server_entity); |
39 | 39 |
40 // FakeServerEntity implementation. | 40 // FakeServerEntity implementation. |
41 bool RequiresParentId() const override; | 41 bool RequiresParentId() const override; |
42 std::string GetParentId() const override; | 42 std::string GetParentId() const override; |
43 void SerializeAsProto(sync_pb::SyncEntity* proto) const override; | 43 void SerializeAsProto(sync_pb::SyncEntity* proto) const override; |
44 bool IsFolder() const override; | 44 bool IsFolder() const override; |
45 bool IsPermanent() const override; | 45 bool IsPermanent() const override; |
46 | 46 |
47 private: | 47 private: |
48 PermanentEntity(const std::string& id, | 48 PermanentEntity(const std::string& id, |
49 const syncer::ModelType& model_type, | 49 const syncer::ModelType& model_type, |
50 const std::string& name, | 50 const std::string& name, |
51 const std::string& parent_id, | 51 const std::string& parent_id, |
52 const std::string& server_defined_unique_tag, | 52 const std::string& server_defined_unique_tag, |
53 const sync_pb::EntitySpecifics& entity_specifics); | 53 const sync_pb::EntitySpecifics& entity_specifics); |
54 | 54 |
55 // All member values have equivalent fields in SyncEntity. | 55 // All member values have equivalent fields in SyncEntity. |
56 std::string server_defined_unique_tag_; | 56 std::string server_defined_unique_tag_; |
57 std::string parent_id_; | 57 std::string parent_id_; |
58 }; | 58 }; |
59 | 59 |
60 } // namespace fake_server | 60 } // namespace fake_server |
61 | 61 |
62 #endif // SYNC_TEST_FAKE_SERVER_PERMANENT_ENTITY_H_ | 62 #endif // SYNC_TEST_FAKE_SERVER_PERMANENT_ENTITY_H_ |
OLD | NEW |