| OLD | NEW |
| 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 Loading... |
| 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 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 | 168 |
| 172 virtual const BaseTransaction* GetTransaction() const OVERRIDE; | 169 virtual const BaseTransaction* GetTransaction() const OVERRIDE; |
| 173 | 170 |
| 174 syncable::MutableEntry* GetMutableEntryForTest(); | 171 syncable::MutableEntry* GetMutableEntryForTest(); |
| 175 | 172 |
| 176 private: | 173 private: |
| 177 FRIEND_TEST_ALL_PREFIXES(SyncManagerTest, EncryptBookmarksWithLegacyData); | 174 FRIEND_TEST_ALL_PREFIXES(SyncManagerTest, EncryptBookmarksWithLegacyData); |
| 178 | 175 |
| 179 void* operator new(size_t size); // Node is meant for stack use only. | 176 void* operator new(size_t size); // Node is meant for stack use only. |
| 180 | 177 |
| 181 // Helper to set model type. This will clear any specifics data. | |
| 182 void PutModelType(ModelType model_type); | |
| 183 | |
| 184 // Helper to set the previous node. | 178 // Helper to set the previous node. |
| 185 bool PutPredecessor(const BaseNode* predecessor) WARN_UNUSED_RESULT; | 179 bool PutPredecessor(const BaseNode* predecessor) WARN_UNUSED_RESULT; |
| 186 | 180 |
| 187 // Sets IS_UNSYNCED and SYNCING to ensure this entry is considered in an | 181 // Sets IS_UNSYNCED and SYNCING to ensure this entry is considered in an |
| 188 // upcoming commit pass. | 182 // upcoming commit pass. |
| 189 void MarkForSyncing(); | 183 void MarkForSyncing(); |
| 190 | 184 |
| 191 // The underlying syncable object which this class wraps. | 185 // The underlying syncable object which this class wraps. |
| 192 syncable::MutableEntry* entry_; | 186 syncable::MutableEntry* entry_; |
| 193 | 187 |
| 194 // The sync API transaction that is the parent of this node. | 188 // The sync API transaction that is the parent of this node. |
| 195 WriteTransaction* transaction_; | 189 WriteTransaction* transaction_; |
| 196 | 190 |
| 197 DISALLOW_COPY_AND_ASSIGN(WriteNode); | 191 DISALLOW_COPY_AND_ASSIGN(WriteNode); |
| 198 }; | 192 }; |
| 199 | 193 |
| 200 } // namespace syncer | 194 } // namespace syncer |
| 201 | 195 |
| 202 #endif // SYNC_INTERNAL_API_PUBLIC_WRITE_NODE_H_ | 196 #endif // SYNC_INTERNAL_API_PUBLIC_WRITE_NODE_H_ |
| OLD | NEW |