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

Side by Side Diff: components/sync/syncable/parent_child_index.cc

Issue 2156693002: [Sync] //components/sync internal changes [DO NOT SUBMIT] (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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
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/syncable/parent_child_index.h" 5 #include "components/sync/syncable/parent_child_index.h"
6 6
7 #include "base/stl_util.h" 7 #include "base/stl_util.h"
8 8
9 #include "sync/syncable/entry_kernel.h" 9 #include "components/sync/syncable/entry_kernel.h"
10 #include "sync/syncable/syncable_id.h" 10 #include "components/sync/syncable/syncable_id.h"
11 11
12 namespace syncer { 12 namespace syncer {
13 namespace syncable { 13 namespace syncable {
14 14
15 bool ChildComparator::operator()(const EntryKernel* a, 15 bool ChildComparator::operator()(const EntryKernel* a,
16 const EntryKernel* b) const { 16 const EntryKernel* b) const {
17 const UniquePosition& a_pos = a->ref(UNIQUE_POSITION); 17 const UniquePosition& a_pos = a->ref(UNIQUE_POSITION);
18 const UniquePosition& b_pos = b->ref(UNIQUE_POSITION); 18 const UniquePosition& b_pos = b->ref(UNIQUE_POSITION);
19 19
20 if (a_pos.IsValid() && b_pos.IsValid()) { 20 if (a_pos.IsValid() && b_pos.IsValid()) {
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 // Erase the entry from the child set. 153 // Erase the entry from the child set.
154 siblings->erase(j); 154 siblings->erase(j);
155 // If the set is now empty and isn't shareable with |type_root_child_sets_|, 155 // If the set is now empty and isn't shareable with |type_root_child_sets_|,
156 // erase it from the map. 156 // erase it from the map.
157 if (siblings->empty() && should_erase) { 157 if (siblings->empty() && should_erase) {
158 delete siblings; 158 delete siblings;
159 parent_children_map_.erase(it); 159 parent_children_map_.erase(it);
160 } 160 }
161 } 161 }
162 162
163 bool ParentChildIndex::Contains(EntryKernel *e) const { 163 bool ParentChildIndex::Contains(EntryKernel* e) const {
164 const OrderedChildSet* siblings = GetChildSet(e); 164 const OrderedChildSet* siblings = GetChildSet(e);
165 return siblings && siblings->count(e) > 0; 165 return siblings && siblings->count(e) > 0;
166 } 166 }
167 167
168 const OrderedChildSet* ParentChildIndex::GetChildren(const Id& id) const { 168 const OrderedChildSet* ParentChildIndex::GetChildren(const Id& id) const {
169 DCHECK(!id.IsNull()); 169 DCHECK(!id.IsNull());
170 170
171 ParentChildrenMap::const_iterator parent = parent_children_map_.find(id); 171 ParentChildrenMap::const_iterator parent = parent_children_map_.find(id);
172 if (parent == parent_children_map_.end()) { 172 if (parent == parent_children_map_.end()) {
173 return nullptr; 173 return nullptr;
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 type_root_child_sets_[model_type] = new OrderedChildSet(); 230 type_root_child_sets_[model_type] = new OrderedChildSet();
231 return type_root_child_sets_[model_type]; 231 return type_root_child_sets_[model_type];
232 } 232 }
233 233
234 const Id& ParentChildIndex::GetModelTypeRootId(ModelType model_type) const { 234 const Id& ParentChildIndex::GetModelTypeRootId(ModelType model_type) const {
235 return model_type_root_ids_[model_type]; 235 return model_type_root_ids_[model_type];
236 } 236 }
237 237
238 } // namespace syncable 238 } // namespace syncable
239 } // namespace syncer 239 } // namespace syncer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698