OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_INTERNAL_API_PUBLIC_TEST_TEST_ENTRY_FACTORY_H_ | 5 #ifndef SYNC_INTERNAL_API_PUBLIC_TEST_TEST_ENTRY_FACTORY_H_ |
6 #define SYNC_INTERNAL_API_PUBLIC_TEST_TEST_ENTRY_FACTORY_H_ | 6 #define SYNC_INTERNAL_API_PUBLIC_TEST_TEST_ENTRY_FACTORY_H_ |
7 | 7 |
| 8 #include <stdint.h> |
| 9 |
8 #include <string> | 10 #include <string> |
9 | 11 |
10 #include "base/basictypes.h" | 12 #include "base/macros.h" |
11 #include "sync/internal_api/public/base/model_type.h" | 13 #include "sync/internal_api/public/base/model_type.h" |
12 #include "sync/protocol/sync.pb.h" | 14 #include "sync/protocol/sync.pb.h" |
13 | 15 |
14 namespace syncer { | 16 namespace syncer { |
15 | 17 |
16 namespace syncable { | 18 namespace syncable { |
17 class Directory; | 19 class Directory; |
18 class Id; | 20 class Id; |
19 } | 21 } |
20 | 22 |
21 class TestEntryFactory { | 23 class TestEntryFactory { |
22 public: | 24 public: |
23 explicit TestEntryFactory(syncable::Directory* dir); | 25 explicit TestEntryFactory(syncable::Directory* dir); |
24 ~TestEntryFactory(); | 26 ~TestEntryFactory(); |
25 | 27 |
26 // Create a new unapplied folder node with a parent. | 28 // Create a new unapplied folder node with a parent. |
27 int64 CreateUnappliedNewItemWithParent( | 29 int64_t CreateUnappliedNewItemWithParent( |
28 const std::string& item_id, | 30 const std::string& item_id, |
29 const sync_pb::EntitySpecifics& specifics, | 31 const sync_pb::EntitySpecifics& specifics, |
30 const std::string& parent_id); | 32 const std::string& parent_id); |
31 | 33 |
32 int64 CreateUnappliedNewBookmarkItemWithParent( | 34 int64_t CreateUnappliedNewBookmarkItemWithParent( |
33 const std::string& item_id, | 35 const std::string& item_id, |
34 const sync_pb::EntitySpecifics& specifics, | 36 const sync_pb::EntitySpecifics& specifics, |
35 const std::string& parent_id); | 37 const std::string& parent_id); |
36 | 38 |
37 // Create a new unapplied update without a parent. | 39 // Create a new unapplied update without a parent. |
38 int64 CreateUnappliedNewItem(const std::string& item_id, | 40 int64_t CreateUnappliedNewItem(const std::string& item_id, |
39 const sync_pb::EntitySpecifics& specifics, | 41 const sync_pb::EntitySpecifics& specifics, |
40 bool is_unique); | 42 bool is_unique); |
41 | 43 |
42 // Create an unsynced unique_client_tag item in the database. If item_id is a | 44 // Create an unsynced unique_client_tag item in the database. If item_id is a |
43 // local ID, it will be treated as a create-new. Otherwise, if it's a server | 45 // local ID, it will be treated as a create-new. Otherwise, if it's a server |
44 // ID, we'll fake the server data so that it looks like it exists on the | 46 // ID, we'll fake the server data so that it looks like it exists on the |
45 // server. Returns the methandle of the created item in |metahandle_out| if | 47 // server. Returns the methandle of the created item in |metahandle_out| if |
46 // not NULL. | 48 // not NULL. |
47 void CreateUnsyncedItem(const syncable::Id& item_id, | 49 void CreateUnsyncedItem(const syncable::Id& item_id, |
48 const syncable::Id& parent_id, | 50 const syncable::Id& parent_id, |
49 const std::string& name, | 51 const std::string& name, |
50 bool is_folder, | 52 bool is_folder, |
51 ModelType model_type, | 53 ModelType model_type, |
52 int64* metahandle_out); | 54 int64_t* metahandle_out); |
53 | 55 |
54 // Creates a bookmark that is both unsynced an an unapplied update. Returns | 56 // Creates a bookmark that is both unsynced an an unapplied update. Returns |
55 // the metahandle of the created item. | 57 // the metahandle of the created item. |
56 int64 CreateUnappliedAndUnsyncedBookmarkItem(const std::string& name); | 58 int64_t CreateUnappliedAndUnsyncedBookmarkItem(const std::string& name); |
57 | 59 |
58 // Creates a unique_client_tag item that has neither IS_UNSYNED or | 60 // Creates a unique_client_tag item that has neither IS_UNSYNED or |
59 // IS_UNAPPLIED_UPDATE. The item is known to both the server and client. | 61 // IS_UNAPPLIED_UPDATE. The item is known to both the server and client. |
60 // Returns the metahandle of the created item. | 62 // Returns the metahandle of the created item. |
61 int64 CreateSyncedItem(const std::string& name, | 63 int64_t CreateSyncedItem(const std::string& name, |
62 ModelType model_type, bool is_folder); | 64 ModelType model_type, |
| 65 bool is_folder); |
63 | 66 |
64 // Creates a root node that IS_UNAPPLIED. Similar to what one would find in | 67 // Creates a root node that IS_UNAPPLIED. Similar to what one would find in |
65 // the database between the ProcessUpdates of an initial datatype configure | 68 // the database between the ProcessUpdates of an initial datatype configure |
66 // cycle and the ApplyUpdates step of the same sync cycle. | 69 // cycle and the ApplyUpdates step of the same sync cycle. |
67 int64 CreateUnappliedRootNode(ModelType model_type); | 70 int64_t CreateUnappliedRootNode(ModelType model_type); |
68 | 71 |
69 // Looks up the item referenced by |meta_handle|. If successful, overwrites | 72 // Looks up the item referenced by |meta_handle|. If successful, overwrites |
70 // the server specifics with |specifics|, sets | 73 // the server specifics with |specifics|, sets |
71 // IS_UNAPPLIED_UPDATES/IS_UNSYNCED appropriately, and returns true. | 74 // IS_UNAPPLIED_UPDATES/IS_UNSYNCED appropriately, and returns true. |
72 // Else, return false. | 75 // Else, return false. |
73 bool SetServerSpecificsForItem(int64 meta_handle, | 76 bool SetServerSpecificsForItem(int64_t meta_handle, |
74 const sync_pb::EntitySpecifics specifics); | 77 const sync_pb::EntitySpecifics specifics); |
75 | 78 |
76 // Looks up the item referenced by |meta_handle|. If successful, overwrites | 79 // Looks up the item referenced by |meta_handle|. If successful, overwrites |
77 // the local specifics with |specifics|, sets | 80 // the local specifics with |specifics|, sets |
78 // IS_UNAPPLIED_UPDATES/IS_UNSYNCED appropriately, and returns true. | 81 // IS_UNAPPLIED_UPDATES/IS_UNSYNCED appropriately, and returns true. |
79 // Else, return false. | 82 // Else, return false. |
80 bool SetLocalSpecificsForItem(int64 meta_handle, | 83 bool SetLocalSpecificsForItem(int64_t meta_handle, |
81 const sync_pb::EntitySpecifics specifics); | 84 const sync_pb::EntitySpecifics specifics); |
82 | 85 |
83 // Looks up the item referenced by |meta_handle| and returns its server | 86 // Looks up the item referenced by |meta_handle| and returns its server |
84 // specifics. | 87 // specifics. |
85 const sync_pb::EntitySpecifics& GetServerSpecificsForItem( | 88 const sync_pb::EntitySpecifics& GetServerSpecificsForItem( |
86 int64 meta_handle) const; | 89 int64_t meta_handle) const; |
87 | 90 |
88 // Looks up the item referenced by |meta_handle| and returns its specifics. | 91 // Looks up the item referenced by |meta_handle| and returns its specifics. |
89 const sync_pb::EntitySpecifics& GetLocalSpecificsForItem( | 92 const sync_pb::EntitySpecifics& GetLocalSpecificsForItem( |
90 int64 meta_handle) const; | 93 int64_t meta_handle) const; |
91 | 94 |
92 // Looks up the item referenced by |meta_handle|. If successful, overwrites | 95 // Looks up the item referenced by |meta_handle|. If successful, overwrites |
93 // the server attachment metadata with |metadata|, sets | 96 // the server attachment metadata with |metadata|, sets |
94 // IS_UNAPPLIED_UPDATES/IS_UNSYNCED appropriately, and returns true. | 97 // IS_UNAPPLIED_UPDATES/IS_UNSYNCED appropriately, and returns true. |
95 // Else, return false. | 98 // Else, return false. |
96 bool SetServerAttachmentMetadataForItem( | 99 bool SetServerAttachmentMetadataForItem( |
97 int64 meta_handle, | 100 int64_t meta_handle, |
98 const sync_pb::AttachmentMetadata metadata); | 101 const sync_pb::AttachmentMetadata metadata); |
99 | 102 |
100 // Looks up the item referenced by |meta_handle|. If successful, overwrites | 103 // Looks up the item referenced by |meta_handle|. If successful, overwrites |
101 // the local attachment metadata with |metadata|, sets | 104 // the local attachment metadata with |metadata|, sets |
102 // IS_UNAPPLIED_UPDATES/IS_UNSYNCED appropriately, and returns true. | 105 // IS_UNAPPLIED_UPDATES/IS_UNSYNCED appropriately, and returns true. |
103 // Else, return false. | 106 // Else, return false. |
104 bool SetLocalAttachmentMetadataForItem( | 107 bool SetLocalAttachmentMetadataForItem( |
105 int64 meta_handle, | 108 int64_t meta_handle, |
106 const sync_pb::AttachmentMetadata metadata); | 109 const sync_pb::AttachmentMetadata metadata); |
107 | 110 |
108 // Looks up the item referenced by |meta_handle| and returns its server | 111 // Looks up the item referenced by |meta_handle| and returns its server |
109 // attachment metadata. | 112 // attachment metadata. |
110 const sync_pb::AttachmentMetadata& GetServerAttachmentMetadataForItem( | 113 const sync_pb::AttachmentMetadata& GetServerAttachmentMetadataForItem( |
111 int64 meta_handle) const; | 114 int64_t meta_handle) const; |
112 | 115 |
113 // Looks up the item referenced by |meta_handle| and returns its attachment | 116 // Looks up the item referenced by |meta_handle| and returns its attachment |
114 // metadata. | 117 // metadata. |
115 const sync_pb::AttachmentMetadata& GetLocalAttachmentMetadataForItem( | 118 const sync_pb::AttachmentMetadata& GetLocalAttachmentMetadataForItem( |
116 int64 meta_handle) const; | 119 int64_t meta_handle) const; |
117 | 120 |
118 // Getters for IS_UNSYNCED and IS_UNAPPLIED_UPDATE bit fields. | 121 // Getters for IS_UNSYNCED and IS_UNAPPLIED_UPDATE bit fields. |
119 bool GetIsUnsyncedForItem(int64 meta_handle) const; | 122 bool GetIsUnsyncedForItem(int64_t meta_handle) const; |
120 bool GetIsUnappliedForItem(int64 meta_handle) const; | 123 bool GetIsUnappliedForItem(int64_t meta_handle) const; |
121 | 124 |
122 int64 GetNextRevision(); | 125 int64_t GetNextRevision(); |
123 | 126 |
124 private: | 127 private: |
125 syncable::Directory* directory_; | 128 syncable::Directory* directory_; |
126 int64 next_revision_; | 129 int64_t next_revision_; |
127 | 130 |
128 DISALLOW_COPY_AND_ASSIGN(TestEntryFactory); | 131 DISALLOW_COPY_AND_ASSIGN(TestEntryFactory); |
129 }; | 132 }; |
130 | 133 |
131 } // namespace syncer | 134 } // namespace syncer |
132 | 135 |
133 #endif // SYNC_INTERNAL_API_PUBLIC_TEST_TEST_ENTRY_FACTORY_H_ | 136 #endif // SYNC_INTERNAL_API_PUBLIC_TEST_TEST_ENTRY_FACTORY_H_ |
OLD | NEW |