| OLD | NEW |
| 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 "components/sync/syncable/parent_child_index.h" | 5 #include "components/sync/syncable/parent_child_index.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
| 10 #include "components/sync/syncable/entry_kernel.h" | 10 #include "components/sync/syncable/entry_kernel.h" |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 } | 160 } |
| 161 | 161 |
| 162 const OrderedChildSet* ParentChildIndex::GetSiblings(EntryKernel* e) const { | 162 const OrderedChildSet* ParentChildIndex::GetSiblings(EntryKernel* e) const { |
| 163 // This implies the entry is in the index. | 163 // This implies the entry is in the index. |
| 164 DCHECK(Contains(e)); | 164 DCHECK(Contains(e)); |
| 165 const OrderedChildSetRef siblings = GetChildSet(e); | 165 const OrderedChildSetRef siblings = GetChildSet(e); |
| 166 DCHECK(siblings && !siblings->empty()); | 166 DCHECK(siblings && !siblings->empty()); |
| 167 return siblings.get(); | 167 return siblings.get(); |
| 168 } | 168 } |
| 169 | 169 |
| 170 size_t ParentChildIndex::EstimateMemoryUsage() const { |
| 171 using base::trace_event::EstimateMemoryUsage; |
| 172 return EstimateMemoryUsage(parent_children_map_) + |
| 173 EstimateMemoryUsage(model_type_root_ids_) + |
| 174 EstimateMemoryUsage(type_root_child_sets_); |
| 175 } |
| 176 |
| 170 /* static */ | 177 /* static */ |
| 171 bool ParentChildIndex::ShouldUseParentId(const Id& parent_id, | 178 bool ParentChildIndex::ShouldUseParentId(const Id& parent_id, |
| 172 ModelType model_type) { | 179 ModelType model_type) { |
| 173 // For compatibility with legacy unit tests, in addition to hierarchical | 180 // For compatibility with legacy unit tests, in addition to hierarchical |
| 174 // entries, this returns true any entries directly under root and for entries | 181 // entries, this returns true any entries directly under root and for entries |
| 175 // of UNSPECIFIED model type. | 182 // of UNSPECIFIED model type. |
| 176 return parent_id.IsRoot() || TypeSupportsHierarchy(model_type) || | 183 return parent_id.IsRoot() || TypeSupportsHierarchy(model_type) || |
| 177 !IsRealDataType(model_type); | 184 !IsRealDataType(model_type); |
| 178 } | 185 } |
| 179 | 186 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 205 OrderedChildSetRef(new OrderedChildSet()); | 212 OrderedChildSetRef(new OrderedChildSet()); |
| 206 return type_root_child_sets_[model_type]; | 213 return type_root_child_sets_[model_type]; |
| 207 } | 214 } |
| 208 | 215 |
| 209 const Id& ParentChildIndex::GetModelTypeRootId(ModelType model_type) const { | 216 const Id& ParentChildIndex::GetModelTypeRootId(ModelType model_type) const { |
| 210 return model_type_root_ids_[model_type]; | 217 return model_type_root_ids_[model_type]; |
| 211 } | 218 } |
| 212 | 219 |
| 213 } // namespace syncable | 220 } // namespace syncable |
| 214 } // namespace syncer | 221 } // namespace syncer |
| OLD | NEW |