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