Chromium Code Reviews| Index: chrome/browser/printing/cloud_print/test/cloud_print_proxy_process_browsertest.cc |
| diff --git a/chrome/browser/printing/cloud_print/test/cloud_print_proxy_process_browsertest.cc b/chrome/browser/printing/cloud_print/test/cloud_print_proxy_process_browsertest.cc |
| index 1ab10361a2bd78de6a4ce22d4c646c3e3bd28363..27cf6662853221bc140585173b00efb7288efb92 100644 |
| --- a/chrome/browser/printing/cloud_print/test/cloud_print_proxy_process_browsertest.cc |
| +++ b/chrome/browser/printing/cloud_print/test/cloud_print_proxy_process_browsertest.cc |
| @@ -50,8 +50,6 @@ |
| #include "content/public/test/test_browser_thread_bundle.h" |
| #include "content/public/test/test_utils.h" |
| #include "ipc/ipc_channel_mojo.h" |
| -#include "ipc/ipc_descriptors.h" |
| -#include "ipc/ipc_multiprocess_test.h" |
| #include "mojo/edk/embedder/embedder.h" |
| #include "mojo/edk/embedder/named_platform_handle.h" |
| #include "mojo/edk/embedder/named_platform_handle_utils.h" |
| @@ -63,9 +61,6 @@ |
| #if defined(OS_MACOSX) |
| #include "chrome/common/mac/mock_launchd.h" |
| #endif |
| -#if defined(OS_POSIX) |
| -#include "base/posix/global_descriptors.h" |
| -#endif |
| using ::testing::AnyNumber; |
| using ::testing::Assign; |
| @@ -294,11 +289,12 @@ int CloudPrintMockService_Main(SetExpectationsCallback set_expectations) { |
| base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
| kProcessChannelID); |
| std::unique_ptr<IPC::ChannelProxy> startup_channel; |
| - startup_channel = |
| - IPC::ChannelProxy::Create(startup_channel_name, |
| - IPC::Channel::MODE_CLIENT, |
| - &listener, |
| - service_process.io_task_runner()); |
| + startup_channel = IPC::ChannelProxy::Create( |
|
Lei Zhang
2016/10/12 07:34:54
Can this be combined with the previous line?
Sam McNally
2016/10/12 08:25:48
Done.
|
| + mojo::edk::ConnectToPeerProcess( |
| + mojo::edk::CreateClientHandle( |
| + mojo::edk::NamedPlatformHandle(startup_channel_name))) |
| + .release(), |
| + IPC::Channel::MODE_CLIENT, &listener, service_process.io_task_runner()); |
| base::RunLoop().Run(); |
| if (!Mock::VerifyAndClearExpectations(&server)) |
| @@ -312,7 +308,7 @@ void SetServiceEnabledExpectations(MockServiceIPCServer* server) { |
| server->SetServiceEnabledExpectations(); |
| } |
| -MULTIPROCESS_IPC_TEST_MAIN(CloudPrintMockService_StartEnabledWaitForQuit) { |
| +MULTIPROCESS_TEST_MAIN(CloudPrintMockService_StartEnabledWaitForQuit) { |
| return CloudPrintMockService_Main( |
| base::Bind(&SetServiceEnabledExpectations)); |
| } |
| @@ -321,7 +317,7 @@ void SetServiceWillBeDisabledExpectations(MockServiceIPCServer* server) { |
| server->SetWillBeDisabledExpectations(); |
| } |
| -MULTIPROCESS_IPC_TEST_MAIN(CloudPrintMockService_StartEnabledExpectDisabled) { |
| +MULTIPROCESS_TEST_MAIN(CloudPrintMockService_StartEnabledExpectDisabled) { |
| return CloudPrintMockService_Main( |
| base::Bind(&SetServiceWillBeDisabledExpectations)); |
| } |
| @@ -361,7 +357,7 @@ class CloudPrintProxyPolicyStartupTest : public base::MultiProcessTest, |
| content::TestBrowserThreadBundle thread_bundle_; |
| base::ScopedTempDir temp_user_data_dir_; |
| - std::string startup_channel_id_; |
| + mojo::edk::NamedPlatformHandle startup_channel_handle_; |
| std::unique_ptr<IPC::ChannelProxy> startup_channel_; |
| std::unique_ptr<ChromeContentClient> content_client_; |
| std::unique_ptr<ChromeContentBrowserClient> browser_content_client_; |
| @@ -462,26 +458,16 @@ base::Process CloudPrintProxyPolicyStartupTest::Launch( |
| const std::string& name) { |
| EXPECT_FALSE(CheckServiceProcessReady()); |
| - startup_channel_id_ = |
| - base::StringPrintf("%d.%p.%d", |
| - base::GetCurrentProcId(), this, |
| - base::RandInt(0, std::numeric_limits<int>::max())); |
| - startup_channel_ = IPC::ChannelProxy::Create(startup_channel_id_, |
| - IPC::Channel::MODE_SERVER, |
| - this, |
| - IOTaskRunner()); |
| - |
| -#if defined(OS_POSIX) |
| - base::FileHandleMappingVector ipc_file_list; |
| - ipc_file_list.push_back(std::make_pair( |
| - startup_channel_->TakeClientFileDescriptor().release(), |
| - kPrimaryIPCChannel + base::GlobalDescriptors::kBaseDescriptor)); |
| - base::LaunchOptions options; |
| - options.fds_to_remap = &ipc_file_list; |
| - base::Process process = SpawnChildWithOptions(name, options); |
| -#else |
| + startup_channel_handle_ = mojo::edk::NamedPlatformHandle( |
| + base::StringPrintf("%d.%p.%d", base::GetCurrentProcId(), this, |
| + base::RandInt(0, std::numeric_limits<int>::max()))); |
| + startup_channel_ = IPC::ChannelProxy::Create( |
| + mojo::edk::ConnectToPeerProcess( |
| + mojo::edk::CreateServerHandle(startup_channel_handle_, false)) |
| + .release(), |
| + IPC::Channel::MODE_SERVER, this, IOTaskRunner()); |
| + |
| base::Process process = SpawnChild(name); |
| -#endif |
| EXPECT_TRUE(process.IsValid()); |
| return process; |
| } |
| @@ -524,7 +510,7 @@ void CloudPrintProxyPolicyStartupTest::OnChannelConnected(int32_t peer_pid) { |
| base::CommandLine CloudPrintProxyPolicyStartupTest::MakeCmdLine( |
| const std::string& procname) { |
| base::CommandLine cl = MultiProcessTest::MakeCmdLine(procname); |
| - cl.AppendSwitchASCII(kProcessChannelID, startup_channel_id_); |
| + cl.AppendSwitchNative(kProcessChannelID, startup_channel_handle_.name); |
| #if defined(OS_MACOSX) |
| cl.AppendSwitchASCII(kTestExecutablePath, executable_path_.value()); |
| #endif |