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

Unified Diff: chrome/browser/printing/cloud_print/test/cloud_print_proxy_process_browsertest.cc

Issue 2415503002: Use ChannelMojo in CloudPrintProxyPolicyStartupTest.StartAndShutdown. (Closed)
Patch Set: Created 4 years, 2 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..8aedf83229442f2d37b4e33411c772d027f62c19 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;
@@ -293,12 +288,14 @@ int CloudPrintMockService_Main(SetExpectationsCallback set_expectations) {
std::string startup_channel_name =
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());
+ std::unique_ptr<IPC::ChannelProxy> startup_channel =
+ IPC::ChannelProxy::Create(
+ 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 +309,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 +318,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 +358,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 +459,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 +511,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
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698