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

Unified Diff: sync/syncable/directory.cc

Issue 1008993004: Sync: Handle empty (implicit) ParentId in GetPredecessorId and GetSuccessorId (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added extra unit test. Created 5 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | sync/syncable/directory_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sync/syncable/directory.cc
diff --git a/sync/syncable/directory.cc b/sync/syncable/directory.cc
index 12616959984419a1c9e5cae9f412c821305460dd..110000e62c9ae5f9520c519542b29d6452bb871e 100644
--- a/sync/syncable/directory.cc
+++ b/sync/syncable/directory.cc
@@ -334,7 +334,7 @@ int Directory::GetPositionIndex(
BaseTransaction* trans,
EntryKernel* kernel) const {
const OrderedChildSet* siblings =
- kernel_->parent_child_index.GetChildren(kernel->ref(PARENT_ID));
+ kernel_->parent_child_index.GetSiblings(kernel);
OrderedChildSet::const_iterator it = siblings->find(kernel);
return std::distance(siblings->begin(), it);
@@ -1360,13 +1360,11 @@ syncable::Id Directory::GetPredecessorId(EntryKernel* e) {
ScopedKernelLock lock(this);
DCHECK(ParentChildIndex::ShouldInclude(e));
- const OrderedChildSet* children =
- kernel_->parent_child_index.GetChildren(e->ref(PARENT_ID));
- DCHECK(children && !children->empty());
- OrderedChildSet::const_iterator i = children->find(e);
- DCHECK(i != children->end());
+ const OrderedChildSet* siblings = kernel_->parent_child_index.GetSiblings(e);
+ OrderedChildSet::const_iterator i = siblings->find(e);
+ DCHECK(i != siblings->end());
- if (i == children->begin()) {
+ if (i == siblings->begin()) {
return Id();
} else {
i--;
@@ -1378,14 +1376,12 @@ syncable::Id Directory::GetSuccessorId(EntryKernel* e) {
ScopedKernelLock lock(this);
DCHECK(ParentChildIndex::ShouldInclude(e));
- const OrderedChildSet* children =
- kernel_->parent_child_index.GetChildren(e->ref(PARENT_ID));
- DCHECK(children && !children->empty());
- OrderedChildSet::const_iterator i = children->find(e);
- DCHECK(i != children->end());
+ const OrderedChildSet* siblings = kernel_->parent_child_index.GetSiblings(e);
+ OrderedChildSet::const_iterator i = siblings->find(e);
+ DCHECK(i != siblings->end());
i++;
- if (i == children->end()) {
+ if (i == siblings->end()) {
return Id();
} else {
return (*i)->ref(ID);
« no previous file with comments | « no previous file | sync/syncable/directory_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698