| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Create a service process that uses a Mock to respond to the browser in order | 5 // Create a service process that uses a Mock to respond to the browser in order |
| 6 // to test launching the browser using the cloud print policy check command | 6 // to test launching the browser using the cloud print policy check command |
| 7 // line switch. | 7 // line switch. |
| 8 | 8 |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| (...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 463 | 463 |
| 464 startup_channel_handle_ = mojo::edk::NamedPlatformHandle( | 464 startup_channel_handle_ = mojo::edk::NamedPlatformHandle( |
| 465 base::StringPrintf("%d.%p.%d", base::GetCurrentProcId(), this, | 465 base::StringPrintf("%d.%p.%d", base::GetCurrentProcId(), this, |
| 466 base::RandInt(0, std::numeric_limits<int>::max()))); | 466 base::RandInt(0, std::numeric_limits<int>::max()))); |
| 467 startup_channel_ = IPC::ChannelProxy::Create( | 467 startup_channel_ = IPC::ChannelProxy::Create( |
| 468 mojo::edk::ConnectToPeerProcess( | 468 mojo::edk::ConnectToPeerProcess( |
| 469 mojo::edk::CreateServerHandle(startup_channel_handle_)) | 469 mojo::edk::CreateServerHandle(startup_channel_handle_)) |
| 470 .release(), | 470 .release(), |
| 471 IPC::Channel::MODE_SERVER, this, IOTaskRunner()); | 471 IPC::Channel::MODE_SERVER, this, IOTaskRunner()); |
| 472 | 472 |
| 473 base::Process process = SpawnChild(name); | 473 base::SpawnChildResult spawn_result = SpawnChild(name); |
| 474 EXPECT_TRUE(process.IsValid()); | 474 EXPECT_TRUE(spawn_result.process.IsValid()); |
| 475 return process; | 475 return std::move(spawn_result.process); |
| 476 } | 476 } |
| 477 | 477 |
| 478 void CloudPrintProxyPolicyStartupTest::WaitForConnect() { | 478 void CloudPrintProxyPolicyStartupTest::WaitForConnect() { |
| 479 observer_.Wait(); | 479 observer_.Wait(); |
| 480 EXPECT_TRUE(CheckServiceProcessReady()); | 480 EXPECT_TRUE(CheckServiceProcessReady()); |
| 481 EXPECT_TRUE(base::ThreadTaskRunnerHandle::Get().get()); | 481 EXPECT_TRUE(base::ThreadTaskRunnerHandle::Get().get()); |
| 482 | 482 |
| 483 mojo::MessagePipe pipe; | 483 mojo::MessagePipe pipe; |
| 484 BrowserThread::PostBlockingPoolTask( | 484 BrowserThread::PostBlockingPoolTask( |
| 485 FROM_HERE, base::Bind(&ConnectOnBlockingPool, base::Passed(&pipe.handle1), | 485 FROM_HERE, base::Bind(&ConnectOnBlockingPool, base::Passed(&pipe.handle1), |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 535 // constructed. | 535 // constructed. |
| 536 chrome::TestingIOThreadState testing_io_thread_state; | 536 chrome::TestingIOThreadState testing_io_thread_state; |
| 537 | 537 |
| 538 base::Process process = | 538 base::Process process = |
| 539 Launch("CloudPrintMockService_StartEnabledWaitForQuit"); | 539 Launch("CloudPrintMockService_StartEnabledWaitForQuit"); |
| 540 WaitForConnect(); | 540 WaitForConnect(); |
| 541 ShutdownAndWaitForExitWithTimeout(std::move(process)); | 541 ShutdownAndWaitForExitWithTimeout(std::move(process)); |
| 542 ServiceProcessControl::GetInstance()->Disconnect(); | 542 ServiceProcessControl::GetInstance()->Disconnect(); |
| 543 content::RunAllPendingInMessageLoop(); | 543 content::RunAllPendingInMessageLoop(); |
| 544 } | 544 } |
| OLD | NEW |