Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(947)

Side by Side Diff: sync/internal_api/public/test/test_entry_factory.h

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

Powered by Google App Engine
This is Rietveld 408576698