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

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

Issue 1545553003: Switch to standard integer types in sync/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 12 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
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_BASE_NODE_H_ 5 #ifndef SYNC_INTERNAL_API_PUBLIC_BASE_NODE_H_
6 #define SYNC_INTERNAL_API_PUBLIC_BASE_NODE_H_ 6 #define SYNC_INTERNAL_API_PUBLIC_BASE_NODE_H_
7 7
8 #include <stddef.h>
9 #include <stdint.h>
10
8 #include <string> 11 #include <string>
9 #include <vector> 12 #include <vector>
10 13
11 #include "base/basictypes.h"
12 #include "base/gtest_prod_util.h" 14 #include "base/gtest_prod_util.h"
15 #include "base/macros.h"
13 #include "base/memory/scoped_ptr.h" 16 #include "base/memory/scoped_ptr.h"
14 #include "base/time/time.h" 17 #include "base/time/time.h"
15 #include "sync/api/attachments/attachment.h" 18 #include "sync/api/attachments/attachment.h"
16 #include "sync/base/sync_export.h" 19 #include "sync/base/sync_export.h"
17 #include "sync/internal_api/public/base/model_type.h" 20 #include "sync/internal_api/public/base/model_type.h"
18 #include "sync/protocol/sync.pb.h" 21 #include "sync/protocol/sync.pb.h"
19 #include "url/gurl.h" 22 #include "url/gurl.h"
20 23
21 // Forward declarations of internal class types so that sync API objects 24 // Forward declarations of internal class types so that sync API objects
22 // may have opaque pointers to these types. 25 // may have opaque pointers to these types.
(...skipping 20 matching lines...) Expand all
43 46
44 class BaseTransaction; 47 class BaseTransaction;
45 48
46 namespace syncable { 49 namespace syncable {
47 class BaseTransaction; 50 class BaseTransaction;
48 class Entry; 51 class Entry;
49 class Id; 52 class Id;
50 } 53 }
51 54
52 // A valid BaseNode will never have an ID of zero. 55 // A valid BaseNode will never have an ID of zero.
53 static const int64 kInvalidId = 0; 56 static const int64_t kInvalidId = 0;
54 57
55 // BaseNode wraps syncable::Entry, and corresponds to a single object's state. 58 // BaseNode wraps syncable::Entry, and corresponds to a single object's state.
56 // This, like syncable::Entry, is intended for use on the stack. A valid 59 // This, like syncable::Entry, is intended for use on the stack. A valid
57 // transaction is necessary to create a BaseNode or any of its children. 60 // transaction is necessary to create a BaseNode or any of its children.
58 // Unlike syncable::Entry, a sync API BaseNode is identified primarily by its 61 // Unlike syncable::Entry, a sync API BaseNode is identified primarily by its
59 // int64 metahandle, which we call an ID here. 62 // int64_t metahandle, which we call an ID here.
60 class SYNC_EXPORT BaseNode { 63 class SYNC_EXPORT BaseNode {
61 public: 64 public:
62 // Enumerates the possible outcomes of trying to initialize a sync node. 65 // Enumerates the possible outcomes of trying to initialize a sync node.
63 enum InitByLookupResult { 66 enum InitByLookupResult {
64 INIT_OK, 67 INIT_OK,
65 // Could not find an entry matching the lookup criteria. 68 // Could not find an entry matching the lookup criteria.
66 INIT_FAILED_ENTRY_NOT_GOOD, 69 INIT_FAILED_ENTRY_NOT_GOOD,
67 // Found an entry, but it is already deleted. 70 // Found an entry, but it is already deleted.
68 INIT_FAILED_ENTRY_IS_DEL, 71 INIT_FAILED_ENTRY_IS_DEL,
69 // Found an entry, but was unable to decrypt. 72 // Found an entry, but was unable to decrypt.
70 INIT_FAILED_DECRYPT_IF_NECESSARY, 73 INIT_FAILED_DECRYPT_IF_NECESSARY,
71 // A precondition was not met for calling init, such as legal input 74 // A precondition was not met for calling init, such as legal input
72 // arguments. 75 // arguments.
73 INIT_FAILED_PRECONDITION, 76 INIT_FAILED_PRECONDITION,
74 }; 77 };
75 78
76 // All subclasses of BaseNode must provide a way to initialize themselves by 79 // All subclasses of BaseNode must provide a way to initialize themselves by
77 // doing an ID lookup. Returns false on failure. An invalid or deleted 80 // doing an ID lookup. Returns false on failure. An invalid or deleted
78 // ID will result in failure. 81 // ID will result in failure.
79 virtual InitByLookupResult InitByIdLookup(int64 id) = 0; 82 virtual InitByLookupResult InitByIdLookup(int64_t id) = 0;
80 83
81 // All subclasses of BaseNode must also provide a way to initialize themselves 84 // All subclasses of BaseNode must also provide a way to initialize themselves
82 // by doing a client tag lookup. Returns false on failure. A deleted node 85 // by doing a client tag lookup. Returns false on failure. A deleted node
83 // will return FALSE. 86 // will return FALSE.
84 virtual InitByLookupResult InitByClientTagLookup( 87 virtual InitByLookupResult InitByClientTagLookup(
85 ModelType model_type, 88 ModelType model_type,
86 const std::string& tag) = 0; 89 const std::string& tag) = 0;
87 90
88 // Each object is identified by a 64-bit id (internally, the syncable 91 // Each object is identified by a 64-bit id (internally, the syncable
89 // metahandle). These ids are strictly local handles. They will persist 92 // metahandle). These ids are strictly local handles. They will persist
90 // on this client, but the same object on a different client may have a 93 // on this client, but the same object on a different client may have a
91 // different ID value. 94 // different ID value.
92 virtual int64 GetId() const; 95 virtual int64_t GetId() const;
93 96
94 // Returns the modification time of the object. 97 // Returns the modification time of the object.
95 base::Time GetModificationTime() const; 98 base::Time GetModificationTime() const;
96 99
97 // Nodes are hierarchically arranged into a single-rooted tree. 100 // Nodes are hierarchically arranged into a single-rooted tree.
98 // InitByRootLookup on ReadNode allows access to the root. GetParentId is 101 // InitByRootLookup on ReadNode allows access to the root. GetParentId is
99 // how you find a node's parent. 102 // how you find a node's parent.
100 int64 GetParentId() const; 103 int64_t GetParentId() const;
101 104
102 // Nodes are either folders or not. This corresponds to the IS_DIR property 105 // Nodes are either folders or not. This corresponds to the IS_DIR property
103 // of syncable::Entry. 106 // of syncable::Entry.
104 bool GetIsFolder() const; 107 bool GetIsFolder() const;
105 108
106 // Specifies whether node is a permanent folder. This is true when 109 // Specifies whether node is a permanent folder. This is true when
107 // UNIQUE_SERVER_TAG property of syncable::Entry is non-empty. 110 // UNIQUE_SERVER_TAG property of syncable::Entry is non-empty.
108 bool GetIsPermanentFolder() const; 111 bool GetIsPermanentFolder() const;
109 112
110 // Returns the title of the object. 113 // Returns the title of the object.
(...skipping 21 matching lines...) Expand all
132 // data. Can only be called if GetModelType() == TYPED_URLS. 135 // data. Can only be called if GetModelType() == TYPED_URLS.
133 const sync_pb::TypedUrlSpecifics& GetTypedUrlSpecifics() const; 136 const sync_pb::TypedUrlSpecifics& GetTypedUrlSpecifics() const;
134 137
135 // Getter specific to the EXPERIMENTS datatype. Returns protobuf 138 // Getter specific to the EXPERIMENTS datatype. Returns protobuf
136 // data. Can only be called if GetModelType() == EXPERIMENTS. 139 // data. Can only be called if GetModelType() == EXPERIMENTS.
137 const sync_pb::ExperimentsSpecifics& GetExperimentsSpecifics() const; 140 const sync_pb::ExperimentsSpecifics& GetExperimentsSpecifics() const;
138 141
139 const sync_pb::EntitySpecifics& GetEntitySpecifics() const; 142 const sync_pb::EntitySpecifics& GetEntitySpecifics() const;
140 143
141 // Returns the local external ID associated with the node. 144 // Returns the local external ID associated with the node.
142 int64 GetExternalId() const; 145 int64_t GetExternalId() const;
143 146
144 // Returns the internal syncable ID associated with the node. 147 // Returns the internal syncable ID associated with the node.
145 const syncable::Id& GetSyncId() const; 148 const syncable::Id& GetSyncId() const;
146 149
147 // Returns true iff this node has children. 150 // Returns true iff this node has children.
148 bool HasChildren() const; 151 bool HasChildren() const;
149 152
150 // Return the ID of the node immediately before this in the sibling order. 153 // Return the ID of the node immediately before this in the sibling order.
151 // For the first node in the ordering, return 0. 154 // For the first node in the ordering, return 0.
152 int64 GetPredecessorId() const; 155 int64_t GetPredecessorId() const;
153 156
154 // Return the ID of the node immediately after this in the sibling order. 157 // Return the ID of the node immediately after this in the sibling order.
155 // For the last node in the ordering, return 0. 158 // For the last node in the ordering, return 0.
156 int64 GetSuccessorId() const; 159 int64_t GetSuccessorId() const;
157 160
158 // Return the ID of the first child of this node. If this node has no 161 // Return the ID of the first child of this node. If this node has no
159 // children, return 0. 162 // children, return 0.
160 int64 GetFirstChildId() const; 163 int64_t GetFirstChildId() const;
161 164
162 // Returns the IDs of the children of this node. 165 // Returns the IDs of the children of this node.
163 // If this type supports user-defined positions the returned IDs will be in 166 // If this type supports user-defined positions the returned IDs will be in
164 // the correct order. 167 // the correct order.
165 void GetChildIds(std::vector<int64>* result) const; 168 void GetChildIds(std::vector<int64_t>* result) const;
166 169
167 // Returns the total number of nodes including and beneath this node. 170 // Returns the total number of nodes including and beneath this node.
168 // Recursively iterates through all children. 171 // Recursively iterates through all children.
169 int GetTotalNodeCount() const; 172 int GetTotalNodeCount() const;
170 173
171 // Returns this item's position within its parent. 174 // Returns this item's position within its parent.
172 // Do not call this function on items that do not support positioning 175 // Do not call this function on items that do not support positioning
173 // (ie. non-bookmarks). 176 // (ie. non-bookmarks).
174 int GetPositionIndex() const; 177 int GetPositionIndex() const;
175 178
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 236
234 // Same as |unencrypted_data_|, but for legacy password encryption. 237 // Same as |unencrypted_data_|, but for legacy password encryption.
235 scoped_ptr<sync_pb::PasswordSpecificsData> password_data_; 238 scoped_ptr<sync_pb::PasswordSpecificsData> password_data_;
236 239
237 DISALLOW_COPY_AND_ASSIGN(BaseNode); 240 DISALLOW_COPY_AND_ASSIGN(BaseNode);
238 }; 241 };
239 242
240 } // namespace syncer 243 } // namespace syncer
241 244
242 #endif // SYNC_INTERNAL_API_PUBLIC_BASE_NODE_H_ 245 #endif // SYNC_INTERNAL_API_PUBLIC_BASE_NODE_H_
OLDNEW
« no previous file with comments | « sync/internal_api/public/base/unique_position_unittest.cc ('k') | sync/internal_api/public/base_transaction.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698