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

Side by Side Diff: sync/internal_api/base_node.cc

Issue 1545553003: Switch to standard integer types in sync/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years 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 (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 #include "sync/internal_api/public/base_node.h" 5 #include "sync/internal_api/public/base_node.h"
6 6
7 #include <stdint.h>
8
7 #include <stack> 9 #include <stack>
8 10
9 #include "base/strings/string_number_conversions.h" 11 #include "base/strings/string_number_conversions.h"
10 #include "base/strings/utf_string_conversions.h" 12 #include "base/strings/utf_string_conversions.h"
11 #include "sync/internal_api/public/base_transaction.h" 13 #include "sync/internal_api/public/base_transaction.h"
12 #include "sync/internal_api/syncapi_internal.h" 14 #include "sync/internal_api/syncapi_internal.h"
13 #include "sync/protocol/app_specifics.pb.h" 15 #include "sync/protocol/app_specifics.pb.h"
14 #include "sync/protocol/autofill_specifics.pb.h" 16 #include "sync/protocol/autofill_specifics.pb.h"
15 #include "sync/protocol/bookmark_specifics.pb.h" 17 #include "sync/protocol/bookmark_specifics.pb.h"
16 #include "sync/protocol/extension_specifics.pb.h" 18 #include "sync/protocol/extension_specifics.pb.h"
17 #include "sync/protocol/nigori_specifics.pb.h" 19 #include "sync/protocol/nigori_specifics.pb.h"
18 #include "sync/protocol/password_specifics.pb.h" 20 #include "sync/protocol/password_specifics.pb.h"
19 #include "sync/protocol/session_specifics.pb.h" 21 #include "sync/protocol/session_specifics.pb.h"
20 #include "sync/protocol/theme_specifics.pb.h" 22 #include "sync/protocol/theme_specifics.pb.h"
21 #include "sync/protocol/typed_url_specifics.pb.h" 23 #include "sync/protocol/typed_url_specifics.pb.h"
22 #include "sync/syncable/directory.h" 24 #include "sync/syncable/directory.h"
23 #include "sync/syncable/entry.h" 25 #include "sync/syncable/entry.h"
24 #include "sync/syncable/syncable_base_transaction.h" 26 #include "sync/syncable/syncable_base_transaction.h"
25 #include "sync/syncable/syncable_id.h" 27 #include "sync/syncable/syncable_id.h"
26 #include "sync/util/time.h" 28 #include "sync/util/time.h"
27 29
28 using sync_pb::AutofillProfileSpecifics; 30 using sync_pb::AutofillProfileSpecifics;
29 31
30 namespace syncer { 32 namespace syncer {
31 33
32 using syncable::SPECIFICS; 34 using syncable::SPECIFICS;
33 35
34 // Helper function to look up the int64 metahandle of an object given the ID 36 // Helper function to look up the int64_t metahandle of an object given the ID
35 // string. 37 // string.
36 static int64 IdToMetahandle(syncable::BaseTransaction* trans, 38 static int64_t IdToMetahandle(syncable::BaseTransaction* trans,
37 const syncable::Id& id) { 39 const syncable::Id& id) {
38 if (id.IsNull()) 40 if (id.IsNull())
39 return kInvalidId; 41 return kInvalidId;
40 syncable::Entry entry(trans, syncable::GET_BY_ID, id); 42 syncable::Entry entry(trans, syncable::GET_BY_ID, id);
41 if (!entry.good()) 43 if (!entry.good())
42 return kInvalidId; 44 return kInvalidId;
43 return entry.GetMetahandle(); 45 return entry.GetMetahandle();
44 } 46 }
45 47
46 BaseNode::BaseNode() : password_data_(new sync_pb::PasswordSpecificsData) {} 48 BaseNode::BaseNode() : password_data_(new sync_pb::PasswordSpecificsData) {}
47 49
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 DCHECK_EQ(GetModelTypeFromSpecifics(unencrypted_data_), BOOKMARKS); 135 DCHECK_EQ(GetModelTypeFromSpecifics(unencrypted_data_), BOOKMARKS);
134 return unencrypted_data_; 136 return unencrypted_data_;
135 } 137 }
136 } else { 138 } else {
137 DCHECK_EQ(GetModelTypeFromSpecifics(unencrypted_data_), UNSPECIFIED); 139 DCHECK_EQ(GetModelTypeFromSpecifics(unencrypted_data_), UNSPECIFIED);
138 return specifics; 140 return specifics;
139 } 141 }
140 } 142 }
141 } 143 }
142 144
143 int64 BaseNode::GetParentId() const { 145 int64_t BaseNode::GetParentId() const {
144 return IdToMetahandle(GetTransaction()->GetWrappedTrans(), 146 return IdToMetahandle(GetTransaction()->GetWrappedTrans(),
145 GetEntry()->GetParentId()); 147 GetEntry()->GetParentId());
146 } 148 }
147 149
148 int64 BaseNode::GetId() const { 150 int64_t BaseNode::GetId() const {
149 return GetEntry()->GetMetahandle(); 151 return GetEntry()->GetMetahandle();
150 } 152 }
151 153
152 base::Time BaseNode::GetModificationTime() const { 154 base::Time BaseNode::GetModificationTime() const {
153 return GetEntry()->GetMtime(); 155 return GetEntry()->GetMtime();
154 } 156 }
155 157
156 bool BaseNode::GetIsFolder() const { 158 bool BaseNode::GetIsFolder() const {
157 return GetEntry()->GetIsDir(); 159 return GetEntry()->GetIsDir();
158 } 160 }
(...skipping 20 matching lines...) Expand all
179 } 181 }
180 return result; 182 return result;
181 } 183 }
182 184
183 bool BaseNode::HasChildren() const { 185 bool BaseNode::HasChildren() const {
184 syncable::Directory* dir = GetTransaction()->GetDirectory(); 186 syncable::Directory* dir = GetTransaction()->GetDirectory();
185 syncable::BaseTransaction* trans = GetTransaction()->GetWrappedTrans(); 187 syncable::BaseTransaction* trans = GetTransaction()->GetWrappedTrans();
186 return dir->HasChildren(trans, GetEntry()->GetId()); 188 return dir->HasChildren(trans, GetEntry()->GetId());
187 } 189 }
188 190
189 int64 BaseNode::GetPredecessorId() const { 191 int64_t BaseNode::GetPredecessorId() const {
190 syncable::Id id_string = GetEntry()->GetPredecessorId(); 192 syncable::Id id_string = GetEntry()->GetPredecessorId();
191 if (id_string.IsNull()) 193 if (id_string.IsNull())
192 return kInvalidId; 194 return kInvalidId;
193 return IdToMetahandle(GetTransaction()->GetWrappedTrans(), id_string); 195 return IdToMetahandle(GetTransaction()->GetWrappedTrans(), id_string);
194 } 196 }
195 197
196 int64 BaseNode::GetSuccessorId() const { 198 int64_t BaseNode::GetSuccessorId() const {
197 syncable::Id id_string = GetEntry()->GetSuccessorId(); 199 syncable::Id id_string = GetEntry()->GetSuccessorId();
198 if (id_string.IsNull()) 200 if (id_string.IsNull())
199 return kInvalidId; 201 return kInvalidId;
200 return IdToMetahandle(GetTransaction()->GetWrappedTrans(), id_string); 202 return IdToMetahandle(GetTransaction()->GetWrappedTrans(), id_string);
201 } 203 }
202 204
203 int64 BaseNode::GetFirstChildId() const { 205 int64_t BaseNode::GetFirstChildId() const {
204 syncable::Id id_string = GetEntry()->GetFirstChildId(); 206 syncable::Id id_string = GetEntry()->GetFirstChildId();
205 if (id_string.IsNull()) 207 if (id_string.IsNull())
206 return kInvalidId; 208 return kInvalidId;
207 return IdToMetahandle(GetTransaction()->GetWrappedTrans(), id_string); 209 return IdToMetahandle(GetTransaction()->GetWrappedTrans(), id_string);
208 } 210 }
209 211
210 void BaseNode::GetChildIds(std::vector<int64>* result) const { 212 void BaseNode::GetChildIds(std::vector<int64_t>* result) const {
211 GetEntry()->GetChildHandles(result); 213 GetEntry()->GetChildHandles(result);
212 } 214 }
213 215
214 int BaseNode::GetTotalNodeCount() const { 216 int BaseNode::GetTotalNodeCount() const {
215 return GetEntry()->GetTotalNodeCount(); 217 return GetEntry()->GetTotalNodeCount();
216 } 218 }
217 219
218 int BaseNode::GetPositionIndex() const { 220 int BaseNode::GetPositionIndex() const {
219 return GetEntry()->GetPositionIndex(); 221 return GetEntry()->GetPositionIndex();
220 } 222 }
221 223
222 base::DictionaryValue* BaseNode::ToValue() const { 224 base::DictionaryValue* BaseNode::ToValue() const {
223 return GetEntry()->ToValue(GetTransaction()->GetCryptographer()); 225 return GetEntry()->ToValue(GetTransaction()->GetCryptographer());
224 } 226 }
225 227
226 int64 BaseNode::GetExternalId() const { 228 int64_t BaseNode::GetExternalId() const {
227 return GetEntry()->GetLocalExternalId(); 229 return GetEntry()->GetLocalExternalId();
228 } 230 }
229 231
230 const syncable::Id& BaseNode::GetSyncId() const { 232 const syncable::Id& BaseNode::GetSyncId() const {
231 return GetEntry()->GetId(); 233 return GetEntry()->GetId();
232 } 234 }
233 235
234 const sync_pb::BookmarkSpecifics& BaseNode::GetBookmarkSpecifics() const { 236 const sync_pb::BookmarkSpecifics& BaseNode::GetBookmarkSpecifics() const {
235 DCHECK_EQ(GetModelType(), BOOKMARKS); 237 DCHECK_EQ(GetModelType(), BOOKMARKS);
236 return GetEntitySpecifics().bookmark(); 238 return GetEntitySpecifics().bookmark();
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 const sync_pb::EntitySpecifics& specifics) { 280 const sync_pb::EntitySpecifics& specifics) {
279 ModelType type = GetModelTypeFromSpecifics(specifics); 281 ModelType type = GetModelTypeFromSpecifics(specifics);
280 DCHECK_NE(UNSPECIFIED, type); 282 DCHECK_NE(UNSPECIFIED, type);
281 if (GetModelType() != UNSPECIFIED) { 283 if (GetModelType() != UNSPECIFIED) {
282 DCHECK_EQ(GetModelType(), type); 284 DCHECK_EQ(GetModelType(), type);
283 } 285 }
284 unencrypted_data_.CopyFrom(specifics); 286 unencrypted_data_.CopyFrom(specifics);
285 } 287 }
286 288
287 } // namespace syncer 289 } // namespace syncer
OLDNEW
« no previous file with comments | « sync/internal_api/attachments/on_disk_attachment_store_unittest.cc ('k') | sync/internal_api/change_reorder_buffer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698