Index: sync/syncable/parent_child_index.cc |
diff --git a/sync/syncable/parent_child_index.cc b/sync/syncable/parent_child_index.cc |
index f45bcfe1bdde313a730ba2784f9e4f642bb408e5..a144e6c65503f80ab6e45f7d8a5373f305a55533 100644 |
--- a/sync/syncable/parent_child_index.cc |
+++ b/sync/syncable/parent_child_index.cc |
@@ -120,8 +120,10 @@ bool ParentChildIndex::Contains(EntryKernel *e) const { |
return children->count(e) > 0; |
} |
-const OrderedChildSet* ParentChildIndex::GetChildren(const syncable::Id& id) { |
- ParentChildrenMap::iterator parent = parent_children_map_.find(id); |
+const OrderedChildSet* ParentChildIndex::GetChildren(const Id& id) const { |
+ DCHECK(!id.IsNull()); |
+ |
+ ParentChildrenMap::const_iterator parent = parent_children_map_.find(id); |
if (parent == parent_children_map_.end()) { |
return NULL; |
} |
@@ -131,6 +133,17 @@ const OrderedChildSet* ParentChildIndex::GetChildren(const syncable::Id& id) { |
return parent->second; |
} |
+const OrderedChildSet* ParentChildIndex::GetChildren(EntryKernel* e) const { |
+ return GetChildren(e->ref(ID)); |
+} |
+ |
+const OrderedChildSet* ParentChildIndex::GetSiblings(EntryKernel* e) const { |
+ DCHECK(Contains(e)); |
+ const OrderedChildSet* siblings = GetChildren(GetParentId(e)); |
+ DCHECK(siblings && !siblings->empty()); |
+ return siblings; |
+} |
+ |
const Id& ParentChildIndex::GetParentId(EntryKernel* e) const { |
const Id& parent_id = e->ref(PARENT_ID); |
if (!parent_id.IsNull()) { |