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