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