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

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

Issue 1675603002: [mojo-edk] Simplify multiprocess pipe bootstrap (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix some callers to work with sync APIs Created 4 years, 10 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/remote_message_pipe_bootstrap.h ('k') | mojo/shell/runner/child/runner_connection.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/edk/system/remote_message_pipe_bootstrap.cc
diff --git a/mojo/edk/system/remote_message_pipe_bootstrap.cc b/mojo/edk/system/remote_message_pipe_bootstrap.cc
index 671542f3595c72615a74b18919d0bcd9dbd181bc..234216633f2fc074d39e29681fd4dec44f592cc1 100644
--- a/mojo/edk/system/remote_message_pipe_bootstrap.cc
+++ b/mojo/edk/system/remote_message_pipe_bootstrap.cc
@@ -31,18 +31,17 @@ struct BootstrapData {
void RemoteMessagePipeBootstrap::Create(
NodeController* node_controller,
ScopedPlatformHandle platform_handle,
- const ports::PortRef& port,
- const base::Closure& callback) {
+ const ports::PortRef& port) {
if (node_controller->io_task_runner()->RunsTasksOnCurrentThread()) {
// Owns itself.
- new RemoteMessagePipeBootstrap(node_controller, std::move(platform_handle),
- port, callback);
+ new RemoteMessagePipeBootstrap(
+ node_controller, std::move(platform_handle), port);
} else {
node_controller->io_task_runner()->PostTask(
FROM_HERE,
base::Bind(&RemoteMessagePipeBootstrap::Create,
base::Unretained(node_controller),
- base::Passed(&platform_handle), port, callback));
+ base::Passed(&platform_handle), port));
}
}
@@ -56,11 +55,9 @@ RemoteMessagePipeBootstrap::~RemoteMessagePipeBootstrap() {
RemoteMessagePipeBootstrap::RemoteMessagePipeBootstrap(
NodeController* node_controller,
ScopedPlatformHandle platform_handle,
- const ports::PortRef& port,
- const base::Closure& callback)
+ const ports::PortRef& port)
: node_controller_(node_controller),
local_port_(port),
- callback_(callback),
io_task_runner_(base::ThreadTaskRunnerHandle::Get()),
channel_(Channel::Create(this, std::move(platform_handle),
io_task_runner_)) {
@@ -119,8 +116,14 @@ void RemoteMessagePipeBootstrap::OnChannelMessage(
}
peer_info_received_ = true;
- node_controller_->ConnectToRemotePort(
- local_port_, data->node_name, data->port_name, callback_);
+
+ // We need to choose one side to initiate the port merge. It doesn't matter
+ // who does it as long as they don't both try. Simple solution: pick the one
+ // with the "smaller" port name.
+ if (local_port_.name() < data->port_name) {
+ node_controller_->node()->MergePorts(local_port_, data->node_name,
+ data->port_name);
+ }
// Send another ping to the other end to trigger shutdown. This may race with
// the other end sending its own ping, but it doesn't matter. Whoever wins
« no previous file with comments | « mojo/edk/system/remote_message_pipe_bootstrap.h ('k') | mojo/shell/runner/child/runner_connection.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698