Commit 2e459d99 authored by Wez's avatar Wez Committed by Commit Bot

[Fuchsia] Remove Mojo NamedPlatformChannel under Fuchsia.

We have neither a use for, nor an implementation of, named platform
channels under Fuchsia, so remove the APIs and NamedPlatformChannel
handle type entirely under that platform.

Bug: 754038
Change-Id: I85319f7b2df2e897e1fd34046911a2a11d5f4a20
Reviewed-on: https://chromium-review.googlesource.com/c/1288900Reviewed-by: default avatarAlex Moshchuk <alexmos@chromium.org>
Reviewed-by: default avatarKen Rockot <rockot@google.com>
Commit-Queue: Wez <wez@chromium.org>
Cr-Commit-Position: refs/heads/master@{#602392}
parent be9cde47
...@@ -88,9 +88,13 @@ void ChildProcessLauncherHelper::StartLaunchOnClientThread() { ...@@ -88,9 +88,13 @@ void ChildProcessLauncherHelper::StartLaunchOnClientThread() {
BeforeLaunchOnClientThread(); BeforeLaunchOnClientThread();
#if defined(OS_FUCHSIA)
mojo_channel_.emplace();
#else // !defined(OS_FUCHSIA)
mojo_named_channel_ = CreateNamedPlatformChannelOnClientThread(); mojo_named_channel_ = CreateNamedPlatformChannelOnClientThread();
if (!mojo_named_channel_) if (!mojo_named_channel_)
mojo_channel_.emplace(); mojo_channel_.emplace();
#endif // !defined(OS_FUCHSIA)
GetProcessLauncherTaskRunner()->PostTask( GetProcessLauncherTaskRunner()->PostTask(
FROM_HERE, FROM_HERE,
...@@ -138,17 +142,21 @@ void ChildProcessLauncherHelper::PostLaunchOnLauncherThread( ...@@ -138,17 +142,21 @@ void ChildProcessLauncherHelper::PostLaunchOnLauncherThread(
// we go out of scope regardless of the outcome below. // we go out of scope regardless of the outcome below.
mojo::OutgoingInvitation invitation = std::move(mojo_invitation_); mojo::OutgoingInvitation invitation = std::move(mojo_invitation_);
if (process.process.IsValid()) { if (process.process.IsValid()) {
#if !defined(OS_FUCHSIA)
if (mojo_named_channel_) {
DCHECK(!mojo_channel_);
mojo::OutgoingInvitation::Send(
std::move(invitation), process.process.Handle(),
mojo_named_channel_->TakeServerEndpoint(), process_error_callback_);
} else
#endif
// Set up Mojo IPC to the new process. // Set up Mojo IPC to the new process.
if (mojo_channel_) { {
DCHECK(mojo_channel_);
DCHECK(mojo_channel_->local_endpoint().is_valid()); DCHECK(mojo_channel_->local_endpoint().is_valid());
mojo::OutgoingInvitation::Send( mojo::OutgoingInvitation::Send(
std::move(invitation), process.process.Handle(), std::move(invitation), process.process.Handle(),
mojo_channel_->TakeLocalEndpoint(), process_error_callback_); mojo_channel_->TakeLocalEndpoint(), process_error_callback_);
} else {
DCHECK(mojo_named_channel_);
mojo::OutgoingInvitation::Send(
std::move(invitation), process.process.Handle(),
mojo_named_channel_->TakeServerEndpoint(), process_error_callback_);
} }
} }
......
...@@ -15,12 +15,15 @@ ...@@ -15,12 +15,15 @@
#include "build/build_config.h" #include "build/build_config.h"
#include "content/public/browser/browser_thread.h" #include "content/public/browser/browser_thread.h"
#include "content/public/common/result_codes.h" #include "content/public/common/result_codes.h"
#include "mojo/public/cpp/platform/named_platform_channel.h"
#include "mojo/public/cpp/platform/platform_channel.h" #include "mojo/public/cpp/platform/platform_channel.h"
#include "mojo/public/cpp/system/invitation.h" #include "mojo/public/cpp/system/invitation.h"
#include "services/catalog/public/cpp/manifest_parsing_util.h" #include "services/catalog/public/cpp/manifest_parsing_util.h"
#include "services/service_manager/zygote/common/zygote_buildflags.h" #include "services/service_manager/zygote/common/zygote_buildflags.h"
#if !defined(OS_FUCHSIA)
#include "mojo/public/cpp/platform/named_platform_channel.h"
#endif
#if defined(OS_ANDROID) #if defined(OS_ANDROID)
#include "base/android/scoped_java_ref.h" #include "base/android/scoped_java_ref.h"
#endif #endif
...@@ -106,11 +109,13 @@ class ChildProcessLauncherHelper : ...@@ -106,11 +109,13 @@ class ChildProcessLauncherHelper :
// Platform specific. // Platform specific.
void BeforeLaunchOnClientThread(); void BeforeLaunchOnClientThread();
#if !defined(OS_FUCHSIA)
// Called to give implementors a chance at creating a server pipe. Platform- // Called to give implementors a chance at creating a server pipe. Platform-
// specific. Returns |base::nullopt| if the helper should initialize // specific. Returns |base::nullopt| if the helper should initialize
// a regular PlatformChannel for communication instead. // a regular PlatformChannel for communication instead.
base::Optional<mojo::NamedPlatformChannel> base::Optional<mojo::NamedPlatformChannel>
CreateNamedPlatformChannelOnClientThread(); CreateNamedPlatformChannelOnClientThread();
#endif
// Returns the list of files that should be mapped in the child process. // Returns the list of files that should be mapped in the child process.
// Platform specific. // Platform specific.
...@@ -221,10 +226,12 @@ class ChildProcessLauncherHelper : ...@@ -221,10 +226,12 @@ class ChildProcessLauncherHelper :
// |CreateNamedPlatformChannelOnClientThread()|. // |CreateNamedPlatformChannelOnClientThread()|.
base::Optional<mojo::PlatformChannel> mojo_channel_; base::Optional<mojo::PlatformChannel> mojo_channel_;
#if !defined(OS_FUCHSIA)
// May be used in exclusion to the above if the platform helper implementation // May be used in exclusion to the above if the platform helper implementation
// returns a valid server endpoint from // returns a valid server endpoint from
// |CreateNamedPlatformChannelOnClientThread()|. // |CreateNamedPlatformChannelOnClientThread()|.
base::Optional<mojo::NamedPlatformChannel> mojo_named_channel_; base::Optional<mojo::NamedPlatformChannel> mojo_named_channel_;
#endif
bool terminate_on_shutdown_; bool terminate_on_shutdown_;
mojo::OutgoingInvitation mojo_invitation_; mojo::OutgoingInvitation mojo_invitation_;
......
...@@ -58,12 +58,6 @@ void ChildProcessLauncherHelper::BeforeLaunchOnClientThread() { ...@@ -58,12 +58,6 @@ void ChildProcessLauncherHelper::BeforeLaunchOnClientThread() {
sandbox_policy_.Initialize(delegate_->GetSandboxType()); sandbox_policy_.Initialize(delegate_->GetSandboxType());
} }
base::Optional<mojo::NamedPlatformChannel>
ChildProcessLauncherHelper::CreateNamedPlatformChannelOnClientThread() {
DCHECK_CURRENTLY_ON(client_thread_id_);
return base::nullopt;
}
std::unique_ptr<FileMappedForLaunch> std::unique_ptr<FileMappedForLaunch>
ChildProcessLauncherHelper::GetFilesToMap() { ChildProcessLauncherHelper::GetFilesToMap() {
DCHECK(CurrentlyOnProcessLauncherTaskRunner()); DCHECK(CurrentlyOnProcessLauncherTaskRunner());
......
...@@ -299,8 +299,10 @@ base::Process InvitationTest::LaunchChildTestClient( ...@@ -299,8 +299,10 @@ base::Process InvitationTest::LaunchChildTestClient(
launch_options.start_hidden = true; launch_options.start_hidden = true;
#endif #endif
base::Optional<PlatformChannel> channel; #if !defined(OS_FUCHSIA)
base::Optional<NamedPlatformChannel> named_channel; base::Optional<NamedPlatformChannel> named_channel;
#endif
base::Optional<PlatformChannel> channel;
PlatformHandle local_endpoint_handle; PlatformHandle local_endpoint_handle;
if (transport_type == TransportType::kChannel) { if (transport_type == TransportType::kChannel) {
channel.emplace(); channel.emplace();
...@@ -308,9 +310,7 @@ base::Process InvitationTest::LaunchChildTestClient( ...@@ -308,9 +310,7 @@ base::Process InvitationTest::LaunchChildTestClient(
&command_line); &command_line);
local_endpoint_handle = channel->TakeLocalEndpoint().TakePlatformHandle(); local_endpoint_handle = channel->TakeLocalEndpoint().TakePlatformHandle();
} else { } else {
#if defined(OS_FUCHSIA) #if !defined(OS_FUCHSIA)
NOTREACHED() << "Named pipe support does not exist for Mojo on Fuchsia.";
#else
NamedPlatformChannel::Options named_channel_options; NamedPlatformChannel::Options named_channel_options;
#if !defined(OS_WIN) #if !defined(OS_WIN)
CHECK(base::PathService::Get(base::DIR_TEMP, CHECK(base::PathService::Get(base::DIR_TEMP,
...@@ -320,7 +320,9 @@ base::Process InvitationTest::LaunchChildTestClient( ...@@ -320,7 +320,9 @@ base::Process InvitationTest::LaunchChildTestClient(
named_channel->PassServerNameOnCommandLine(&command_line); named_channel->PassServerNameOnCommandLine(&command_line);
local_endpoint_handle = local_endpoint_handle =
named_channel->TakeServerEndpoint().TakePlatformHandle(); named_channel->TakeServerEndpoint().TakePlatformHandle();
#endif #else // !defined(OS_FUCHSIA)
NOTREACHED() << "Named pipe support does not exist for Mojo on Fuchsia.";
#endif // !defined(OS_FUCHSIA)
} }
base::Process child_process = base::SpawnMultiProcessTestChild( base::Process child_process = base::SpawnMultiProcessTestChild(
...@@ -395,8 +397,10 @@ class TestClientBase : public InvitationTest { ...@@ -395,8 +397,10 @@ class TestClientBase : public InvitationTest {
static MojoHandle AcceptInvitation(MojoAcceptInvitationFlags flags, static MojoHandle AcceptInvitation(MojoAcceptInvitationFlags flags,
base::StringPiece switch_name = {}) { base::StringPiece switch_name = {}) {
const auto& command_line = *base::CommandLine::ForCurrentProcess(); const auto& command_line = *base::CommandLine::ForCurrentProcess();
PlatformChannelEndpoint channel_endpoint = PlatformChannelEndpoint channel_endpoint;
NamedPlatformChannel::ConnectToServer(command_line); #if !defined(OS_FUCHSIA)
channel_endpoint = NamedPlatformChannel::ConnectToServer(command_line);
#endif
if (!channel_endpoint.is_valid()) { if (!channel_endpoint.is_valid()) {
if (switch_name.empty()) { if (switch_name.empty()) {
channel_endpoint = channel_endpoint =
......
...@@ -26,7 +26,6 @@ ...@@ -26,7 +26,6 @@
#include "base/task_runner.h" #include "base/task_runner.h"
#include "base/threading/thread_task_runner_handle.h" #include "base/threading/thread_task_runner_handle.h"
#include "build/build_config.h" #include "build/build_config.h"
#include "mojo/public/cpp/platform/named_platform_channel.h"
#include "mojo/public/cpp/platform/platform_channel.h" #include "mojo/public/cpp/platform/platform_channel.h"
#include "mojo/public/cpp/platform/platform_channel_endpoint.h" #include "mojo/public/cpp/platform/platform_channel_endpoint.h"
#include "mojo/public/cpp/platform/platform_channel_server_endpoint.h" #include "mojo/public/cpp/platform/platform_channel_server_endpoint.h"
...@@ -39,15 +38,20 @@ ...@@ -39,15 +38,20 @@
#include "base/mac/mach_port_broker.h" #include "base/mac/mach_port_broker.h"
#endif #endif
#if !defined(OS_FUCHSIA)
#include "mojo/public/cpp/platform/named_platform_channel.h"
#endif
namespace mojo { namespace mojo {
namespace core { namespace core {
namespace test { namespace test {
namespace { namespace {
#if !defined(OS_FUCHSIA)
const char kNamedPipeName[] = "named-pipe-name"; const char kNamedPipeName[] = "named-pipe-name";
#endif
const char kRunAsBrokerClient[] = "run-as-broker-client"; const char kRunAsBrokerClient[] = "run-as-broker-client";
const char kTestChildMessagePipeName[] = "test_pipe"; const char kTestChildMessagePipeName[] = "test_pipe";
// For use (and only valid) in a test child process: // For use (and only valid) in a test child process:
...@@ -106,8 +110,10 @@ ScopedMessagePipeHandle MultiprocessTestHelper::StartChildWithExtraSwitch( ...@@ -106,8 +110,10 @@ ScopedMessagePipeHandle MultiprocessTestHelper::StartChildWithExtraSwitch(
command_line.AppendSwitchNative(entry.first, entry.second); command_line.AppendSwitchNative(entry.first, entry.second);
} }
mojo::PlatformChannel channel; #if !defined(OS_FUCHSIA)
mojo::NamedPlatformChannel::ServerName server_name; NamedPlatformChannel::ServerName server_name;
#endif
PlatformChannel channel;
base::LaunchOptions options; base::LaunchOptions options;
switch (launch_type) { switch (launch_type) {
case LaunchType::CHILD: case LaunchType::CHILD:
...@@ -205,14 +211,14 @@ ScopedMessagePipeHandle MultiprocessTestHelper::StartChildWithExtraSwitch( ...@@ -205,14 +211,14 @@ ScopedMessagePipeHandle MultiprocessTestHelper::StartChildWithExtraSwitch(
DCHECK(local_channel_endpoint.is_valid()); DCHECK(local_channel_endpoint.is_valid());
OutgoingInvitation::Send(std::move(child_invitation), test_child_.Handle(), OutgoingInvitation::Send(std::move(child_invitation), test_child_.Handle(),
std::move(local_channel_endpoint), std::move(local_channel_endpoint),
mojo::ProcessErrorCallback()); ProcessErrorCallback());
} }
#if !defined(OS_FUCHSIA) #if !defined(OS_FUCHSIA)
else if (launch_type == LaunchType::NAMED_CHILD) { else if (launch_type == LaunchType::NAMED_CHILD) {
DCHECK(server_endpoint.is_valid()); DCHECK(server_endpoint.is_valid());
OutgoingInvitation::Send(std::move(child_invitation), test_child_.Handle(), OutgoingInvitation::Send(std::move(child_invitation), test_child_.Handle(),
std::move(server_endpoint), std::move(server_endpoint),
mojo::ProcessErrorCallback()); ProcessErrorCallback());
} }
#endif // !defined(OS_FUCHSIA) #endif // !defined(OS_FUCHSIA)
...@@ -239,31 +245,33 @@ void MultiprocessTestHelper::ChildSetup() { ...@@ -239,31 +245,33 @@ void MultiprocessTestHelper::ChildSetup() {
CHECK(base::CommandLine::InitializedForCurrentProcess()); CHECK(base::CommandLine::InitializedForCurrentProcess());
auto& command_line = *base::CommandLine::ForCurrentProcess(); auto& command_line = *base::CommandLine::ForCurrentProcess();
NamedPlatformChannel::ServerName named_pipe(
command_line.GetSwitchValueNative(kNamedPipeName)); bool run_as_broker_client = command_line.HasSwitch(kRunAsBrokerClient);
if (command_line.HasSwitch(kRunAsBrokerClient)) {
mojo::IncomingInvitation invitation;
#if defined(OS_MACOSX) && !defined(OS_IOS) #if defined(OS_MACOSX) && !defined(OS_IOS)
if (run_as_broker_client)
CHECK(base::MachPortBroker::ChildSendTaskPortToParent("mojo_test")); CHECK(base::MachPortBroker::ChildSendTaskPortToParent("mojo_test"));
#endif #endif
if (!named_pipe.empty()) {
invitation = mojo::IncomingInvitation::Accept( PlatformChannelEndpoint endpoint;
mojo::NamedPlatformChannel::ConnectToServer(named_pipe)); #if !defined(OS_FUCHSIA)
} else { NamedPlatformChannel::ServerName named_pipe(
auto endpoint = command_line.GetSwitchValueNative(kNamedPipeName));
mojo::PlatformChannel::RecoverPassedEndpointFromCommandLine( if (!named_pipe.empty()) {
command_line); endpoint = NamedPlatformChannel::ConnectToServer(named_pipe);
invitation = IncomingInvitation::Accept(std::move(endpoint)); } else
} #endif // !defined(OS_FUCHSIA)
{
endpoint =
PlatformChannel::RecoverPassedEndpointFromCommandLine(command_line);
}
if (run_as_broker_client) {
IncomingInvitation invitation =
IncomingInvitation::Accept(std::move(endpoint));
primordial_pipe = invitation.ExtractMessagePipe(kTestChildMessagePipeName); primordial_pipe = invitation.ExtractMessagePipe(kTestChildMessagePipeName);
} else { } else {
if (!named_pipe.empty()) { primordial_pipe =
primordial_pipe = g_child_isolated_connection.Get().Connect( g_child_isolated_connection.Get().Connect(std::move(endpoint));
NamedPlatformChannel::ConnectToServer(named_pipe));
} else {
primordial_pipe = g_child_isolated_connection.Get().Connect(
PlatformChannel::RecoverPassedEndpointFromCommandLine(command_line));
}
} }
} }
...@@ -290,8 +298,7 @@ int MultiprocessTestHelper::RunClientTestMain( ...@@ -290,8 +298,7 @@ int MultiprocessTestHelper::RunClientTestMain(
true /* pass_pipe_ownership_to_main */); true /* pass_pipe_ownership_to_main */);
} }
// static ScopedMessagePipeHandle MultiprocessTestHelper::primordial_pipe;
mojo::ScopedMessagePipeHandle MultiprocessTestHelper::primordial_pipe;
} // namespace test } // namespace test
} // namespace core } // namespace core
......
...@@ -8,7 +8,6 @@ component("platform") { ...@@ -8,7 +8,6 @@ component("platform") {
output_name = "mojo_cpp_platform" output_name = "mojo_cpp_platform"
public = [ public = [
"named_platform_channel.h",
"platform_channel.h", "platform_channel.h",
"platform_channel_endpoint.h", "platform_channel_endpoint.h",
"platform_channel_server_endpoint.h", "platform_channel_server_endpoint.h",
...@@ -16,7 +15,6 @@ component("platform") { ...@@ -16,7 +15,6 @@ component("platform") {
] ]
sources = [ sources = [
"named_platform_channel.cc",
"named_platform_channel_win.cc", "named_platform_channel_win.cc",
"platform_channel.cc", "platform_channel.cc",
"platform_channel_endpoint.cc", "platform_channel_endpoint.cc",
...@@ -34,17 +32,21 @@ component("platform") { ...@@ -34,17 +32,21 @@ component("platform") {
"//mojo/public/c/system:headers", "//mojo/public/c/system:headers",
] ]
if (is_posix && (!is_nacl && !is_fuchsia)) { if (is_posix && !is_nacl) {
sources += [ "named_platform_channel_posix.cc" ] sources += [ "named_platform_channel_posix.cc" ]
} }
if (is_fuchsia) { if (is_fuchsia) {
sources += [ "named_platform_channel_fuchsia.cc" ]
public_deps += [ public_deps += [
"//third_party/fuchsia-sdk/sdk:fdio", "//third_party/fuchsia-sdk/sdk:fdio",
"//third_party/fuchsia-sdk/sdk:zx", "//third_party/fuchsia-sdk/sdk:zx",
] ]
} }
if (!is_fuchsia) {
sources += [ "named_platform_channel.cc" ]
public += [ "named_platform_channel.h" ]
}
defines = [ "IS_MOJO_CPP_PLATFORM_IMPL" ] defines = [ "IS_MOJO_CPP_PLATFORM_IMPL" ]
} }
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "mojo/public/cpp/platform/named_platform_channel.h"
namespace mojo {
// static
PlatformChannelServerEndpoint NamedPlatformChannel::CreateServerEndpoint(
const Options& options,
ServerName* server_name) {
// TODO(https://crbug.com/754038): Implement, or remove dependencies.
NOTREACHED();
return {};
}
// static
PlatformChannelEndpoint NamedPlatformChannel::CreateClientEndpoint(
const ServerName& server_name) {
// TODO(https://crbug.com/754038): Implement, or remove dependencies.
NOTREACHED();
return {};
}
} // namespace mojo
...@@ -20,7 +20,6 @@ ...@@ -20,7 +20,6 @@
#include "base/test/scoped_task_environment.h" #include "base/test/scoped_task_environment.h"
#include "base/test/test_timeouts.h" #include "base/test/test_timeouts.h"
#include "build/build_config.h" #include "build/build_config.h"
#include "mojo/public/cpp/platform/named_platform_channel.h"
#include "mojo/public/cpp/platform/platform_channel.h" #include "mojo/public/cpp/platform/platform_channel.h"
#include "mojo/public/cpp/system/message_pipe.h" #include "mojo/public/cpp/system/message_pipe.h"
#include "mojo/public/cpp/system/platform_handle.h" #include "mojo/public/cpp/system/platform_handle.h"
...@@ -28,6 +27,10 @@ ...@@ -28,6 +27,10 @@
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
#include "testing/multiprocess_func_list.h" #include "testing/multiprocess_func_list.h"
#if !defined(OS_FUCHSIA)
#include "mojo/public/cpp/platform/named_platform_channel.h"
#endif
namespace mojo { namespace mojo {
namespace { namespace {
...@@ -38,14 +41,18 @@ enum class InvitationType { ...@@ -38,14 +41,18 @@ enum class InvitationType {
enum class TransportType { enum class TransportType {
kChannel, kChannel,
#if !defined(OS_FUCHSIA)
kChannelServer, kChannelServer,
#endif
}; };
// Switches and values to tell clients of parameterized test runs what mode they // Switches and values to tell clients of parameterized test runs what mode they
// should be testing against. // should be testing against.
const char kTransportTypeSwitch[] = "test-transport-type"; const char kTransportTypeSwitch[] = "test-transport-type";
const char kTransportTypeChannel[] = "channel"; const char kTransportTypeChannel[] = "channel";
#if !defined(OS_FUCHSIA)
const char kTransportTypeChannelServer[] = "channel-server"; const char kTransportTypeChannelServer[] = "channel-server";
#endif
class InvitationCppTest : public testing::Test, class InvitationCppTest : public testing::Test,
public testing::WithParamInterface<TransportType> { public testing::WithParamInterface<TransportType> {
...@@ -67,30 +74,33 @@ class InvitationCppTest : public testing::Test, ...@@ -67,30 +74,33 @@ class InvitationCppTest : public testing::Test,
base::Optional<PlatformChannel> channel; base::Optional<PlatformChannel> channel;
PlatformChannelEndpoint channel_endpoint; PlatformChannelEndpoint channel_endpoint;
PlatformChannelServerEndpoint server_endpoint; PlatformChannelServerEndpoint server_endpoint;
if (transport_type == TransportType::kChannel) { switch (transport_type) {
command_line.AppendSwitchASCII(kTransportTypeSwitch, case TransportType::kChannel: {
kTransportTypeChannel); command_line.AppendSwitchASCII(kTransportTypeSwitch,
channel.emplace(); kTransportTypeChannel);
channel->PrepareToPassRemoteEndpoint(&launch_options, &command_line); channel.emplace();
channel->PrepareToPassRemoteEndpoint(&launch_options, &command_line);
#if defined(OS_WIN) #if defined(OS_WIN)
launch_options.start_hidden = true; launch_options.start_hidden = true;
#endif #endif
channel_endpoint = channel->TakeLocalEndpoint(); channel_endpoint = channel->TakeLocalEndpoint();
} else if (transport_type == TransportType::kChannelServer) { break;
command_line.AppendSwitchASCII(kTransportTypeSwitch, }
kTransportTypeChannelServer); #if !defined(OS_FUCHSIA)
#if defined(OS_FUCHSIA) case TransportType::kChannelServer: {
NOTREACHED() << "Named pipe support does not exist for Mojo on Fuchsia."; command_line.AppendSwitchASCII(kTransportTypeSwitch,
#else kTransportTypeChannelServer);
NamedPlatformChannel::Options named_channel_options; NamedPlatformChannel::Options named_channel_options;
#if !defined(OS_WIN) #if !defined(OS_WIN)
CHECK(base::PathService::Get(base::DIR_TEMP, CHECK(base::PathService::Get(base::DIR_TEMP,
&named_channel_options.socket_dir)); &named_channel_options.socket_dir));
#endif
NamedPlatformChannel named_channel(named_channel_options);
named_channel.PassServerNameOnCommandLine(&command_line);
server_endpoint = named_channel.TakeServerEndpoint();
#endif #endif
NamedPlatformChannel named_channel(named_channel_options);
named_channel.PassServerNameOnCommandLine(&command_line);
server_endpoint = named_channel.TakeServerEndpoint();
break;
}
#endif // !defined(OS_FUCHSIA)
} }
child_process_ = base::SpawnMultiProcessTestChild( child_process_ = base::SpawnMultiProcessTestChild(
...@@ -104,28 +114,35 @@ class InvitationCppTest : public testing::Test, ...@@ -104,28 +114,35 @@ class InvitationCppTest : public testing::Test,
primordial_pipes[name] = invitation.AttachMessagePipe(name); primordial_pipes[name] = invitation.AttachMessagePipe(name);
} }
if (transport_type == TransportType::kChannel) { switch (transport_type) {
DCHECK(channel_endpoint.is_valid()); case TransportType::kChannel:
if (invitation_type == InvitationType::kNormal) { DCHECK(channel_endpoint.is_valid());
OutgoingInvitation::Send(std::move(invitation), child_process_.Handle(), if (invitation_type == InvitationType::kNormal) {
std::move(channel_endpoint), error_callback); OutgoingInvitation::Send(std::move(invitation),
} else { child_process_.Handle(),
DCHECK(primordial_pipes); std::move(channel_endpoint), error_callback);
DCHECK_EQ(num_primordial_pipes, 1u); } else {
primordial_pipes[0] = DCHECK(primordial_pipes);
OutgoingInvitation::SendIsolated(std::move(channel_endpoint)); DCHECK_EQ(num_primordial_pipes, 1u);
} primordial_pipes[0] =
} else if (transport_type == TransportType::kChannelServer) { OutgoingInvitation::SendIsolated(std::move(channel_endpoint));
DCHECK(server_endpoint.is_valid()); }
if (invitation_type == InvitationType::kNormal) { break;
OutgoingInvitation::Send(std::move(invitation), child_process_.Handle(), #if !defined(OS_FUCHSIA)
std::move(server_endpoint), error_callback); case TransportType::kChannelServer:
} else { DCHECK(server_endpoint.is_valid());
DCHECK(primordial_pipes); if (invitation_type == InvitationType::kNormal) {
DCHECK_EQ(num_primordial_pipes, 1u); OutgoingInvitation::Send(std::move(invitation),
primordial_pipes[0] = child_process_.Handle(),
OutgoingInvitation::SendIsolated(std::move(server_endpoint)); std::move(server_endpoint), error_callback);
} } else {
DCHECK(primordial_pipes);
DCHECK_EQ(num_primordial_pipes, 1u);
primordial_pipes[0] =
OutgoingInvitation::SendIsolated(std::move(server_endpoint));
}
break;
#endif // !defined(OS_FUCHSIA)
} }
} }
...@@ -165,15 +182,15 @@ class TestClientBase : public InvitationCppTest { ...@@ -165,15 +182,15 @@ class TestClientBase : public InvitationCppTest {
public: public:
static PlatformChannelEndpoint RecoverEndpointFromCommandLine() { static PlatformChannelEndpoint RecoverEndpointFromCommandLine() {
const auto& command_line = *base::CommandLine::ForCurrentProcess(); const auto& command_line = *base::CommandLine::ForCurrentProcess();
#if !defined(OS_FUCHSIA)
std::string transport_type_string = std::string transport_type_string =
command_line.GetSwitchValueASCII(kTransportTypeSwitch); command_line.GetSwitchValueASCII(kTransportTypeSwitch);
CHECK(!transport_type_string.empty()); CHECK(!transport_type_string.empty());
if (transport_type_string == kTransportTypeChannel) { if (transport_type_string != kTransportTypeChannel) {
return PlatformChannel::RecoverPassedEndpointFromCommandLine(
command_line);
} else {
return NamedPlatformChannel::ConnectToServer(command_line); return NamedPlatformChannel::ConnectToServer(command_line);
} }
#endif
return PlatformChannel::RecoverPassedEndpointFromCommandLine(command_line);
} }
static IncomingInvitation AcceptInvitation() { static IncomingInvitation AcceptInvitation() {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment