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

Unified Diff: sync/syncable/parent_child_index.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 | « sync/syncable/parent_child_index.h ('k') | sync/syncable/parent_child_index_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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()) {
« no previous file with comments | « sync/syncable/parent_child_index.h ('k') | sync/syncable/parent_child_index_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698