OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "mojo/edk/test/scoped_ipc_support.h" |
| 6 |
| 7 #include "base/message_loop/message_loop.h" |
| 8 #include "mojo/edk/embedder/embedder.h" |
| 9 |
| 10 namespace mojo { |
| 11 namespace test { |
| 12 |
| 13 ScopedIPCSupport::ScopedIPCSupport( |
| 14 scoped_refptr<base::TaskRunner> io_thread_task_runner) |
| 15 : io_thread_task_runner_(io_thread_task_runner), |
| 16 event_(true, false) { // Manual reset. |
| 17 // Note: Run delegate methods on the I/O thread. |
| 18 embedder::InitIPCSupport(embedder::ProcessType::NONE, io_thread_task_runner, |
| 19 this, io_thread_task_runner, |
| 20 embedder::ScopedPlatformHandle()); |
| 21 } |
| 22 |
| 23 ScopedIPCSupport::~ScopedIPCSupport() { |
| 24 if (base::MessageLoop::current() && |
| 25 base::MessageLoop::current()->task_runner() == io_thread_task_runner_) { |
| 26 embedder::ShutdownIPCSupportOnIOThread(); |
| 27 } else { |
| 28 embedder::ShutdownIPCSupport(); |
| 29 event_.Wait(); |
| 30 } |
| 31 } |
| 32 |
| 33 void ScopedIPCSupport::OnShutdownComplete() { |
| 34 event_.Signal(); |
| 35 } |
| 36 |
| 37 } // namespace test |
| 38 } // namespace mojo |
OLD | NEW |