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