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

Side by Side Diff: chrome/browser/sync/internal_api/write_node.h

Issue 10152003: sync: Make BaseNode lookup-related Init functions return specific failures. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 8 years, 8 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 (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 CHROME_BROWSER_SYNC_INTERNAL_API_WRITE_NODE_H_ 5 #ifndef CHROME_BROWSER_SYNC_INTERNAL_API_WRITE_NODE_H_
6 #define CHROME_BROWSER_SYNC_INTERNAL_API_WRITE_NODE_H_ 6 #define CHROME_BROWSER_SYNC_INTERNAL_API_WRITE_NODE_H_
7 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 class WriteNode : public BaseNode { 47 class WriteNode : public BaseNode {
48 public: 48 public:
49 // Create a WriteNode using the given transaction. 49 // Create a WriteNode using the given transaction.
50 explicit WriteNode(WriteTransaction* transaction); 50 explicit WriteNode(WriteTransaction* transaction);
51 virtual ~WriteNode(); 51 virtual ~WriteNode();
52 52
53 // A client must use one (and only one) of the following Init variants to 53 // A client must use one (and only one) of the following Init variants to
54 // populate the node. 54 // populate the node.
55 55
56 // BaseNode implementation. 56 // BaseNode implementation.
57 virtual bool InitByIdLookup(int64 id) OVERRIDE; 57 virtual InitByLookupResult InitByIdLookup(int64 id) OVERRIDE;
58 virtual bool InitByClientTagLookup(syncable::ModelType model_type, 58 virtual InitByLookupResult InitByClientTagLookup(
59 const std::string& tag) OVERRIDE; 59 syncable::ModelType model_type,
60 const std::string& tag) OVERRIDE;
60 61
61 // Create a new node with the specified parent and predecessor. |model_type| 62 // Create a new node with the specified parent and predecessor. |model_type|
62 // dictates the type of the item, and controls which EntitySpecifics proto 63 // dictates the type of the item, and controls which EntitySpecifics proto
63 // extension can be used with this item. Use a NULL |predecessor| 64 // extension can be used with this item. Use a NULL |predecessor|
64 // to indicate that this is to be the first child. 65 // to indicate that this is to be the first child.
65 // |predecessor| must be a child of |new_parent| or NULL. Returns false on 66 // |predecessor| must be a child of |new_parent| or NULL. Returns false on
66 // failure. 67 // failure.
67 bool InitByCreation(syncable::ModelType model_type, 68 bool InitByCreation(syncable::ModelType model_type,
68 const BaseNode& parent, 69 const BaseNode& parent,
69 const BaseNode* predecessor); 70 const BaseNode* predecessor);
70 71
71 // Create nodes using this function if they're unique items that 72 // Create nodes using this function if they're unique items that
72 // you want to fetch using client_tag. Note that the behavior of these 73 // you want to fetch using client_tag. Note that the behavior of these
73 // items is slightly different than that of normal items. 74 // items is slightly different than that of normal items.
74 // Most importantly, if it exists locally, this function will 75 // Most importantly, if it exists locally, this function will
75 // actually undelete it 76 // actually undelete it
76 // Client unique tagged nodes must NOT be folders. 77 // Client unique tagged nodes must NOT be folders.
77 bool InitUniqueByCreation(syncable::ModelType model_type, 78 bool InitUniqueByCreation(syncable::ModelType model_type,
78 const BaseNode& parent, 79 const BaseNode& parent,
79 const std::string& client_tag); 80 const std::string& client_tag);
80 81
81 // Each server-created permanent node is tagged with a unique string. 82 // Each server-created permanent node is tagged with a unique string.
82 // Look up the node with the particular tag. If it does not exist, 83 // Look up the node with the particular tag. If it does not exist,
83 // return false. 84 // return false.
84 bool InitByTagLookup(const std::string& tag); 85 InitByLookupResult InitByTagLookup(const std::string& tag);
85 86
86 // These Set() functions correspond to the Get() functions of BaseNode. 87 // These Set() functions correspond to the Get() functions of BaseNode.
87 void SetIsFolder(bool folder); 88 void SetIsFolder(bool folder);
88 void SetTitle(const std::wstring& title); 89 void SetTitle(const std::wstring& title);
89 90
90 // External ID is a client-only field, so setting it doesn't cause the item to 91 // External ID is a client-only field, so setting it doesn't cause the item to
91 // be synced again. 92 // be synced again.
92 void SetExternalId(int64 external_id); 93 void SetExternalId(int64 external_id);
93 94
94 // Remove this node and its children. 95 // Remove this node and its children.
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 181
181 // The sync API transaction that is the parent of this node. 182 // The sync API transaction that is the parent of this node.
182 WriteTransaction* transaction_; 183 WriteTransaction* transaction_;
183 184
184 DISALLOW_COPY_AND_ASSIGN(WriteNode); 185 DISALLOW_COPY_AND_ASSIGN(WriteNode);
185 }; 186 };
186 187
187 } // namespace sync_api 188 } // namespace sync_api
188 189
189 #endif // CHROME_BROWSER_SYNC_INTERNAL_API_WRITE_NODE_H_ 190 #endif // CHROME_BROWSER_SYNC_INTERNAL_API_WRITE_NODE_H_
OLDNEW
« no previous file with comments | « chrome/browser/sync/internal_api/syncapi_unittest.cc ('k') | chrome/browser/sync/internal_api/write_node.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698