OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/edk/system/node_controller.h" | 5 #include "mojo/edk/system/node_controller.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <limits> | 8 #include <limits> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 1251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1262 DLOG(ERROR) << "Received unexpected AcceptPeer message from " << from_node; | 1262 DLOG(ERROR) << "Received unexpected AcceptPeer message from " << from_node; |
1263 DropPeer(from_node, nullptr); | 1263 DropPeer(from_node, nullptr); |
1264 return; | 1264 return; |
1265 } | 1265 } |
1266 | 1266 |
1267 scoped_refptr<NodeChannel> channel = it->second.first; | 1267 scoped_refptr<NodeChannel> channel = it->second.first; |
1268 ports::PortRef local_port = it->second.second; | 1268 ports::PortRef local_port = it->second.second; |
1269 pending_peers_.erase(it); | 1269 pending_peers_.erase(it); |
1270 DCHECK(channel); | 1270 DCHECK(channel); |
1271 | 1271 |
1272 DVLOG(1) << "Node " << name_ << " accepted peer " << peer_name; | 1272 // If the peer connection is a self connection (which is used in tests), |
| 1273 // drop the channel to it and skip straight to merging the ports. |
| 1274 if (name_ != peer_name) { |
| 1275 DVLOG(1) << "Node " << name_ << " accepted peer " << peer_name; |
1273 | 1276 |
1274 AddPeer(peer_name, channel, false /* start_channel */); | 1277 AddPeer(peer_name, channel, false /* start_channel */); |
| 1278 } |
1275 | 1279 |
1276 // We need to choose one side to initiate the port merge. It doesn't matter | 1280 // We need to choose one side to initiate the port merge. It doesn't matter |
1277 // who does it as long as they don't both try. Simple solution: pick the one | 1281 // who does it as long as they don't both try. Simple solution: pick the one |
1278 // with the "smaller" port name. | 1282 // with the "smaller" port name. |
1279 if (local_port.name() < port_name) { | 1283 if (local_port.name() < port_name) { |
1280 node()->MergePorts(local_port, peer_name, port_name); | 1284 node()->MergePorts(local_port, peer_name, port_name); |
1281 } | 1285 } |
1282 } | 1286 } |
1283 | 1287 |
1284 void NodeController::OnChannelError(const ports::NodeName& from_node, | 1288 void NodeController::OnChannelError(const ports::NodeName& from_node, |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1349 shutdown_callback_flag_.Set(false); | 1353 shutdown_callback_flag_.Set(false); |
1350 } | 1354 } |
1351 | 1355 |
1352 DCHECK(!callback.is_null()); | 1356 DCHECK(!callback.is_null()); |
1353 | 1357 |
1354 callback.Run(); | 1358 callback.Run(); |
1355 } | 1359 } |
1356 | 1360 |
1357 } // namespace edk | 1361 } // namespace edk |
1358 } // namespace mojo | 1362 } // namespace mojo |
OLD | NEW |