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

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

Issue 11637053: sync: Start moving away from PREV_ID and NEXT_ID (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase 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
« no previous file with comments | « sync/engine/syncer_util.cc ('k') | sync/internal_api/change_reorder_buffer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <stack> 7 #include <stack>
8 8
9 #include "base/string_number_conversions.h" 9 #include "base/string_number_conversions.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 return result; 188 return result;
189 } 189 }
190 190
191 bool BaseNode::HasChildren() const { 191 bool BaseNode::HasChildren() const {
192 syncable::Directory* dir = GetTransaction()->GetDirectory(); 192 syncable::Directory* dir = GetTransaction()->GetDirectory();
193 syncable::BaseTransaction* trans = GetTransaction()->GetWrappedTrans(); 193 syncable::BaseTransaction* trans = GetTransaction()->GetWrappedTrans();
194 return dir->HasChildren(trans, GetEntry()->Get(syncable::ID)); 194 return dir->HasChildren(trans, GetEntry()->Get(syncable::ID));
195 } 195 }
196 196
197 int64 BaseNode::GetPredecessorId() const { 197 int64 BaseNode::GetPredecessorId() const {
198 syncable::Id id_string = GetEntry()->Get(syncable::PREV_ID); 198 syncable::Id id_string = GetEntry()->GetPredecessorId();
199 if (id_string.IsRoot()) 199 if (id_string.IsRoot())
200 return kInvalidId; 200 return kInvalidId;
201 return IdToMetahandle(GetTransaction()->GetWrappedTrans(), id_string); 201 return IdToMetahandle(GetTransaction()->GetWrappedTrans(), id_string);
202 } 202 }
203 203
204 int64 BaseNode::GetSuccessorId() const { 204 int64 BaseNode::GetSuccessorId() const {
205 syncable::Id id_string = GetEntry()->Get(syncable::NEXT_ID); 205 syncable::Id id_string = GetEntry()->GetSuccessorId();
206 if (id_string.IsRoot()) 206 if (id_string.IsRoot())
207 return kInvalidId; 207 return kInvalidId;
208 return IdToMetahandle(GetTransaction()->GetWrappedTrans(), id_string); 208 return IdToMetahandle(GetTransaction()->GetWrappedTrans(), id_string);
209 } 209 }
210 210
211 int64 BaseNode::GetFirstChildId() const { 211 int64 BaseNode::GetFirstChildId() const {
212 syncable::Directory* dir = GetTransaction()->GetDirectory(); 212 syncable::Directory* dir = GetTransaction()->GetDirectory();
213 syncable::BaseTransaction* trans = GetTransaction()->GetWrappedTrans(); 213 syncable::BaseTransaction* trans = GetTransaction()->GetWrappedTrans();
214 syncable::Id id_string; 214 syncable::Id id_string;
215 // TODO(akalin): Propagate up the error further (see 215 // TODO(akalin): Propagate up the error further (see
(...skipping 19 matching lines...) Expand all
235 if (handle == kInvalidId) 235 if (handle == kInvalidId)
236 continue; 236 continue;
237 count++; 237 count++;
238 syncable::Entry entry(trans, syncable::GET_BY_HANDLE, handle); 238 syncable::Entry entry(trans, syncable::GET_BY_HANDLE, handle);
239 if (!entry.good()) 239 if (!entry.good())
240 continue; 240 continue;
241 syncable::Id id = entry.Get(syncable::ID); 241 syncable::Id id = entry.Get(syncable::ID);
242 syncable::Id child_id; 242 syncable::Id child_id;
243 if (dir->GetFirstChildId(trans, id, &child_id) && !child_id.IsRoot()) 243 if (dir->GetFirstChildId(trans, id, &child_id) && !child_id.IsRoot())
244 stack.push(IdToMetahandle(trans, child_id)); 244 stack.push(IdToMetahandle(trans, child_id));
245 syncable::Id successor_id = entry.Get(syncable::NEXT_ID); 245 syncable::Id successor_id = entry.GetSuccessorId();
246 if (!successor_id.IsRoot()) 246 if (!successor_id.IsRoot())
247 stack.push(IdToMetahandle(trans, successor_id)); 247 stack.push(IdToMetahandle(trans, successor_id));
248 } 248 }
249 return count; 249 return count;
250 } 250 }
251 251
252 DictionaryValue* BaseNode::GetSummaryAsValue() const { 252 DictionaryValue* BaseNode::GetSummaryAsValue() const {
253 DictionaryValue* node_info = new DictionaryValue(); 253 DictionaryValue* node_info = new DictionaryValue();
254 node_info->SetString("id", base::Int64ToString(GetId())); 254 node_info->SetString("id", base::Int64ToString(GetId()));
255 node_info->SetBoolean("isFolder", GetIsFolder()); 255 node_info->SetBoolean("isFolder", GetIsFolder());
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 const sync_pb::EntitySpecifics& specifics) { 355 const sync_pb::EntitySpecifics& specifics) {
356 ModelType type = GetModelTypeFromSpecifics(specifics); 356 ModelType type = GetModelTypeFromSpecifics(specifics);
357 DCHECK_NE(UNSPECIFIED, type); 357 DCHECK_NE(UNSPECIFIED, type);
358 if (GetModelType() != UNSPECIFIED) { 358 if (GetModelType() != UNSPECIFIED) {
359 DCHECK_EQ(GetModelType(), type); 359 DCHECK_EQ(GetModelType(), type);
360 } 360 }
361 unencrypted_data_.CopyFrom(specifics); 361 unencrypted_data_.CopyFrom(specifics);
362 } 362 }
363 363
364 } // namespace syncer 364 } // namespace syncer
OLDNEW
« no previous file with comments | « sync/engine/syncer_util.cc ('k') | sync/internal_api/change_reorder_buffer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698