| Index: mojo/edk/system/node_controller.cc
|
| diff --git a/mojo/edk/system/node_controller.cc b/mojo/edk/system/node_controller.cc
|
| index 0d16c5eacd93f97796f2fca2f52242144fcc3340..f19b21351481164d93af8b3b457c53411d4928e0 100644
|
| --- a/mojo/edk/system/node_controller.cc
|
| +++ b/mojo/edk/system/node_controller.cc
|
| @@ -165,7 +165,7 @@ void NodeController::SetIOTaskRunner(
|
|
|
| void NodeController::ConnectToChild(
|
| base::ProcessHandle process_handle,
|
| - ScopedPlatformHandle platform_handle,
|
| + ConnectionParam connection_param,
|
| const std::string& child_token,
|
| const ProcessErrorCallback& process_error_callback) {
|
| // Generate the temporary remote node name here so that it can be associated
|
| @@ -196,13 +196,10 @@ void NodeController::ConnectToChild(
|
| #endif
|
|
|
| io_task_runner_->PostTask(
|
| - FROM_HERE,
|
| - base::Bind(&NodeController::ConnectToChildOnIOThread,
|
| - base::Unretained(this),
|
| - process_handle,
|
| - base::Passed(&platform_handle),
|
| - node_name,
|
| - process_error_callback));
|
| + FROM_HERE, base::Bind(&NodeController::ConnectToChildOnIOThread,
|
| + base::Unretained(this), process_handle,
|
| + base::Passed(&connection_param), node_name,
|
| + process_error_callback));
|
| }
|
|
|
| void NodeController::CloseChildPorts(const std::string& child_token) {
|
| @@ -235,13 +232,13 @@ void NodeController::ClosePeerConnection(const std::string& peer_token) {
|
| base::Unretained(this), peer_token));
|
| }
|
|
|
| -void NodeController::ConnectToParent(ScopedPlatformHandle platform_handle) {
|
| +void NodeController::ConnectToParent(ConnectionParam connection_param) {
|
| #if !defined(OS_MACOSX) && !defined(OS_NACL_SFI)
|
| // Use the bootstrap channel for the broker and receive the node's channel
|
| // synchronously as the first message from the broker.
|
| base::ElapsedTimer timer;
|
| - broker_.reset(new Broker(std::move(platform_handle)));
|
| - platform_handle = broker_->GetParentPlatformHandle();
|
| + broker_.reset(new Broker(connection_param.TakeChannelHandle()));
|
| + ScopedPlatformHandle platform_handle = broker_->GetParentPlatformHandle();
|
| UMA_HISTOGRAM_TIMES("Mojo.System.GetParentPlatformHandleSyncTime",
|
| timer.Elapsed());
|
|
|
| @@ -253,24 +250,25 @@ void NodeController::ConnectToParent(ScopedPlatformHandle platform_handle) {
|
| CancelPendingPortMerges();
|
| return;
|
| }
|
| + connection_param = ConnectionParam(std::move(platform_handle));
|
| #endif
|
|
|
| io_task_runner_->PostTask(
|
| FROM_HERE,
|
| base::Bind(&NodeController::ConnectToParentOnIOThread,
|
| - base::Unretained(this),
|
| - base::Passed(&platform_handle)));
|
| + base::Unretained(this), base::Passed(&connection_param)));
|
| }
|
|
|
| -void NodeController::ConnectToPeer(ScopedPlatformHandle handle,
|
| +void NodeController::ConnectToPeer(ConnectionParam connection_param,
|
| const ports::PortRef& port,
|
| const std::string& peer_token) {
|
| ports::NodeName node_name;
|
| GenerateRandomName(&node_name);
|
| io_task_runner_->PostTask(
|
| - FROM_HERE, base::Bind(&NodeController::ConnectToPeerOnIOThread,
|
| - base::Unretained(this), base::Passed(&handle),
|
| - node_name, port, peer_token));
|
| + FROM_HERE,
|
| + base::Bind(&NodeController::ConnectToPeerOnIOThread,
|
| + base::Unretained(this), base::Passed(&connection_param),
|
| + node_name, port, peer_token));
|
| }
|
|
|
| void NodeController::SetPortObserver(const ports::PortRef& port,
|
| @@ -394,7 +392,7 @@ void NodeController::NotifyBadMessageFrom(const ports::NodeName& source_node,
|
|
|
| void NodeController::ConnectToChildOnIOThread(
|
| base::ProcessHandle process_handle,
|
| - ScopedPlatformHandle platform_handle,
|
| + ConnectionParam connection_param,
|
| ports::NodeName token,
|
| const ProcessErrorCallback& process_error_callback) {
|
| DCHECK(io_task_runner_->RunsTasksOnCurrentThread());
|
| @@ -404,7 +402,7 @@ void NodeController::ConnectToChildOnIOThread(
|
| ScopedPlatformHandle server_handle = node_channel.PassServerHandle();
|
| // BrokerHost owns itself.
|
| BrokerHost* broker_host =
|
| - new BrokerHost(process_handle, std::move(platform_handle));
|
| + new BrokerHost(process_handle, connection_param.TakeChannelHandle());
|
| bool channel_ok = broker_host->SendChannel(node_channel.PassClientHandle());
|
|
|
| #if defined(OS_WIN)
|
| @@ -419,12 +417,13 @@ void NodeController::ConnectToChildOnIOThread(
|
| CHECK(channel_ok);
|
| #endif // defined(OS_WIN)
|
|
|
| - scoped_refptr<NodeChannel> channel = NodeChannel::Create(
|
| - this, std::move(server_handle), io_task_runner_, process_error_callback);
|
| + scoped_refptr<NodeChannel> channel =
|
| + NodeChannel::Create(this, ConnectionParam(std::move(server_handle)),
|
| + io_task_runner_, process_error_callback);
|
|
|
| #else // !defined(OS_MACOSX) && !defined(OS_NACL)
|
| scoped_refptr<NodeChannel> channel =
|
| - NodeChannel::Create(this, std::move(platform_handle), io_task_runner_,
|
| + NodeChannel::Create(this, std::move(connection_param), io_task_runner_,
|
| process_error_callback);
|
| #endif // !defined(OS_MACOSX) && !defined(OS_NACL)
|
|
|
| @@ -444,7 +443,7 @@ void NodeController::ConnectToChildOnIOThread(
|
| }
|
|
|
| void NodeController::ConnectToParentOnIOThread(
|
| - ScopedPlatformHandle platform_handle) {
|
| + ConnectionParam connection_param) {
|
| DCHECK(io_task_runner_->RunsTasksOnCurrentThread());
|
|
|
| {
|
| @@ -455,7 +454,7 @@ void NodeController::ConnectToParentOnIOThread(
|
| // into our |peers_| map. That will happen as soon as we receive an
|
| // AcceptChild message from them.
|
| bootstrap_parent_channel_ =
|
| - NodeChannel::Create(this, std::move(platform_handle), io_task_runner_,
|
| + NodeChannel::Create(this, std::move(connection_param), io_task_runner_,
|
| ProcessErrorCallback());
|
| // Prevent the parent pipe handle from being closed on shutdown. Pipe
|
| // closure is used by the parent to detect the child process has exited.
|
| @@ -467,14 +466,14 @@ void NodeController::ConnectToParentOnIOThread(
|
| bootstrap_parent_channel_->Start();
|
| }
|
|
|
| -void NodeController::ConnectToPeerOnIOThread(ScopedPlatformHandle handle,
|
| +void NodeController::ConnectToPeerOnIOThread(ConnectionParam connection_param,
|
| ports::NodeName token,
|
| ports::PortRef port,
|
| const std::string& peer_token) {
|
| DCHECK(io_task_runner_->RunsTasksOnCurrentThread());
|
|
|
| - scoped_refptr<NodeChannel> channel =
|
| - NodeChannel::Create(this, std::move(handle), io_task_runner_, {});
|
| + scoped_refptr<NodeChannel> channel = NodeChannel::Create(
|
| + this, std::move(connection_param), io_task_runner_, {});
|
| peer_connections_.insert(
|
| {token, PeerConnection{channel, port, peer_token}});
|
| peers_by_token_.insert({peer_token, token});
|
| @@ -994,9 +993,10 @@ void NodeController::OnAddBrokerClient(const ports::NodeName& from_node,
|
| }
|
|
|
| PlatformChannelPair broker_channel;
|
| - scoped_refptr<NodeChannel> client = NodeChannel::Create(
|
| - this, broker_channel.PassServerHandle(), io_task_runner_,
|
| - ProcessErrorCallback());
|
| + ConnectionParam connection_param(broker_channel.PassServerHandle());
|
| + scoped_refptr<NodeChannel> client =
|
| + NodeChannel::Create(this, std::move(connection_param), io_task_runner_,
|
| + ProcessErrorCallback());
|
|
|
| #if defined(OS_WIN)
|
| // The broker must have a working handle to the client process in order to
|
| @@ -1072,7 +1072,8 @@ void NodeController::OnAcceptBrokerClient(const ports::NodeName& from_node,
|
| broker = parent;
|
| } else {
|
| DCHECK(broker_channel.is_valid());
|
| - broker = NodeChannel::Create(this, std::move(broker_channel),
|
| + ConnectionParam connection_param(std::move(broker_channel));
|
| + broker = NodeChannel::Create(this, std::move(connection_param),
|
| io_task_runner_, ProcessErrorCallback());
|
| AddPeer(broker_name, broker, true /* start_channel */);
|
| }
|
| @@ -1200,8 +1201,9 @@ void NodeController::OnIntroduce(const ports::NodeName& from_node,
|
| return;
|
| }
|
|
|
| + ConnectionParam connection_param(std::move(channel_handle));
|
| scoped_refptr<NodeChannel> channel =
|
| - NodeChannel::Create(this, std::move(channel_handle), io_task_runner_,
|
| + NodeChannel::Create(this, std::move(connection_param), io_task_runner_,
|
| ProcessErrorCallback());
|
|
|
| DVLOG(1) << "Adding new peer " << name << " via parent introduction.";
|
|
|