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/view_manager/view_manager_connection.h" | 5 #include "mojo/services/view_manager/view_manager_connection.h" |
6 | 6 |
7 #include "base/stl_util.h" | 7 #include "base/stl_util.h" |
8 #include "mojo/geometry/geometry_type_converters.h" | 8 #include "mojo/geometry/geometry_type_converters.h" |
9 #include "mojo/public/cpp/bindings/allocation_scope.h" | 9 #include "mojo/public/cpp/bindings/allocation_scope.h" |
10 #include "mojo/services/view_manager/node.h" | 10 #include "mojo/services/view_manager/node.h" |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 if (parent) | 64 if (parent) |
65 parent->Remove(node); | 65 parent->Remove(node); |
66 root_node_manager_->ProcessNodeDeleted(node_id); | 66 root_node_manager_->ProcessNodeDeleted(node_id); |
67 node_map_.erase(NodeIdToTransportId(node_id)); | 67 node_map_.erase(NodeIdToTransportId(node_id)); |
68 } | 68 } |
69 } | 69 } |
70 | 70 |
71 root_node_manager_->RemoveConnection(this); | 71 root_node_manager_->RemoveConnection(this); |
72 } | 72 } |
73 | 73 |
74 void ViewManagerConnection::OnConnectionEstablished() { | |
75 DCHECK_EQ(0, id_); // Should only get OnConnectionEstablished() once. | |
76 id_ = root_node_manager_->GetAndAdvanceNextConnectionId(); | |
77 root_node_manager_->AddConnection(this); | |
78 std::vector<const Node*> to_send; | |
79 GetUnknownNodesFrom(root_node_manager_->root(), &to_send); | |
80 AllocationScope allocation_scope; | |
81 client()->OnConnectionEstablished( | |
82 id_, | |
83 root_node_manager_->next_server_change_id(), | |
84 NodesToINodes(to_send)); | |
85 } | |
86 | |
87 const Node* ViewManagerConnection::GetNode(const NodeId& id) const { | 74 const Node* ViewManagerConnection::GetNode(const NodeId& id) const { |
88 if (id_ == id.connection_id) { | 75 if (id_ == id.connection_id) { |
89 NodeMap::const_iterator i = node_map_.find(id.node_id); | 76 NodeMap::const_iterator i = node_map_.find(id.node_id); |
90 return i == node_map_.end() ? NULL : i->second; | 77 return i == node_map_.end() ? NULL : i->second; |
91 } | 78 } |
92 return root_node_manager_->GetNode(id); | 79 return root_node_manager_->GetNode(id); |
93 } | 80 } |
94 | 81 |
95 const View* ViewManagerConnection::GetView(const ViewId& id) const { | 82 const View* ViewManagerConnection::GetView(const ViewId& id) const { |
96 if (id_ == id.connection_id) { | 83 if (id_ == id.connection_id) { |
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
417 } | 404 } |
418 roots_.swap(roots); | 405 roots_.swap(roots); |
419 | 406 |
420 // TODO(sky): remove |known_nodes_.clear()| temporary while this is done here | 407 // TODO(sky): remove |known_nodes_.clear()| temporary while this is done here |
421 // instead of at creation time. | 408 // instead of at creation time. |
422 known_nodes_.clear(); | 409 known_nodes_.clear(); |
423 std::vector<const Node*> to_send; | 410 std::vector<const Node*> to_send; |
424 for (NodeIdSet::const_iterator i = roots_.begin(); i != roots_.end(); ++i) | 411 for (NodeIdSet::const_iterator i = roots_.begin(); i != roots_.end(); ++i) |
425 GetUnknownNodesFrom(GetNode(NodeIdFromTransportId(*i)), &to_send); | 412 GetUnknownNodesFrom(GetNode(NodeIdFromTransportId(*i)), &to_send); |
426 AllocationScope allocation_scope; | 413 AllocationScope allocation_scope; |
427 client()->OnConnectionEstablished( | 414 client()->OnViewManagerConnectionEstablished( |
428 id_, | 415 id_, |
429 root_node_manager_->next_server_change_id(), | 416 root_node_manager_->next_server_change_id(), |
430 NodesToINodes(to_send)); | 417 NodesToINodes(to_send)); |
431 | 418 |
432 return true; | 419 return true; |
433 } | 420 } |
434 | 421 |
435 Array<INode> ViewManagerConnection::NodesToINodes( | 422 Array<INode> ViewManagerConnection::NodesToINodes( |
436 const std::vector<const Node*>& nodes) { | 423 const std::vector<const Node*>& nodes) { |
437 Array<INode>::Builder array_builder(nodes.size()); | 424 Array<INode>::Builder array_builder(nodes.size()); |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
631 const Node* old_parent) { | 618 const Node* old_parent) { |
632 root_node_manager_->ProcessNodeHierarchyChanged(node, new_parent, old_parent); | 619 root_node_manager_->ProcessNodeHierarchyChanged(node, new_parent, old_parent); |
633 } | 620 } |
634 | 621 |
635 void ViewManagerConnection::OnNodeViewReplaced(const Node* node, | 622 void ViewManagerConnection::OnNodeViewReplaced(const Node* node, |
636 const View* new_view, | 623 const View* new_view, |
637 const View* old_view) { | 624 const View* old_view) { |
638 root_node_manager_->ProcessNodeViewReplaced(node, new_view, old_view); | 625 root_node_manager_->ProcessNodeViewReplaced(node, new_view, old_view); |
639 } | 626 } |
640 | 627 |
| 628 void ViewManagerConnection::OnConnectionEstablished() { |
| 629 DCHECK_EQ(0, id_); // Should only get OnConnectionEstablished() once. |
| 630 id_ = root_node_manager_->GetAndAdvanceNextConnectionId(); |
| 631 root_node_manager_->AddConnection(this); |
| 632 std::vector<const Node*> to_send; |
| 633 GetUnknownNodesFrom(root_node_manager_->root(), &to_send); |
| 634 AllocationScope allocation_scope; |
| 635 client()->OnViewManagerConnectionEstablished( |
| 636 id_, |
| 637 root_node_manager_->next_server_change_id(), |
| 638 NodesToINodes(to_send)); |
| 639 } |
| 640 |
641 } // namespace service | 641 } // namespace service |
642 } // namespace view_manager | 642 } // namespace view_manager |
643 } // namespace mojo | 643 } // namespace mojo |
OLD | NEW |