| 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/internal_api/change_reorder_buffer.h" | 5 #include "sync/internal_api/change_reorder_buffer.h" |
| 6 | 6 |
| 7 #include <limits> | 7 #include <limits> |
| 8 #include <queue> | 8 #include <queue> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <utility> // for pair<> | 10 #include <utility> // for pair<> |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 Traversal::LinkSet::const_iterator j = traversal.begin_children(next); | 193 Traversal::LinkSet::const_iterator j = traversal.begin_children(next); |
| 194 Traversal::LinkSet::const_iterator end = traversal.end_children(next); | 194 Traversal::LinkSet::const_iterator end = traversal.end_children(next); |
| 195 for (; j != end; ++j) { | 195 for (; j != end; ++j) { |
| 196 CHECK(j->first == next); | 196 CHECK(j->first == next); |
| 197 to_visit.push(j->second); | 197 to_visit.push(j->second); |
| 198 } | 198 } |
| 199 } else { | 199 } else { |
| 200 // There were ordering changes on the children of this parent, so | 200 // There were ordering changes on the children of this parent, so |
| 201 // enumerate all the children in the sibling order. | 201 // enumerate all the children in the sibling order. |
| 202 syncable::Entry parent(trans, syncable::GET_BY_HANDLE, next); | 202 syncable::Entry parent(trans, syncable::GET_BY_HANDLE, next); |
| 203 syncable::Id id; | 203 syncable::Id id = parent.GetFirstChildId(); |
| 204 if (!trans->directory()->GetFirstChildId( | |
| 205 trans, parent.Get(syncable::ID), &id)) { | |
| 206 *changes = ImmutableChangeRecordList(); | |
| 207 return false; | |
| 208 } | |
| 209 while (!id.IsRoot()) { | 204 while (!id.IsRoot()) { |
| 210 syncable::Entry child(trans, syncable::GET_BY_ID, id); | 205 syncable::Entry child(trans, syncable::GET_BY_ID, id); |
| 211 CHECK(child.good()); | 206 CHECK(child.good()); |
| 212 int64 handle = child.Get(syncable::META_HANDLE); | 207 int64 handle = child.Get(syncable::META_HANDLE); |
| 213 to_visit.push(handle); | 208 to_visit.push(handle); |
| 214 // If there is no operation on this child node, record it as as an | 209 // If there is no operation on this child node, record it as as an |
| 215 // update, so that the listener gets notified of all nodes in the new | 210 // update, so that the listener gets notified of all nodes in the new |
| 216 // ordering. | 211 // ordering. |
| 217 if (operations_.find(handle) == operations_.end()) | 212 if (operations_.find(handle) == operations_.end()) |
| 218 operations_[handle] = OP_UPDATE_POSITION_AND_PROPERTIES; | 213 operations_[handle] = OP_UPDATE_POSITION_AND_PROPERTIES; |
| 219 id = child.Get(syncable::NEXT_ID); | 214 id = child.GetSuccessorId(); |
| 220 } | 215 } |
| 221 } | 216 } |
| 222 } | 217 } |
| 223 | 218 |
| 224 *changes = ImmutableChangeRecordList(&changelist); | 219 *changes = ImmutableChangeRecordList(&changelist); |
| 225 return true; | 220 return true; |
| 226 } | 221 } |
| 227 | 222 |
| 228 } // namespace syncer | 223 } // namespace syncer |
| OLD | NEW |