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

Side by Side Diff: components/sync/core_impl/change_reorder_buffer.cc

Issue 2130453004: [Sync] Move //sync to //components/sync. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 4 years, 4 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 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 "sync/internal_api/change_reorder_buffer.h" 5 #include "components/sync/core_impl/change_reorder_buffer.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <limits> 9 #include <limits>
10 #include <queue> 10 #include <queue>
11 #include <set> 11 #include <set>
12 #include <utility> // for pair<> 12 #include <utility> // for pair<>
13 13
14 #include "base/macros.h" 14 #include "base/macros.h"
15 #include "sync/internal_api/public/base_node.h" 15 #include "components/sync/core/base_node.h"
16 #include "sync/internal_api/public/base_transaction.h" 16 #include "components/sync/core/base_transaction.h"
17 #include "sync/syncable/entry.h" 17 #include "components/sync/syncable/entry.h"
18 #include "sync/syncable/syncable_base_transaction.h" 18 #include "components/sync/syncable/syncable_base_transaction.h"
19 19
20 using std::numeric_limits; 20 using std::numeric_limits;
21 using std::pair; 21 using std::pair;
22 using std::queue; 22 using std::queue;
23 using std::set; 23 using std::set;
24 24
25 namespace syncer { 25 namespace syncer {
26 26
27 // Traversal provides a way to collect a set of nodes from the syncable 27 // Traversal provides a way to collect a set of nodes from the syncable
28 // directory structure and then traverse them, along with any intermediate 28 // directory structure and then traverse them, along with any intermediate
29 // nodes, in a top-down fashion, starting from a single common ancestor. A 29 // nodes, in a top-down fashion, starting from a single common ancestor. A
30 // Traversal starts out empty and is grown by means of the ExpandToInclude 30 // Traversal starts out empty and is grown by means of the ExpandToInclude
31 // method. Once constructed, the top(), begin_children(), and end_children() 31 // method. Once constructed, the top(), begin_children(), and end_children()
32 // methods can be used to explore the nodes in root-to-leaf order. 32 // methods can be used to explore the nodes in root-to-leaf order.
33 class ChangeReorderBuffer::Traversal { 33 class ChangeReorderBuffer::Traversal {
34 public: 34 public:
35 typedef pair<int64_t, int64_t> ParentChildLink; 35 typedef pair<int64_t, int64_t> ParentChildLink;
36 typedef set<ParentChildLink> LinkSet; 36 typedef set<ParentChildLink> LinkSet;
37 37
38 Traversal() : top_(kInvalidId) { } 38 Traversal() : top_(kInvalidId) {}
39 39
40 // Expand the traversal so that it includes the node indicated by 40 // Expand the traversal so that it includes the node indicated by
41 // |child_handle|. 41 // |child_handle|.
42 void ExpandToInclude(syncable::BaseTransaction* trans, int64_t child_handle) { 42 void ExpandToInclude(syncable::BaseTransaction* trans, int64_t child_handle) {
43 // If |top_| is invalid, this is the first insertion -- easy. 43 // If |top_| is invalid, this is the first insertion -- easy.
44 if (top_ == kInvalidId) { 44 if (top_ == kInvalidId) {
45 top_ = child_handle; 45 top_ = child_handle;
46 return; 46 return;
47 } 47 }
48 48
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 // (parent, child) ordering of values enables efficient lookup of children 116 // (parent, child) ordering of values enables efficient lookup of children
117 // given the parent handle, which is used for top-down traversal. |links_| 117 // given the parent handle, which is used for top-down traversal. |links_|
118 // is expected to be connected -- every node that appears as a parent in a 118 // is expected to be connected -- every node that appears as a parent in a
119 // link must either appear as a child of another link, or else be the 119 // link must either appear as a child of another link, or else be the
120 // topmost node, |top_|. 120 // topmost node, |top_|.
121 LinkSet links_; 121 LinkSet links_;
122 122
123 DISALLOW_COPY_AND_ASSIGN(Traversal); 123 DISALLOW_COPY_AND_ASSIGN(Traversal);
124 }; 124 };
125 125
126 ChangeReorderBuffer::ChangeReorderBuffer() { 126 ChangeReorderBuffer::ChangeReorderBuffer() {}
127 }
128 127
129 ChangeReorderBuffer::~ChangeReorderBuffer() { 128 ChangeReorderBuffer::~ChangeReorderBuffer() {}
130 }
131 129
132 void ChangeReorderBuffer::PushAddedItem(int64_t id) { 130 void ChangeReorderBuffer::PushAddedItem(int64_t id) {
133 operations_[id] = ChangeRecord::ACTION_ADD; 131 operations_[id] = ChangeRecord::ACTION_ADD;
134 } 132 }
135 133
136 void ChangeReorderBuffer::PushDeletedItem(int64_t id) { 134 void ChangeReorderBuffer::PushDeletedItem(int64_t id) {
137 operations_[id] = ChangeRecord::ACTION_DELETE; 135 operations_[id] = ChangeRecord::ACTION_DELETE;
138 } 136 }
139 137
140 void ChangeReorderBuffer::PushUpdatedItem(int64_t id) { 138 void ChangeReorderBuffer::PushUpdatedItem(int64_t id) {
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 CHECK(j->first == next); 215 CHECK(j->first == next);
218 to_visit.push(j->second); 216 to_visit.push(j->second);
219 } 217 }
220 } 218 }
221 219
222 *changes = ImmutableChangeRecordList(&changelist); 220 *changes = ImmutableChangeRecordList(&changelist);
223 return true; 221 return true;
224 } 222 }
225 223
226 } // namespace syncer 224 } // namespace syncer
OLDNEW
« no previous file with comments | « components/sync/core_impl/change_reorder_buffer.h ('k') | components/sync/core_impl/debug_info_event_listener.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698