| Index: third_party/mojo/src/mojo/edk/test/scoped_ipc_support.cc
|
| diff --git a/third_party/mojo/src/mojo/edk/test/scoped_ipc_support.cc b/third_party/mojo/src/mojo/edk/test/scoped_ipc_support.cc
|
| index 9f3b97d7579a3b2fa8dd3db435f6bb80bc1a2aca..fad9c82c6d296bd88df7fdf81da90a8c961e9588 100644
|
| --- a/third_party/mojo/src/mojo/edk/test/scoped_ipc_support.cc
|
| +++ b/third_party/mojo/src/mojo/edk/test/scoped_ipc_support.cc
|
| @@ -10,17 +10,13 @@
|
| namespace mojo {
|
| namespace test {
|
|
|
| -ScopedIPCSupport::ScopedIPCSupport(
|
| - scoped_refptr<base::TaskRunner> io_thread_task_runner)
|
| - : io_thread_task_runner_(io_thread_task_runner),
|
| - event_(true, false) { // Manual reset.
|
| - // Note: Run delegate methods on the I/O thread.
|
| - embedder::InitIPCSupport(embedder::ProcessType::NONE, io_thread_task_runner,
|
| - this, io_thread_task_runner,
|
| - embedder::ScopedPlatformHandle());
|
| +namespace internal {
|
| +
|
| +ScopedIPCSupportHelper::ScopedIPCSupportHelper()
|
| + : event_(true, false) { // Manual reset.
|
| }
|
|
|
| -ScopedIPCSupport::~ScopedIPCSupport() {
|
| +ScopedIPCSupportHelper::~ScopedIPCSupportHelper() {
|
| if (base::MessageLoop::current() &&
|
| base::MessageLoop::current()->task_runner() == io_thread_task_runner_) {
|
| embedder::ShutdownIPCSupportOnIOThread();
|
| @@ -30,9 +26,90 @@ ScopedIPCSupport::~ScopedIPCSupport() {
|
| }
|
| }
|
|
|
| -void ScopedIPCSupport::OnShutdownComplete() {
|
| +void ScopedIPCSupportHelper::Init(
|
| + embedder::ProcessType process_type,
|
| + embedder::ProcessDelegate* process_delegate,
|
| + scoped_refptr<base::TaskRunner> io_thread_task_runner,
|
| + embedder::ScopedPlatformHandle platform_handle) {
|
| + io_thread_task_runner_ = io_thread_task_runner;
|
| + // Note: Run delegate methods on the I/O thread.
|
| + embedder::InitIPCSupport(process_type, io_thread_task_runner_,
|
| + process_delegate, io_thread_task_runner_,
|
| + platform_handle.Pass());
|
| +}
|
| +
|
| +void ScopedIPCSupportHelper::OnShutdownCompleteImpl() {
|
| event_.Signal();
|
| }
|
|
|
| +} // namespace internal
|
| +
|
| +ScopedIPCSupport::ScopedIPCSupport(
|
| + scoped_refptr<base::TaskRunner> io_thread_task_runner) {
|
| + helper_.Init(embedder::ProcessType::NONE, this, io_thread_task_runner.Pass(),
|
| + embedder::ScopedPlatformHandle());
|
| +}
|
| +
|
| +ScopedIPCSupport::~ScopedIPCSupport() {
|
| +}
|
| +
|
| +void ScopedIPCSupport::OnShutdownComplete() {
|
| + helper_.OnShutdownCompleteImpl();
|
| +}
|
| +
|
| +ScopedMasterIPCSupport::ScopedMasterIPCSupport(
|
| + scoped_refptr<base::TaskRunner> io_thread_task_runner) {
|
| + helper_.Init(embedder::ProcessType::MASTER, this,
|
| + io_thread_task_runner.Pass(), embedder::ScopedPlatformHandle());
|
| +}
|
| +
|
| +ScopedMasterIPCSupport::ScopedMasterIPCSupport(
|
| + scoped_refptr<base::TaskRunner> io_thread_task_runner,
|
| + base::Callback<void(embedder::SlaveInfo slave_info)> on_slave_disconnect)
|
| + : on_slave_disconnect_(on_slave_disconnect) {
|
| + helper_.Init(embedder::ProcessType::MASTER, this,
|
| + io_thread_task_runner.Pass(), embedder::ScopedPlatformHandle());
|
| +}
|
| +
|
| +ScopedMasterIPCSupport::~ScopedMasterIPCSupport() {
|
| +}
|
| +
|
| +void ScopedMasterIPCSupport::OnShutdownComplete() {
|
| + helper_.OnShutdownCompleteImpl();
|
| +}
|
| +
|
| +void ScopedMasterIPCSupport::OnSlaveDisconnect(embedder::SlaveInfo slave_info) {
|
| + if (!on_slave_disconnect_.is_null())
|
| + on_slave_disconnect_.Run(slave_info);
|
| +}
|
| +
|
| +ScopedSlaveIPCSupport::ScopedSlaveIPCSupport(
|
| + scoped_refptr<base::TaskRunner> io_thread_task_runner,
|
| + embedder::ScopedPlatformHandle platform_handle) {
|
| + helper_.Init(embedder::ProcessType::SLAVE, this, io_thread_task_runner.Pass(),
|
| + platform_handle.Pass());
|
| +}
|
| +
|
| +ScopedSlaveIPCSupport::ScopedSlaveIPCSupport(
|
| + scoped_refptr<base::TaskRunner> io_thread_task_runner,
|
| + embedder::ScopedPlatformHandle platform_handle,
|
| + base::Closure on_master_disconnect)
|
| + : on_master_disconnect_(on_master_disconnect) {
|
| + helper_.Init(embedder::ProcessType::SLAVE, this, io_thread_task_runner.Pass(),
|
| + platform_handle.Pass());
|
| +}
|
| +
|
| +ScopedSlaveIPCSupport::~ScopedSlaveIPCSupport() {
|
| +}
|
| +
|
| +void ScopedSlaveIPCSupport::OnShutdownComplete() {
|
| + helper_.OnShutdownCompleteImpl();
|
| +}
|
| +
|
| +void ScopedSlaveIPCSupport::OnMasterDisconnect() {
|
| + if (!on_master_disconnect_.is_null())
|
| + on_master_disconnect_.Run();
|
| +}
|
| +
|
| } // namespace test
|
| } // namespace mojo
|
|
|