OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "mojo/services/public/cpp/view_manager/lib/view_manager_synchronizer.h" | 5 #include "mojo/services/public/cpp/view_manager/lib/view_manager_synchronizer.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/message_loop/message_loop.h" | |
9 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
10 #include "mojo/public/cpp/shell/service.h" | 9 #include "mojo/public/cpp/shell/service.h" |
11 #include "mojo/public/interfaces/shell/shell.mojom.h" | 10 #include "mojo/public/interfaces/shell/shell.mojom.h" |
12 #include "mojo/services/public/cpp/view_manager/lib/view_manager_private.h" | 11 #include "mojo/services/public/cpp/view_manager/lib/view_manager_private.h" |
13 #include "mojo/services/public/cpp/view_manager/lib/view_tree_node_private.h" | 12 #include "mojo/services/public/cpp/view_manager/lib/view_tree_node_private.h" |
14 #include "mojo/services/public/cpp/view_manager/util.h" | 13 #include "mojo/services/public/cpp/view_manager/util.h" |
15 | 14 |
16 namespace mojo { | 15 namespace mojo { |
17 namespace services { | 16 namespace services { |
18 namespace view_manager { | 17 namespace view_manager { |
19 | 18 |
20 TransportNodeId MakeTransportNodeId(uint16_t connection_id, | 19 TransportNodeId MakeTransportNodeId(uint16_t connection_id, |
21 uint16_t local_node_id) { | 20 uint16_t local_node_id) { |
22 return (connection_id << 16) | local_node_id; | 21 return (connection_id << 16) | local_node_id; |
23 } | 22 } |
24 | 23 |
25 class ViewManagerTransaction { | 24 class ViewManagerTransaction { |
26 public: | 25 public: |
27 virtual ~ViewManagerTransaction() {} | 26 virtual ~ViewManagerTransaction() {} |
28 | 27 |
29 void Commit() { | 28 void Commit() { |
30 DCHECK(!committed_); | 29 DCHECK(!committed_); |
31 DoCommit(); | 30 DoCommit(); |
32 committed_ = true; | 31 committed_ = true; |
33 } | 32 } |
34 | 33 |
35 bool committed() const { return committed_; } | 34 bool committed() const { return committed_; } |
36 uint32_t change_id() const { return change_id_; } | 35 TransportChangeId client_change_id() const { return client_change_id_; } |
37 | 36 |
38 // General callback to be used for commits to the service. | 37 // General callback to be used for commits to the service. |
39 void OnActionCompleted(bool success) { | 38 void OnActionCompleted(bool success) { |
40 DCHECK(success); | 39 DCHECK(success); |
41 DoActionCompleted(success); | 40 DoActionCompleted(success); |
42 synchronizer_->RemoveFromPendingQueue(this); | 41 synchronizer_->RemoveFromPendingQueue(this); |
43 } | 42 } |
44 | 43 |
45 protected: | 44 protected: |
46 enum TransactionType { | 45 enum TransactionType { |
47 // Node creation and destruction. | 46 // Node creation and destruction. |
48 TYPE_CREATE_VIEW_TREE_NODE, | 47 TYPE_CREATE_VIEW_TREE_NODE, |
49 TYPE_DESTROY_VIEW_TREE_NODE, | 48 TYPE_DESTROY_VIEW_TREE_NODE, |
50 // Modifications to the hierarchy (addition of or removal of nodes from a | 49 // Modifications to the hierarchy (addition of or removal of nodes from a |
51 // parent.) | 50 // parent.) |
52 TYPE_HIERARCHY | 51 TYPE_HIERARCHY |
53 }; | 52 }; |
54 | 53 |
55 ViewManagerTransaction(TransactionType transaction_type, | 54 ViewManagerTransaction(TransactionType transaction_type, |
56 ViewManagerSynchronizer* synchronizer) | 55 ViewManagerSynchronizer* synchronizer) |
57 : transaction_type_(transaction_type), | 56 : transaction_type_(transaction_type), |
58 change_id_(synchronizer->GetNextChangeId()), | 57 client_change_id_(synchronizer->GetNextClientChangeId()), |
59 committed_(false), | 58 committed_(false), |
60 synchronizer_(synchronizer) { | 59 synchronizer_(synchronizer) { |
61 } | 60 } |
62 | 61 |
63 // Overridden to perform transaction-specific commit actions. | 62 // Overridden to perform transaction-specific commit actions. |
64 virtual void DoCommit() = 0; | 63 virtual void DoCommit() = 0; |
65 | 64 |
66 // Overridden to perform transaction-specific cleanup on commit ack from the | 65 // Overridden to perform transaction-specific cleanup on commit ack from the |
67 // service. | 66 // service. |
68 virtual void DoActionCompleted(bool success) = 0; | 67 virtual void DoActionCompleted(bool success) = 0; |
69 | 68 |
70 IViewManager* service() { return synchronizer_->service_.get(); } | 69 IViewManager* service() { return synchronizer_->service_.get(); } |
71 | 70 |
| 71 TransportChangeId GetAndAdvanceNextServerChangeId() { |
| 72 return synchronizer_->next_server_change_id_++; |
| 73 } |
| 74 |
72 private: | 75 private: |
73 const TransactionType transaction_type_; | 76 const TransactionType transaction_type_; |
74 const uint32_t change_id_; | 77 const uint32_t client_change_id_; |
75 bool committed_; | 78 bool committed_; |
76 ViewManagerSynchronizer* synchronizer_; | 79 ViewManagerSynchronizer* synchronizer_; |
77 | 80 |
78 DISALLOW_COPY_AND_ASSIGN(ViewManagerTransaction); | 81 DISALLOW_COPY_AND_ASSIGN(ViewManagerTransaction); |
79 }; | 82 }; |
80 | 83 |
81 class CreateViewTreeNodeTransaction : public ViewManagerTransaction { | 84 class CreateViewTreeNodeTransaction : public ViewManagerTransaction { |
82 public: | 85 public: |
83 CreateViewTreeNodeTransaction(uint16_t node_id, | 86 CreateViewTreeNodeTransaction(uint16_t node_id, |
84 ViewManagerSynchronizer* synchronizer) | 87 ViewManagerSynchronizer* synchronizer) |
85 : ViewManagerTransaction(TYPE_CREATE_VIEW_TREE_NODE, synchronizer), | 88 : ViewManagerTransaction(TYPE_CREATE_VIEW_TREE_NODE, synchronizer), |
86 node_id_(node_id) {} | 89 node_id_(node_id) {} |
87 virtual ~CreateViewTreeNodeTransaction() {} | 90 virtual ~CreateViewTreeNodeTransaction() {} |
88 | 91 |
89 private: | 92 private: |
90 // Overridden from ViewManagerTransaction: | 93 // Overridden from ViewManagerTransaction: |
91 virtual void DoCommit() OVERRIDE { | 94 virtual void DoCommit() OVERRIDE { |
92 service()->CreateNode( | 95 service()->CreateNode( |
93 node_id_, | 96 node_id_, |
94 base::Bind(&ViewManagerTransaction::OnActionCompleted, | 97 base::Bind(&ViewManagerTransaction::OnActionCompleted, |
95 base::Unretained(this))); | 98 base::Unretained(this))); |
96 } | 99 } |
97 virtual void DoActionCompleted(bool success) OVERRIDE { | 100 virtual void DoActionCompleted(bool success) OVERRIDE { |
98 // TODO(beng): Failure means we tried to create with an extant id for this | 101 // TODO(beng): Failure means we tried to create with an extant id for this |
99 // connection. Figure out what to do. | 102 // connection. It also could mean we tried to do something |
| 103 // invalid, or we tried applying a change out of order. Figure |
| 104 // out what to do. |
100 } | 105 } |
101 | 106 |
102 const uint16_t node_id_; | 107 const uint16_t node_id_; |
103 | 108 |
104 DISALLOW_COPY_AND_ASSIGN(CreateViewTreeNodeTransaction); | 109 DISALLOW_COPY_AND_ASSIGN(CreateViewTreeNodeTransaction); |
105 }; | 110 }; |
106 | 111 |
107 class DestroyViewTreeNodeTransaction : public ViewManagerTransaction { | 112 class DestroyViewTreeNodeTransaction : public ViewManagerTransaction { |
108 public: | 113 public: |
109 DestroyViewTreeNodeTransaction(TransportNodeId node_id, | 114 DestroyViewTreeNodeTransaction(TransportNodeId node_id, |
110 ViewManagerSynchronizer* synchronizer) | 115 ViewManagerSynchronizer* synchronizer) |
111 : ViewManagerTransaction(TYPE_DESTROY_VIEW_TREE_NODE, synchronizer), | 116 : ViewManagerTransaction(TYPE_DESTROY_VIEW_TREE_NODE, synchronizer), |
112 node_id_(node_id) {} | 117 node_id_(node_id) {} |
113 virtual ~DestroyViewTreeNodeTransaction() {} | 118 virtual ~DestroyViewTreeNodeTransaction() {} |
114 | 119 |
115 private: | 120 private: |
116 // Overridden from ViewManagerTransaction: | 121 // Overridden from ViewManagerTransaction: |
117 virtual void DoCommit() OVERRIDE { | 122 virtual void DoCommit() OVERRIDE { |
118 service()->DeleteNode( | 123 service()->DeleteNode( |
119 node_id_, | 124 node_id_, |
120 change_id(), | 125 client_change_id(), |
121 base::Bind(&ViewManagerTransaction::OnActionCompleted, | 126 base::Bind(&ViewManagerTransaction::OnActionCompleted, |
122 base::Unretained(this))); | 127 base::Unretained(this))); |
123 } | 128 } |
124 virtual void DoActionCompleted(bool success) OVERRIDE { | 129 virtual void DoActionCompleted(bool success) OVERRIDE { |
125 // TODO(beng): recovery? | 130 // TODO(beng): recovery? |
126 } | 131 } |
127 | 132 |
128 TransportNodeId node_id_; | 133 TransportNodeId node_id_; |
129 DISALLOW_COPY_AND_ASSIGN(DestroyViewTreeNodeTransaction); | 134 DISALLOW_COPY_AND_ASSIGN(DestroyViewTreeNodeTransaction); |
130 }; | 135 }; |
(...skipping 15 matching lines...) Expand all Loading... |
146 virtual ~HierarchyTransaction() {} | 151 virtual ~HierarchyTransaction() {} |
147 | 152 |
148 private: | 153 private: |
149 // Overridden from ViewManagerTransaction: | 154 // Overridden from ViewManagerTransaction: |
150 virtual void DoCommit() OVERRIDE { | 155 virtual void DoCommit() OVERRIDE { |
151 switch (hierarchy_change_type_) { | 156 switch (hierarchy_change_type_) { |
152 case TYPE_ADD: | 157 case TYPE_ADD: |
153 service()->AddNode( | 158 service()->AddNode( |
154 parent_id_, | 159 parent_id_, |
155 child_id_, | 160 child_id_, |
156 change_id(), | 161 GetAndAdvanceNextServerChangeId(), |
| 162 client_change_id(), |
157 base::Bind(&ViewManagerTransaction::OnActionCompleted, | 163 base::Bind(&ViewManagerTransaction::OnActionCompleted, |
158 base::Unretained(this))); | 164 base::Unretained(this))); |
159 break; | 165 break; |
160 case TYPE_REMOVE: | 166 case TYPE_REMOVE: |
161 service()->RemoveNodeFromParent( | 167 service()->RemoveNodeFromParent( |
162 child_id_, | 168 child_id_, |
163 change_id(), | 169 GetAndAdvanceNextServerChangeId(), |
| 170 client_change_id(), |
164 base::Bind(&ViewManagerTransaction::OnActionCompleted, | 171 base::Bind(&ViewManagerTransaction::OnActionCompleted, |
165 base::Unretained(this))); | 172 base::Unretained(this))); |
166 break; | 173 break; |
167 } | 174 } |
168 } | 175 } |
169 | 176 |
170 virtual void DoActionCompleted(bool success) OVERRIDE { | 177 virtual void DoActionCompleted(bool success) OVERRIDE { |
171 // TODO(beng): Failure means either one of the nodes specified didn't exist, | 178 // TODO(beng): Failure means either one of the nodes specified didn't exist, |
172 // or we passed the same node id for both params. Roll back? | 179 // or we passed the same node id for both params. Roll back? |
173 } | 180 } |
174 | 181 |
175 const HierarchyChangeType hierarchy_change_type_; | 182 const HierarchyChangeType hierarchy_change_type_; |
176 const TransportNodeId child_id_; | 183 const TransportNodeId child_id_; |
177 const TransportNodeId parent_id_; | 184 const TransportNodeId parent_id_; |
178 | 185 |
179 DISALLOW_COPY_AND_ASSIGN(HierarchyTransaction); | 186 DISALLOW_COPY_AND_ASSIGN(HierarchyTransaction); |
180 }; | 187 }; |
181 | 188 |
182 ViewManagerSynchronizer::ViewManagerSynchronizer(ViewManager* view_manager) | 189 ViewManagerSynchronizer::ViewManagerSynchronizer(ViewManager* view_manager) |
183 : view_manager_(view_manager), | 190 : view_manager_(view_manager), |
184 connected_(false), | 191 connected_(false), |
185 connection_id_(0), | 192 connection_id_(0), |
186 next_id_(1), | 193 next_id_(1), |
187 next_change_id_(0), | 194 next_client_change_id_(0), |
| 195 next_server_change_id_(0), |
188 sync_factory_(this), | 196 sync_factory_(this), |
189 init_loop_(NULL) { | 197 init_loop_(NULL) { |
190 ConnectTo(ViewManagerPrivate(view_manager_).shell(), "mojo:mojo_view_manager", | 198 ConnectTo(ViewManagerPrivate(view_manager_).shell(), "mojo:mojo_view_manager", |
191 &service_); | 199 &service_); |
192 service_->SetClient(this); | 200 service_->SetClient(this); |
193 | 201 |
194 AllocationScope scope; | 202 AllocationScope scope; |
195 service_->GetNodeTree( | 203 service_->GetNodeTree( |
196 1, | 204 1, |
197 base::Bind(&ViewManagerSynchronizer::OnRootTreeReceived, | 205 base::Bind(&ViewManagerSynchronizer::OnRootTreeReceived, |
198 base::Unretained(this))); | 206 base::Unretained(this))); |
199 | 207 |
200 base::RunLoop loop; | 208 base::RunLoop loop; |
201 init_loop_ = &loop; | 209 init_loop_ = &loop; |
202 init_loop_->Run(); | 210 init_loop_->Run(); |
203 init_loop_ = NULL; | 211 init_loop_ = NULL; |
204 } | 212 } |
205 | 213 |
206 ViewManagerSynchronizer::~ViewManagerSynchronizer() { | 214 ViewManagerSynchronizer::~ViewManagerSynchronizer() { |
207 DoSync(); | 215 Sync(); |
208 } | 216 } |
209 | 217 |
210 TransportNodeId ViewManagerSynchronizer::CreateViewTreeNode() { | 218 TransportNodeId ViewManagerSynchronizer::CreateViewTreeNode() { |
211 DCHECK(connected_); | 219 DCHECK(connected_); |
212 uint16_t id = ++next_id_; | 220 uint16_t id = ++next_id_; |
213 pending_transactions_.push_back(new CreateViewTreeNodeTransaction(id, this)); | 221 pending_transactions_.push_back(new CreateViewTreeNodeTransaction(id, this)); |
214 ScheduleSync(); | 222 Sync(); |
215 return MakeTransportNodeId(connection_id_, id); | 223 return MakeTransportNodeId(connection_id_, id); |
216 } | 224 } |
217 | 225 |
218 void ViewManagerSynchronizer::DestroyViewTreeNode(TransportNodeId node_id) { | 226 void ViewManagerSynchronizer::DestroyViewTreeNode(TransportNodeId node_id) { |
219 DCHECK(connected_); | 227 DCHECK(connected_); |
220 pending_transactions_.push_back( | 228 pending_transactions_.push_back( |
221 new DestroyViewTreeNodeTransaction(node_id, this)); | 229 new DestroyViewTreeNodeTransaction(node_id, this)); |
222 ScheduleSync(); | 230 Sync(); |
223 } | 231 } |
224 | 232 |
225 void ViewManagerSynchronizer::AddChild(TransportNodeId child_id, | 233 void ViewManagerSynchronizer::AddChild(TransportNodeId child_id, |
226 TransportNodeId parent_id) { | 234 TransportNodeId parent_id) { |
227 DCHECK(connected_); | 235 DCHECK(connected_); |
228 pending_transactions_.push_back( | 236 pending_transactions_.push_back( |
229 new HierarchyTransaction(HierarchyTransaction::TYPE_ADD, | 237 new HierarchyTransaction(HierarchyTransaction::TYPE_ADD, |
230 child_id, | 238 child_id, |
231 parent_id, | 239 parent_id, |
232 this)); | 240 this)); |
233 ScheduleSync(); | 241 Sync(); |
234 } | 242 } |
235 | 243 |
236 void ViewManagerSynchronizer::RemoveChild(TransportNodeId child_id, | 244 void ViewManagerSynchronizer::RemoveChild(TransportNodeId child_id, |
237 TransportNodeId parent_id) { | 245 TransportNodeId parent_id) { |
238 DCHECK(connected_); | 246 DCHECK(connected_); |
239 pending_transactions_.push_back( | 247 pending_transactions_.push_back( |
240 new HierarchyTransaction(HierarchyTransaction::TYPE_REMOVE, | 248 new HierarchyTransaction(HierarchyTransaction::TYPE_REMOVE, |
241 child_id, | 249 child_id, |
242 parent_id, | 250 parent_id, |
243 this)); | 251 this)); |
244 ScheduleSync(); | 252 Sync(); |
245 } | 253 } |
246 | 254 |
247 bool ViewManagerSynchronizer::OwnsNode(TransportNodeId id) const { | 255 bool ViewManagerSynchronizer::OwnsNode(TransportNodeId id) const { |
248 return HiWord(id) == connection_id_; | 256 return HiWord(id) == connection_id_; |
249 } | 257 } |
250 | 258 |
251 //////////////////////////////////////////////////////////////////////////////// | 259 //////////////////////////////////////////////////////////////////////////////// |
252 // ViewManagerSynchronizer, IViewManagerClient implementation: | 260 // ViewManagerSynchronizer, IViewManagerClient implementation: |
253 | 261 |
254 void ViewManagerSynchronizer::OnConnectionEstablished(uint16 connection_id) { | 262 void ViewManagerSynchronizer::OnConnectionEstablished( |
| 263 TransportConnectionId connection_id, |
| 264 TransportChangeId next_server_change_id) { |
255 connected_ = true; | 265 connected_ = true; |
256 connection_id_ = connection_id; | 266 connection_id_ = connection_id; |
257 ScheduleSync(); | 267 next_server_change_id_ = next_server_change_id; |
| 268 Sync(); |
258 } | 269 } |
259 | 270 |
260 void ViewManagerSynchronizer::OnNodeHierarchyChanged(uint32_t node_id, | 271 void ViewManagerSynchronizer::OnNodeHierarchyChanged( |
261 uint32_t new_parent_id, | 272 uint32_t node_id, |
262 uint32_t old_parent_id, | 273 uint32_t new_parent_id, |
263 uint32_t change_id) { | 274 uint32_t old_parent_id, |
264 if (change_id == 0) { | 275 TransportChangeId server_change_id, |
265 ViewTreeNode* new_parent = view_manager_->GetNodeById(new_parent_id); | 276 TransportChangeId client_change_id) { |
266 ViewTreeNode* old_parent = view_manager_->GetNodeById(old_parent_id); | 277 if (client_change_id == 0) { |
| 278 // Change originated from another client. |
| 279 ViewTreeNode* new_parent = |
| 280 view_manager_->tree()->GetChildById(new_parent_id); |
| 281 ViewTreeNode* old_parent = |
| 282 view_manager_->tree()->GetChildById(old_parent_id); |
267 ViewTreeNode* node = NULL; | 283 ViewTreeNode* node = NULL; |
268 if (old_parent) { | 284 if (old_parent) { |
269 // Existing node, mapped in this connection's tree. | 285 // Existing node, mapped in this connection's tree. |
270 // TODO(beng): verify this is actually true. | 286 // TODO(beng): verify this is actually true. |
271 node = view_manager_->GetNodeById(node_id); | 287 node = view_manager_->GetNodeById(node_id); |
272 DCHECK_EQ(node->parent(), old_parent); | 288 DCHECK_EQ(node->parent(), old_parent); |
273 } else { | 289 } else { |
274 // New node, originating from another connection. | 290 // New node, originating from another connection. |
275 node = ViewTreeNodePrivate::LocalCreate(); | 291 node = ViewTreeNodePrivate::LocalCreate(); |
276 ViewTreeNodePrivate private_node(node); | 292 ViewTreeNodePrivate private_node(node); |
277 private_node.set_view_manager(view_manager_); | 293 private_node.set_view_manager(view_manager_); |
278 private_node.set_id(node_id); | 294 private_node.set_id(node_id); |
279 ViewManagerPrivate(view_manager_).AddNode(node->id(), node); | 295 ViewManagerPrivate(view_manager_).AddNode(node->id(), node); |
280 } | 296 } |
281 if (new_parent) | 297 if (new_parent) |
282 ViewTreeNodePrivate(new_parent).LocalAddChild(node); | 298 ViewTreeNodePrivate(new_parent).LocalAddChild(node); |
283 else | 299 else |
284 ViewTreeNodePrivate(old_parent).LocalRemoveChild(node); | 300 ViewTreeNodePrivate(old_parent).LocalRemoveChild(node); |
285 } | 301 } |
| 302 next_server_change_id_ = server_change_id + 1; |
| 303 } |
| 304 |
| 305 void ViewManagerSynchronizer::OnNodeDeleted( |
| 306 TransportNodeId node_id, |
| 307 TransportChangeId server_change_id, |
| 308 TransportChangeId client_change_id) { |
| 309 next_server_change_id_ = server_change_id + 1; |
| 310 if (client_change_id == 0) { |
| 311 ViewTreeNode* node = view_manager_->GetNodeById(node_id); |
| 312 if (node) |
| 313 ViewTreeNodePrivate(node).LocalDestroy(); |
| 314 } |
286 } | 315 } |
287 | 316 |
288 void ViewManagerSynchronizer::OnNodeViewReplaced(uint32_t node, | 317 void ViewManagerSynchronizer::OnNodeViewReplaced(uint32_t node, |
289 uint32_t new_view_id, | 318 uint32_t new_view_id, |
290 uint32_t old_view_id, | 319 uint32_t old_view_id, |
291 uint32_t change_id) { | 320 uint32_t client_change_id) { |
292 // .. | 321 // .. |
293 } | 322 } |
294 | 323 |
295 void ViewManagerSynchronizer::OnNodeDeleted(uint32_t node_id, | |
296 uint32_t change_id) { | |
297 if (change_id == 0) { | |
298 ViewTreeNode* node = view_manager_->GetNodeById(node_id); | |
299 if (node) | |
300 ViewTreeNodePrivate(node).LocalDestroy(); | |
301 } | |
302 } | |
303 | |
304 //////////////////////////////////////////////////////////////////////////////// | 324 //////////////////////////////////////////////////////////////////////////////// |
305 // ViewManagerSynchronizer, private: | 325 // ViewManagerSynchronizer, private: |
306 | 326 |
307 void ViewManagerSynchronizer::ScheduleSync() { | 327 void ViewManagerSynchronizer::Sync() { |
308 if (sync_factory_.HasWeakPtrs()) | |
309 return; | |
310 base::MessageLoop::current()->PostTask( | |
311 FROM_HERE, | |
312 base::Bind(&ViewManagerSynchronizer::DoSync, sync_factory_.GetWeakPtr())); | |
313 } | |
314 | |
315 void ViewManagerSynchronizer::DoSync() { | |
316 // The service connection may not be set up yet. OnConnectionEstablished() | 328 // The service connection may not be set up yet. OnConnectionEstablished() |
317 // will schedule another sync when it is. | 329 // will schedule another sync when it is. |
318 if (!connected_) | 330 if (!connected_) |
319 return; | 331 return; |
320 | 332 |
321 Transactions::const_iterator it = pending_transactions_.begin(); | 333 Transactions::const_iterator it = pending_transactions_.begin(); |
322 for (; it != pending_transactions_.end(); ++it) { | 334 for (; it != pending_transactions_.end(); ++it) { |
323 if (!(*it)->committed()) | 335 if (!(*it)->committed()) |
324 (*it)->Commit(); | 336 (*it)->Commit(); |
325 } | 337 } |
326 } | 338 } |
327 | 339 |
328 uint32_t ViewManagerSynchronizer::GetNextChangeId() { | 340 uint32_t ViewManagerSynchronizer::GetNextClientChangeId() { |
329 // TODO(beng): deal with change id collisions? Important in the "never ack'ed | 341 // TODO(beng): deal with change id collisions? Important in the "never ack'ed |
330 // change" case mentioned in OnNodeHierarchyChanged(). | 342 // change" case mentioned in OnNodeHierarchyChanged(). |
331 // "0" is a special value passed to other connected clients, so we can't use | 343 // "0" is a special value passed to other connected clients, so we can't use |
332 // it. | 344 // it. |
333 next_change_id_ = std::max(1u, next_change_id_ + 1); | 345 next_client_change_id_ = std::max(1u, next_client_change_id_ + 1); |
334 return next_change_id_; | 346 return next_client_change_id_; |
335 } | 347 } |
336 | 348 |
337 void ViewManagerSynchronizer::RemoveFromPendingQueue( | 349 void ViewManagerSynchronizer::RemoveFromPendingQueue( |
338 ViewManagerTransaction* transaction) { | 350 ViewManagerTransaction* transaction) { |
339 DCHECK_EQ(transaction, pending_transactions_.front()); | 351 DCHECK_EQ(transaction, pending_transactions_.front()); |
340 pending_transactions_.erase(pending_transactions_.begin()); | 352 pending_transactions_.erase(pending_transactions_.begin()); |
341 } | 353 } |
342 | 354 |
343 void ViewManagerSynchronizer::OnRootTreeReceived( | 355 void ViewManagerSynchronizer::OnRootTreeReceived( |
344 const Array<INode>& nodes) { | 356 const Array<INode>& nodes) { |
(...skipping 21 matching lines...) Expand all Loading... |
366 ViewManagerPrivate(view_manager_).AddNode(node->id(), node); | 378 ViewManagerPrivate(view_manager_).AddNode(node->id(), node); |
367 } | 379 } |
368 ViewManagerPrivate(view_manager_).set_root(root); | 380 ViewManagerPrivate(view_manager_).set_root(root); |
369 if (init_loop_) | 381 if (init_loop_) |
370 init_loop_->Quit(); | 382 init_loop_->Quit(); |
371 } | 383 } |
372 | 384 |
373 } // namespace view_manager | 385 } // namespace view_manager |
374 } // namespace services | 386 } // namespace services |
375 } // namespace mojo | 387 } // namespace mojo |
OLD | NEW |