| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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/change_reorder_buffer.h" | 5 #include "components/sync/syncable/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 11 matching lines...) Expand all Loading... |
| 22 namespace syncer { | 22 namespace syncer { |
| 23 | 23 |
| 24 // Traversal provides a way to collect a set of nodes from the syncable | 24 // Traversal provides a way to collect a set of nodes from the syncable |
| 25 // directory structure and then traverse them, along with any intermediate | 25 // directory structure and then traverse them, along with any intermediate |
| 26 // nodes, in a top-down fashion, starting from a single common ancestor. A | 26 // nodes, in a top-down fashion, starting from a single common ancestor. A |
| 27 // Traversal starts out empty and is grown by means of the ExpandToInclude | 27 // Traversal starts out empty and is grown by means of the ExpandToInclude |
| 28 // method. Once constructed, the top(), begin_children(), and end_children() | 28 // method. Once constructed, the top(), begin_children(), and end_children() |
| 29 // methods can be used to explore the nodes in root-to-leaf order. | 29 // methods can be used to explore the nodes in root-to-leaf order. |
| 30 class ChangeReorderBuffer::Traversal { | 30 class ChangeReorderBuffer::Traversal { |
| 31 public: | 31 public: |
| 32 typedef pair<int64_t, int64_t> ParentChildLink; | 32 using ParentChildLink = pair<int64_t, int64_t>; |
| 33 typedef set<ParentChildLink> LinkSet; | 33 using LinkSet = set<ParentChildLink>; |
| 34 | 34 |
| 35 Traversal() : top_(kInvalidId) {} | 35 Traversal() : top_(kInvalidId) {} |
| 36 | 36 |
| 37 // Expand the traversal so that it includes the node indicated by | 37 // Expand the traversal so that it includes the node indicated by |
| 38 // |child_handle|. | 38 // |child_handle|. |
| 39 void ExpandToInclude(syncable::BaseTransaction* trans, int64_t child_handle) { | 39 void ExpandToInclude(syncable::BaseTransaction* trans, int64_t child_handle) { |
| 40 // If |top_| is invalid, this is the first insertion -- easy. | 40 // If |top_| is invalid, this is the first insertion -- easy. |
| 41 if (top_ == kInvalidId) { | 41 if (top_ == kInvalidId) { |
| 42 top_ = child_handle; | 42 top_ = child_handle; |
| 43 return; | 43 return; |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 CHECK(j->first == next); | 212 CHECK(j->first == next); |
| 213 to_visit.push(j->second); | 213 to_visit.push(j->second); |
| 214 } | 214 } |
| 215 } | 215 } |
| 216 | 216 |
| 217 *changes = ImmutableChangeRecordList(&changelist); | 217 *changes = ImmutableChangeRecordList(&changelist); |
| 218 return true; | 218 return true; |
| 219 } | 219 } |
| 220 | 220 |
| 221 } // namespace syncer | 221 } // namespace syncer |
| OLD | NEW |