Chromium Code Reviews| 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_.find(NodeIdToTransportId(node->id())) != |
|
sky
2014/05/16 23:28:22
nit: use known_nodes_.count > 0 (it's shorter and
| |
| 125 ViewIdToTransportId(new_view->id()) : 0; | 125 known_nodes_.end()) { |
| 126 const TransportViewId old_view_id = old_view ? | 126 const TransportViewId new_view_id = new_view ? |
| 127 ViewIdToTransportId(old_view->id()) : 0; | 127 ViewIdToTransportId(new_view->id()) : 0; |
| 128 client()->OnNodeViewReplaced(NodeIdToTransportId(node->id()), | 128 const TransportViewId old_view_id = old_view ? |
| 129 new_view_id, old_view_id); | 129 ViewIdToTransportId(old_view->id()) : 0; |
| 130 client()->OnNodeViewReplaced(NodeIdToTransportId(node->id()), | |
| 131 new_view_id, old_view_id); | |
| 132 } | |
| 130 } | 133 } |
| 131 | 134 |
| 132 void ViewManagerConnection::ProcessNodeDeleted( | 135 void ViewManagerConnection::ProcessNodeDeleted( |
| 133 const NodeId& node, | 136 const NodeId& node, |
| 134 TransportChangeId server_change_id, | 137 TransportChangeId server_change_id, |
| 135 bool originated_change) { | 138 bool originated_change) { |
| 136 const bool in_known = known_nodes_.erase(NodeIdToTransportId(node)) > 0; | 139 const bool in_known = known_nodes_.erase(NodeIdToTransportId(node)) > 0; |
| 137 | 140 |
| 138 if (originated_change) | 141 if (originated_change) |
| 139 return; | 142 return; |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 257 void ViewManagerConnection::CreateNode( | 260 void ViewManagerConnection::CreateNode( |
| 258 TransportNodeId transport_node_id, | 261 TransportNodeId transport_node_id, |
| 259 const Callback<void(bool)>& callback) { | 262 const Callback<void(bool)>& callback) { |
| 260 const NodeId node_id(NodeIdFromTransportId(transport_node_id)); | 263 const NodeId node_id(NodeIdFromTransportId(transport_node_id)); |
| 261 if (node_id.connection_id != id_ || | 264 if (node_id.connection_id != id_ || |
| 262 node_map_.find(node_id.node_id) != node_map_.end()) { | 265 node_map_.find(node_id.node_id) != node_map_.end()) { |
| 263 callback.Run(false); | 266 callback.Run(false); |
| 264 return; | 267 return; |
| 265 } | 268 } |
| 266 node_map_[node_id.node_id] = new Node(this, node_id); | 269 node_map_[node_id.node_id] = new Node(this, node_id); |
| 270 known_nodes_.insert(transport_node_id); | |
| 267 callback.Run(true); | 271 callback.Run(true); |
| 268 } | 272 } |
| 269 | 273 |
| 270 void ViewManagerConnection::DeleteNode( | 274 void ViewManagerConnection::DeleteNode( |
| 271 TransportNodeId transport_node_id, | 275 TransportNodeId transport_node_id, |
| 272 const Callback<void(bool)>& callback) { | 276 const Callback<void(bool)>& callback) { |
| 273 AllocationScope allocation_scope; | 277 AllocationScope allocation_scope; |
| 274 const NodeId node_id(NodeIdFromTransportId(transport_node_id)); | 278 const NodeId node_id(NodeIdFromTransportId(transport_node_id)); |
| 275 ViewManagerConnection* connection = root_node_manager_->GetConnection( | 279 ViewManagerConnection* connection = root_node_manager_->GetConnection( |
| 276 node_id.connection_id); | 280 node_id.connection_id); |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 385 | 389 |
| 386 void ViewManagerConnection::OnNodeViewReplaced(const Node* node, | 390 void ViewManagerConnection::OnNodeViewReplaced(const Node* node, |
| 387 const View* new_view, | 391 const View* new_view, |
| 388 const View* old_view) { | 392 const View* old_view) { |
| 389 root_node_manager_->ProcessNodeViewReplaced(node, new_view, old_view); | 393 root_node_manager_->ProcessNodeViewReplaced(node, new_view, old_view); |
| 390 } | 394 } |
| 391 | 395 |
| 392 } // namespace service | 396 } // namespace service |
| 393 } // namespace view_manager | 397 } // namespace view_manager |
| 394 } // namespace mojo | 398 } // namespace mojo |
| OLD | NEW |