| 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 COMPONENTS_SYNC_TEST_FAKE_SERVER_BOOKMARK_ENTITY_H_ | 5 #ifndef COMPONENTS_SYNC_ENGINE_IMPL_NET_LOOPBACK_SERVER_BOOKMARK_ENTITY_H_ |
| 6 #define COMPONENTS_SYNC_TEST_FAKE_SERVER_BOOKMARK_ENTITY_H_ | 6 #define COMPONENTS_SYNC_ENGINE_IMPL_NET_LOOPBACK_SERVER_BOOKMARK_ENTITY_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <map> | 10 #include <map> |
| 11 #include <memory> |
| 11 #include <string> | 12 #include <string> |
| 12 | 13 |
| 13 #include "components/sync/base/model_type.h" | 14 #include "components/sync/base/model_type.h" |
| 15 #include "components/sync/engine_impl/net/loopback_server/loopback_server_entity
.h" |
| 14 #include "components/sync/protocol/sync.pb.h" | 16 #include "components/sync/protocol/sync.pb.h" |
| 15 #include "components/sync/test/fake_server/fake_server_entity.h" | |
| 16 | 17 |
| 17 namespace fake_server { | 18 namespace syncer { |
| 18 | 19 |
| 19 // A bookmark version of FakeServerEntity. This type represents entities that | 20 // A bookmark version of LoopbackServerEntity. This type represents entities |
| 20 // are non-deleted, client-created, and not unique per client account. | 21 // that are non-deleted, client-created, and not unique per client account. |
| 21 class BookmarkEntity : public FakeServerEntity { | 22 class BookmarkEntity : public LoopbackServerEntity { |
| 22 public: | 23 public: |
| 23 ~BookmarkEntity() override; | 24 ~BookmarkEntity() override; |
| 24 | 25 |
| 25 // Factory function for BookmarkEntity. This factory should be used only for | 26 // Factory function for BookmarkEntity. This factory should be used only for |
| 26 // the first time that a specific bookmark is seen by the server. | 27 // the first time that a specific bookmark is seen by the server. |
| 27 static std::unique_ptr<FakeServerEntity> CreateNew( | 28 static std::unique_ptr<LoopbackServerEntity> CreateNew( |
| 28 const sync_pb::SyncEntity& client_entity, | 29 const sync_pb::SyncEntity& client_entity, |
| 29 const std::string& parent_id, | 30 const std::string& parent_id, |
| 30 const std::string& client_guid); | 31 const std::string& client_guid); |
| 31 | 32 |
| 32 // Factory function for BookmarkEntity. The server's current entity for this | 33 // Factory function for BookmarkEntity. The server's current entity for this |
| 33 // ID, |current_server_entity|, is passed here because the client does not | 34 // ID, |current_server_entity|, is passed here because the client does not |
| 34 // always send the complete entity over the wire. This requires copying of | 35 // always send the complete entity over the wire. This requires copying of |
| 35 // some of the existing entity when creating a new entity. | 36 // some of the existing entity when creating a new entity. |
| 36 static std::unique_ptr<FakeServerEntity> CreateUpdatedVersion( | 37 static std::unique_ptr<LoopbackServerEntity> CreateUpdatedVersion( |
| 37 const sync_pb::SyncEntity& client_entity, | 38 const sync_pb::SyncEntity& client_entity, |
| 38 const FakeServerEntity& current_server_entity, | 39 const LoopbackServerEntity& current_server_entity, |
| 39 const std::string& parent_id); | 40 const std::string& parent_id); |
| 40 | 41 |
| 42 static std::unique_ptr<LoopbackServerEntity> BookmarkEntity::CreateFromEntity( |
| 43 const sync_pb::SyncEntity& client_entity); |
| 44 |
| 41 BookmarkEntity(const std::string& id, | 45 BookmarkEntity(const std::string& id, |
| 42 int64_t version, | 46 int64_t version, |
| 43 const std::string& name, | 47 const std::string& name, |
| 44 const std::string& originator_cache_guid, | 48 const std::string& originator_cache_guid, |
| 45 const std::string& originator_client_item_id, | 49 const std::string& originator_client_item_id, |
| 46 const sync_pb::UniquePosition& unique_position, | 50 const sync_pb::UniquePosition& unique_position, |
| 47 const sync_pb::EntitySpecifics& specifics, | 51 const sync_pb::EntitySpecifics& specifics, |
| 48 bool is_folder, | 52 bool is_folder, |
| 49 const std::string& parent_id, | 53 const std::string& parent_id, |
| 50 int64_t creation_time, | 54 int64_t creation_time, |
| 51 int64_t last_modified_time); | 55 int64_t last_modified_time); |
| 52 | 56 |
| 53 void SetParentId(const std::string& parent_id); | 57 void SetParentId(const std::string& parent_id); |
| 54 | 58 |
| 55 // FakeServerEntity implementation. | 59 // LoopbackServerEntity implementation. |
| 56 bool RequiresParentId() const override; | 60 bool RequiresParentId() const override; |
| 57 std::string GetParentId() const override; | 61 std::string GetParentId() const override; |
| 58 void SerializeAsProto(sync_pb::SyncEntity* proto) const override; | 62 void SerializeAsProto(sync_pb::SyncEntity* proto) const override; |
| 59 bool IsFolder() const override; | 63 bool IsFolder() const override; |
| 60 | 64 |
| 61 private: | 65 private: |
| 62 // All member values have equivalent fields in SyncEntity. | 66 // All member values have equivalent fields in SyncEntity. |
| 63 std::string originator_cache_guid_; | 67 std::string originator_cache_guid_; |
| 64 std::string originator_client_item_id_; | 68 std::string originator_client_item_id_; |
| 65 sync_pb::UniquePosition unique_position_; | 69 sync_pb::UniquePosition unique_position_; |
| 66 bool is_folder_; | 70 bool is_folder_; |
| 67 std::string parent_id_; | 71 std::string parent_id_; |
| 68 int64_t creation_time_; | 72 int64_t creation_time_; |
| 69 int64_t last_modified_time_; | 73 int64_t last_modified_time_; |
| 70 }; | 74 }; |
| 71 | 75 |
| 72 } // namespace fake_server | 76 } // namespace syncer |
| 73 | 77 |
| 74 #endif // COMPONENTS_SYNC_TEST_FAKE_SERVER_BOOKMARK_ENTITY_H_ | 78 #endif // COMPONENTS_SYNC_ENGINE_IMPL_NET_LOOPBACK_SERVER_BOOKMARK_ENTITY_H_ |
| OLD | NEW |