Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1626)

Unified Diff: mojo/edk/system/node_controller.cc

Issue 2738853002: Connections now take a ConnectionParams instead of a pipe handle. (Closed)
Patch Set: Fix Win release build. Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « mojo/edk/system/node_controller.h ('k') | mojo/edk/test/multiprocess_test_helper.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..7bdb571c88c7a2c5857a3a9ae494c85366fe65d7 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,
+ ConnectionParams connection_params,
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_params), 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(ConnectionParams connection_params) {
#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_params.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_params = ConnectionParams(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_params)));
}
-void NodeController::ConnectToPeer(ScopedPlatformHandle handle,
+void NodeController::ConnectToPeer(ConnectionParams connection_params,
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_params),
+ 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,
+ ConnectionParams connection_params,
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_params.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, ConnectionParams(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_params), 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) {
+ ConnectionParams connection_params) {
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_params), 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(ConnectionParams connection_params,
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_params), 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());
+ ConnectionParams connection_params(broker_channel.PassServerHandle());
+ scoped_refptr<NodeChannel> client =
+ NodeChannel::Create(this, std::move(connection_params), io_task_runner_,
+ ProcessErrorCallback());
#if defined(OS_WIN)
// The broker must have a working handle to the client process in order to
@@ -1072,8 +1072,9 @@ void NodeController::OnAcceptBrokerClient(const ports::NodeName& from_node,
broker = parent;
} else {
DCHECK(broker_channel.is_valid());
- broker = NodeChannel::Create(this, std::move(broker_channel),
- io_task_runner_, ProcessErrorCallback());
+ broker =
+ NodeChannel::Create(this, ConnectionParams(std::move(broker_channel)),
+ io_task_runner_, ProcessErrorCallback());
AddPeer(broker_name, broker, true /* start_channel */);
}
@@ -1201,8 +1202,8 @@ void NodeController::OnIntroduce(const ports::NodeName& from_node,
}
scoped_refptr<NodeChannel> channel =
- NodeChannel::Create(this, std::move(channel_handle), io_task_runner_,
- ProcessErrorCallback());
+ NodeChannel::Create(this, ConnectionParams(std::move(channel_handle)),
+ io_task_runner_, ProcessErrorCallback());
DVLOG(1) << "Adding new peer " << name << " via parent introduction.";
AddPeer(name, channel, true /* start_channel */);
« no previous file with comments | « mojo/edk/system/node_controller.h ('k') | mojo/edk/test/multiprocess_test_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698