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/run_loop.h" | 8 #include "base/run_loop.h" |
9 #include "mojo/public/cpp/shell/connect.h" | 9 #include "mojo/public/cpp/shell/connect.h" |
10 #include "mojo/public/interfaces/shell/shell.mojom.h" | 10 #include "mojo/public/interfaces/shell/shell.mojom.h" |
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
387 new SetActiveViewTransaction(node_id, view_id, this)); | 387 new SetActiveViewTransaction(node_id, view_id, this)); |
388 Sync(); | 388 Sync(); |
389 } | 389 } |
390 | 390 |
391 //////////////////////////////////////////////////////////////////////////////// | 391 //////////////////////////////////////////////////////////////////////////////// |
392 // ViewManagerSynchronizer, IViewManagerClient implementation: | 392 // ViewManagerSynchronizer, IViewManagerClient implementation: |
393 | 393 |
394 void ViewManagerSynchronizer::OnConnectionEstablished( | 394 void ViewManagerSynchronizer::OnConnectionEstablished( |
395 TransportConnectionId connection_id, | 395 TransportConnectionId connection_id, |
396 TransportChangeId next_server_change_id, | 396 TransportChangeId next_server_change_id, |
397 const mojo::Array<INode>& nodes) { | 397 mojo::Array<INodePtr> nodes) { |
398 connected_ = true; | 398 connected_ = true; |
399 connection_id_ = connection_id; | 399 connection_id_ = connection_id; |
400 next_server_change_id_ = next_server_change_id; | 400 next_server_change_id_ = next_server_change_id; |
401 | 401 |
402 ViewManagerPrivate private_manager(view_manager_); | 402 ViewManagerPrivate private_manager(view_manager_); |
403 std::vector<ViewTreeNode*> parents; | 403 std::vector<ViewTreeNode*> parents; |
404 ViewTreeNode* root = NULL; | 404 ViewTreeNode* root = NULL; |
405 ViewTreeNode* last_node = NULL; | 405 ViewTreeNode* last_node = NULL; |
406 for (size_t i = 0; i < nodes.size(); ++i) { | 406 for (size_t i = 0; i < nodes.size(); ++i) { |
407 if (last_node && nodes[i].parent_id() == last_node->id()) { | 407 if (last_node && nodes[i]->parent_id == last_node->id()) { |
408 parents.push_back(last_node); | 408 parents.push_back(last_node); |
409 } else if (!parents.empty()) { | 409 } else if (!parents.empty()) { |
410 while (parents.back()->id() != nodes[i].parent_id()) | 410 while (parents.back()->id() != nodes[i]->parent_id) |
411 parents.pop_back(); | 411 parents.pop_back(); |
412 } | 412 } |
413 ViewTreeNode* node = | 413 ViewTreeNode* node = |
414 AddNodeToViewManager(view_manager_, | 414 AddNodeToViewManager(view_manager_, |
415 !parents.empty() ? parents.back() : NULL, | 415 !parents.empty() ? parents.back() : NULL, |
416 nodes[i].node_id(), | 416 nodes[i]->node_id, |
417 nodes[i].view_id()); | 417 nodes[i]->view_id); |
418 if (!last_node) | 418 if (!last_node) |
419 root = node; | 419 root = node; |
420 last_node = node; | 420 last_node = node; |
421 } | 421 } |
422 private_manager.set_root(root); | 422 private_manager.set_root(root); |
423 if (init_loop_) | 423 if (init_loop_) |
424 init_loop_->Quit(); | 424 init_loop_->Quit(); |
425 | 425 |
426 Sync(); | 426 Sync(); |
427 } | 427 } |
428 | 428 |
429 void ViewManagerSynchronizer::OnServerChangeIdAdvanced( | 429 void ViewManagerSynchronizer::OnServerChangeIdAdvanced( |
430 uint32_t next_server_change_id) { | 430 uint32_t next_server_change_id) { |
431 next_server_change_id_ = next_server_change_id; | 431 next_server_change_id_ = next_server_change_id; |
432 } | 432 } |
433 | 433 |
434 void ViewManagerSynchronizer::OnNodeHierarchyChanged( | 434 void ViewManagerSynchronizer::OnNodeHierarchyChanged( |
435 uint32_t node_id, | 435 uint32_t node_id, |
436 uint32_t new_parent_id, | 436 uint32_t new_parent_id, |
437 uint32_t old_parent_id, | 437 uint32_t old_parent_id, |
438 TransportChangeId server_change_id, | 438 TransportChangeId server_change_id, |
439 const mojo::Array<INode>& nodes) { | 439 mojo::Array<INodePtr> nodes) { |
440 // TODO: deal with |nodes|. | 440 // TODO: deal with |nodes|. |
441 next_server_change_id_ = server_change_id + 1; | 441 next_server_change_id_ = server_change_id + 1; |
442 | 442 |
443 ViewTreeNode* new_parent = | 443 ViewTreeNode* new_parent = |
444 view_manager_->tree()->GetChildById(new_parent_id); | 444 view_manager_->tree()->GetChildById(new_parent_id); |
445 ViewTreeNode* old_parent = | 445 ViewTreeNode* old_parent = |
446 view_manager_->tree()->GetChildById(old_parent_id); | 446 view_manager_->tree()->GetChildById(old_parent_id); |
447 ViewTreeNode* node = NULL; | 447 ViewTreeNode* node = NULL; |
448 if (old_parent) { | 448 if (old_parent) { |
449 // Existing node, mapped in this connection's tree. | 449 // Existing node, mapped in this connection's tree. |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
517 } | 517 } |
518 | 518 |
519 void ViewManagerSynchronizer::RemoveFromPendingQueue( | 519 void ViewManagerSynchronizer::RemoveFromPendingQueue( |
520 ViewManagerTransaction* transaction) { | 520 ViewManagerTransaction* transaction) { |
521 DCHECK_EQ(transaction, pending_transactions_.front()); | 521 DCHECK_EQ(transaction, pending_transactions_.front()); |
522 pending_transactions_.erase(pending_transactions_.begin()); | 522 pending_transactions_.erase(pending_transactions_.begin()); |
523 } | 523 } |
524 | 524 |
525 } // namespace view_manager | 525 } // namespace view_manager |
526 } // namespace mojo | 526 } // namespace mojo |
OLD | NEW |