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/public/cpp/bindings/allocation_scope.h" | 8 #include "mojo/public/cpp/bindings/allocation_scope.h" |
9 #include "mojo/services/view_manager/node.h" | 9 #include "mojo/services/view_manager/node.h" |
10 #include "mojo/services/view_manager/root_node_manager.h" | 10 #include "mojo/services/view_manager/root_node_manager.h" |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 Array<INode>::From(to_send)); | 114 Array<INode>::From(to_send)); |
115 } | 115 } |
116 | 116 |
117 void ViewManagerConnection::ProcessNodeViewReplaced( | 117 void ViewManagerConnection::ProcessNodeViewReplaced( |
118 const Node* node, | 118 const Node* node, |
119 const View* new_view, | 119 const View* new_view, |
120 const View* old_view, | 120 const View* old_view, |
121 bool originated_change) { | 121 bool originated_change) { |
122 if (originated_change) | 122 if (originated_change) |
123 return; | 123 return; |
124 const TransportViewId new_view_id = new_view ? | 124 if (known_nodes_.count(NodeIdToTransportId(node->id())) > 0) { |
125 ViewIdToTransportId(new_view->id()) : 0; | 125 const TransportViewId new_view_id = new_view ? |
126 const TransportViewId old_view_id = old_view ? | 126 ViewIdToTransportId(new_view->id()) : 0; |
127 ViewIdToTransportId(old_view->id()) : 0; | 127 const TransportViewId old_view_id = old_view ? |
128 client()->OnNodeViewReplaced(NodeIdToTransportId(node->id()), | 128 ViewIdToTransportId(old_view->id()) : 0; |
129 new_view_id, old_view_id); | 129 client()->OnNodeViewReplaced(NodeIdToTransportId(node->id()), |
| 130 new_view_id, old_view_id); |
| 131 } |
130 } | 132 } |
131 | 133 |
132 void ViewManagerConnection::ProcessNodeDeleted( | 134 void ViewManagerConnection::ProcessNodeDeleted( |
133 const NodeId& node, | 135 const NodeId& node, |
134 TransportChangeId server_change_id, | 136 TransportChangeId server_change_id, |
135 bool originated_change) { | 137 bool originated_change) { |
136 const bool in_known = known_nodes_.erase(NodeIdToTransportId(node)) > 0; | 138 const bool in_known = known_nodes_.erase(NodeIdToTransportId(node)) > 0; |
137 | 139 |
138 if (originated_change) | 140 if (originated_change) |
139 return; | 141 return; |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
257 void ViewManagerConnection::CreateNode( | 259 void ViewManagerConnection::CreateNode( |
258 TransportNodeId transport_node_id, | 260 TransportNodeId transport_node_id, |
259 const Callback<void(bool)>& callback) { | 261 const Callback<void(bool)>& callback) { |
260 const NodeId node_id(NodeIdFromTransportId(transport_node_id)); | 262 const NodeId node_id(NodeIdFromTransportId(transport_node_id)); |
261 if (node_id.connection_id != id_ || | 263 if (node_id.connection_id != id_ || |
262 node_map_.find(node_id.node_id) != node_map_.end()) { | 264 node_map_.find(node_id.node_id) != node_map_.end()) { |
263 callback.Run(false); | 265 callback.Run(false); |
264 return; | 266 return; |
265 } | 267 } |
266 node_map_[node_id.node_id] = new Node(this, node_id); | 268 node_map_[node_id.node_id] = new Node(this, node_id); |
| 269 known_nodes_.insert(transport_node_id); |
267 callback.Run(true); | 270 callback.Run(true); |
268 } | 271 } |
269 | 272 |
270 void ViewManagerConnection::DeleteNode( | 273 void ViewManagerConnection::DeleteNode( |
271 TransportNodeId transport_node_id, | 274 TransportNodeId transport_node_id, |
272 const Callback<void(bool)>& callback) { | 275 const Callback<void(bool)>& callback) { |
273 AllocationScope allocation_scope; | 276 AllocationScope allocation_scope; |
274 const NodeId node_id(NodeIdFromTransportId(transport_node_id)); | 277 const NodeId node_id(NodeIdFromTransportId(transport_node_id)); |
275 ViewManagerConnection* connection = root_node_manager_->GetConnection( | 278 ViewManagerConnection* connection = root_node_manager_->GetConnection( |
276 node_id.connection_id); | 279 node_id.connection_id); |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
385 | 388 |
386 void ViewManagerConnection::OnNodeViewReplaced(const Node* node, | 389 void ViewManagerConnection::OnNodeViewReplaced(const Node* node, |
387 const View* new_view, | 390 const View* new_view, |
388 const View* old_view) { | 391 const View* old_view) { |
389 root_node_manager_->ProcessNodeViewReplaced(node, new_view, old_view); | 392 root_node_manager_->ProcessNodeViewReplaced(node, new_view, old_view); |
390 } | 393 } |
391 | 394 |
392 } // namespace service | 395 } // namespace service |
393 } // namespace view_manager | 396 } // namespace view_manager |
394 } // namespace mojo | 397 } // namespace mojo |
OLD | NEW |