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

Side by Side Diff: sync/internal_api/public/write_node.h

Issue 11817010: sync: Initialize entries with a valid model type (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix broken DCHECKs Created 7 years, 11 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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_WRITE_NODE_H_ 5 #ifndef SYNC_INTERNAL_API_PUBLIC_WRITE_NODE_H_
6 #define SYNC_INTERNAL_API_PUBLIC_WRITE_NODE_H_ 6 #define SYNC_INTERNAL_API_PUBLIC_WRITE_NODE_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 60
61 // A client must use one (and only one) of the following Init variants to 61 // A client must use one (and only one) of the following Init variants to
62 // populate the node. 62 // populate the node.
63 63
64 // BaseNode implementation. 64 // BaseNode implementation.
65 virtual InitByLookupResult InitByIdLookup(int64 id) OVERRIDE; 65 virtual InitByLookupResult InitByIdLookup(int64 id) OVERRIDE;
66 virtual InitByLookupResult InitByClientTagLookup( 66 virtual InitByLookupResult InitByClientTagLookup(
67 ModelType model_type, 67 ModelType model_type,
68 const std::string& tag) OVERRIDE; 68 const std::string& tag) OVERRIDE;
69 69
70 // Create a new node with the specified parent and predecessor. |model_type| 70 // Create a new bookmark node with the specified parent and predecessor. Use
71 // dictates the type of the item, and controls which EntitySpecifics proto 71 // a NULL |predecessor| to indicate that this is to be the first child.
72 // extension can be used with this item. Use a NULL |predecessor|
73 // to indicate that this is to be the first child.
74 // |predecessor| must be a child of |new_parent| or NULL. Returns false on 72 // |predecessor| must be a child of |new_parent| or NULL. Returns false on
75 // failure. 73 // failure.
76 bool InitByCreation(ModelType model_type, 74 bool InitBookmarkByCreation(const BaseNode& parent,
77 const BaseNode& parent, 75 const BaseNode* predecessor);
78 const BaseNode* predecessor);
79 76
80 // Create nodes using this function if they're unique items that 77 // Create nodes using this function if they're unique items that
81 // you want to fetch using client_tag. Note that the behavior of these 78 // you want to fetch using client_tag. Note that the behavior of these
82 // items is slightly different than that of normal items. 79 // items is slightly different than that of normal items.
83 // Most importantly, if it exists locally, this function will 80 // Most importantly, if it exists locally, this function will
84 // actually undelete it 81 // actually undelete it
85 // Client unique tagged nodes must NOT be folders. 82 // Client unique tagged nodes must NOT be folders.
86 InitUniqueByCreationResult InitUniqueByCreation( 83 InitUniqueByCreationResult InitUniqueByCreation(
87 ModelType model_type, 84 ModelType model_type,
88 const BaseNode& parent, 85 const BaseNode& parent,
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 173
177 virtual const BaseTransaction* GetTransaction() const OVERRIDE; 174 virtual const BaseTransaction* GetTransaction() const OVERRIDE;
178 175
179 syncable::MutableEntry* GetMutableEntryForTest(); 176 syncable::MutableEntry* GetMutableEntryForTest();
180 177
181 private: 178 private:
182 FRIEND_TEST_ALL_PREFIXES(SyncManagerTest, EncryptBookmarksWithLegacyData); 179 FRIEND_TEST_ALL_PREFIXES(SyncManagerTest, EncryptBookmarksWithLegacyData);
183 180
184 void* operator new(size_t size); // Node is meant for stack use only. 181 void* operator new(size_t size); // Node is meant for stack use only.
185 182
186 // Helper to set model type. This will clear any specifics data.
187 void PutModelType(ModelType model_type);
188
189 // Helper to set the previous node. 183 // Helper to set the previous node.
190 bool PutPredecessor(const BaseNode* predecessor) WARN_UNUSED_RESULT; 184 bool PutPredecessor(const BaseNode* predecessor) WARN_UNUSED_RESULT;
191 185
192 // Sets IS_UNSYNCED and SYNCING to ensure this entry is considered in an 186 // Sets IS_UNSYNCED and SYNCING to ensure this entry is considered in an
193 // upcoming commit pass. 187 // upcoming commit pass.
194 void MarkForSyncing(); 188 void MarkForSyncing();
195 189
196 // The underlying syncable object which this class wraps. 190 // The underlying syncable object which this class wraps.
197 syncable::MutableEntry* entry_; 191 syncable::MutableEntry* entry_;
198 192
199 // The sync API transaction that is the parent of this node. 193 // The sync API transaction that is the parent of this node.
200 WriteTransaction* transaction_; 194 WriteTransaction* transaction_;
201 195
202 DISALLOW_COPY_AND_ASSIGN(WriteNode); 196 DISALLOW_COPY_AND_ASSIGN(WriteNode);
203 }; 197 };
204 198
205 } // namespace syncer 199 } // namespace syncer
206 200
207 #endif // SYNC_INTERNAL_API_PUBLIC_WRITE_NODE_H_ 201 #endif // SYNC_INTERNAL_API_PUBLIC_WRITE_NODE_H_
OLDNEW
« no previous file with comments | « sync/internal_api/public/test/test_entry_factory.h ('k') | sync/internal_api/sync_encryption_handler_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698