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 "sync/syncable/parent_child_index.h" | 5 #include "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 "sync/syncable/entry_kernel.h" |
10 #include "sync/syncable/syncable_id.h" | 10 #include "sync/syncable/syncable_id.h" |
(...skipping 16 matching lines...) Expand all Loading... |
27 // move all invalid position items to the right. | 27 // move all invalid position items to the right. |
28 return true; | 28 return true; |
29 } else if (!a_pos.IsValid() && b_pos.IsValid()) { | 29 } else if (!a_pos.IsValid() && b_pos.IsValid()) { |
30 // TODO(rlarocque): Remove this case. | 30 // TODO(rlarocque): Remove this case. |
31 // Mirror of the above case. | 31 // Mirror of the above case. |
32 return false; | 32 return false; |
33 } else { | 33 } else { |
34 // Position doesn't matter. | 34 // Position doesn't matter. |
35 DCHECK(!a->ref(UNIQUE_POSITION).IsValid()); | 35 DCHECK(!a->ref(UNIQUE_POSITION).IsValid()); |
36 DCHECK(!b->ref(UNIQUE_POSITION).IsValid()); | 36 DCHECK(!b->ref(UNIQUE_POSITION).IsValid()); |
37 return a->ref(ID) < b->ref(ID); | 37 // Sort by META_HANDLE to ensure consistent order for testing. |
| 38 return a->ref(META_HANDLE) < b->ref(META_HANDLE); |
38 } | 39 } |
39 } | 40 } |
40 | 41 |
41 ParentChildIndex::ParentChildIndex() { | 42 ParentChildIndex::ParentChildIndex() { |
42 } | 43 } |
43 | 44 |
44 ParentChildIndex::~ParentChildIndex() { | 45 ParentChildIndex::~ParentChildIndex() { |
45 STLDeleteContainerPairSecondPointers( | 46 STLDeleteContainerPairSecondPointers( |
46 parent_children_map_.begin(), parent_children_map_.end()); | 47 parent_children_map_.begin(), parent_children_map_.end()); |
47 } | 48 } |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 } | 163 } |
163 | 164 |
164 const Id& ParentChildIndex::GetModelTypeRootId(ModelType model_type) const { | 165 const Id& ParentChildIndex::GetModelTypeRootId(ModelType model_type) const { |
165 // TODO(stanisc): Review whether this approach is reliable enough. | 166 // TODO(stanisc): Review whether this approach is reliable enough. |
166 // Should this method simply enumerate children of root node ("r") instead? | 167 // Should this method simply enumerate children of root node ("r") instead? |
167 return model_type_root_ids_[model_type]; | 168 return model_type_root_ids_[model_type]; |
168 } | 169 } |
169 | 170 |
170 } // namespace syncable | 171 } // namespace syncable |
171 } // namespace syncer | 172 } // namespace syncer |
OLD | NEW |