| 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_TEST_TEST_ENTRY_FACTORY_H_ | 5 #ifndef SYNC_TEST_TEST_ENTRY_FACTORY_H_ |
| 6 #define SYNC_TEST_TEST_ENTRY_FACTORY_H_ | 6 #define SYNC_TEST_TEST_ENTRY_FACTORY_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 explicit TestEntryFactory(syncable::Directory* dir); | 23 explicit TestEntryFactory(syncable::Directory* dir); |
| 24 ~TestEntryFactory(); | 24 ~TestEntryFactory(); |
| 25 | 25 |
| 26 // Create a new unapplied folder node with a parent. | 26 // Create a new unapplied folder node with a parent. |
| 27 void CreateUnappliedNewItemWithParent( | 27 void CreateUnappliedNewItemWithParent( |
| 28 const std::string& item_id, | 28 const std::string& item_id, |
| 29 const sync_pb::EntitySpecifics& specifics, | 29 const sync_pb::EntitySpecifics& specifics, |
| 30 const std::string& parent_id); | 30 const std::string& parent_id); |
| 31 | 31 |
| 32 // Create a new unapplied update without a parent. | 32 // Create a new unapplied update without a parent. |
| 33 void CreateUnappliedNewItem(const std::string& item_id, | 33 int64 CreateUnappliedNewItem(const std::string& item_id, |
| 34 const sync_pb::EntitySpecifics& specifics, | 34 const sync_pb::EntitySpecifics& specifics, |
| 35 bool is_unique); | 35 bool is_unique); |
| 36 | 36 |
| 37 // Create an unsynced item in the database. If item_id is a local ID, it will | 37 // Create an unsynced item in the database. If item_id is a local ID, it will |
| 38 // be treated as a create-new. Otherwise, if it's a server ID, we'll fake the | 38 // be treated as a create-new. Otherwise, if it's a server ID, we'll fake the |
| 39 // server data so that it looks like it exists on the server. Returns the | 39 // server data so that it looks like it exists on the server. Returns the |
| 40 // methandle of the created item in |metahandle_out| if not NULL. | 40 // methandle of the created item in |metahandle_out| if not NULL. |
| 41 void CreateUnsyncedItem(const syncable::Id& item_id, | 41 void CreateUnsyncedItem(const syncable::Id& item_id, |
| 42 const syncable::Id& parent_id, | 42 const syncable::Id& parent_id, |
| 43 const std::string& name, | 43 const std::string& name, |
| 44 bool is_folder, | 44 bool is_folder, |
| 45 ModelType model_type, | 45 ModelType model_type, |
| 46 int64* metahandle_out); | 46 int64* metahandle_out); |
| 47 | 47 |
| 48 // Creates an item that is both unsynced an an unapplied update. Returns the | 48 // Creates an item that is both unsynced an an unapplied update. Returns the |
| 49 // metahandle of the created item. | 49 // metahandle of the created item. |
| 50 int64 CreateUnappliedAndUnsyncedItem(const std::string& name, | 50 int64 CreateUnappliedAndUnsyncedItem(const std::string& name, |
| 51 ModelType model_type); | 51 ModelType model_type); |
| 52 | 52 |
| 53 // Creates an item that has neither IS_UNSYNED or IS_UNAPPLIED_UPDATE. The | 53 // Creates an item that has neither IS_UNSYNED or IS_UNAPPLIED_UPDATE. The |
| 54 // item is known to both the server and client. Returns the metahandle of | 54 // item is known to both the server and client. Returns the metahandle of |
| 55 // the created item. | 55 // the created item. |
| 56 int64 CreateSyncedItem(const std::string& name, | 56 int64 CreateSyncedItem(const std::string& name, |
| 57 ModelType model_type, bool is_folder); | 57 ModelType model_type, bool is_folder); |
| 58 | 58 |
| 59 // Looks up the item referenced by |meta_handle|. If successful, overwrites |
| 60 // the server specifics with |specifics|, sets |
| 61 // IS_UNAPPLIED_UPDATES/IS_UNSYNCED appropriately, and returns true. |
| 62 // Else, return false. |
| 63 bool SetServerSpecificsForItem(int64 meta_handle, |
| 64 const sync_pb::EntitySpecifics specifics); |
| 65 |
| 66 // Looks up the item referenced by |meta_handle|. If successful, overwrites |
| 67 // the local specifics with |specifics|, sets |
| 68 // IS_UNAPPLIED_UPDATES/IS_UNSYNCED appropriately, and returns true. |
| 69 // Else, return false. |
| 70 bool SetLocalSpecificsForItem(int64 meta_handle, |
| 71 const sync_pb::EntitySpecifics specifics); |
| 72 |
| 73 // Looks up the item referenced by |meta_handle|. If successful, stores |
| 74 // the server specifics into |specifics| and returns true. Else, return false. |
| 75 const sync_pb::EntitySpecifics& GetServerSpecificsForItem( |
| 76 int64 meta_handle) const; |
| 77 |
| 78 // Looks up the item referenced by |meta_handle|. If successful, stores |
| 79 // the local specifics into |specifics| and returns true. Else, return false. |
| 80 const sync_pb::EntitySpecifics& GetLocalSpecificsForItem( |
| 81 int64 meta_handle) const; |
| 82 |
| 83 // Getters for IS_UNSYNCED and IS_UNAPPLIED_UPDATE bit fields. |
| 84 bool GetIsUnsyncedForItem(int64 meta_handle) const; |
| 85 bool GetIsUnappliedForItem(int64 meta_handle) const; |
| 86 |
| 59 int64 GetNextRevision(); | 87 int64 GetNextRevision(); |
| 60 | 88 |
| 61 private: | 89 private: |
| 62 syncable::Directory* directory_; | 90 syncable::Directory* directory_; |
| 63 int64 next_revision_; | 91 int64 next_revision_; |
| 64 | 92 |
| 65 DISALLOW_COPY_AND_ASSIGN(TestEntryFactory); | 93 DISALLOW_COPY_AND_ASSIGN(TestEntryFactory); |
| 66 }; | 94 }; |
| 67 | 95 |
| 68 } // namespace syncer | 96 } // namespace syncer |
| 69 | 97 |
| 70 #endif // SYNC_TEST_TEST_ENTRY_FACTORY_H_ | 98 #endif // SYNC_TEST_TEST_ENTRY_FACTORY_H_ |
| OLD | NEW |