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 edk { |
| 12 namespace test { |
| 13 |
| 14 namespace internal { |
| 15 |
| 16 ScopedIPCSupportHelper::ScopedIPCSupportHelper() |
| 17 : event_(true, false) { // Manual reset. |
| 18 } |
| 19 |
| 20 ScopedIPCSupportHelper::~ScopedIPCSupportHelper() { |
| 21 if (base::MessageLoop::current() && |
| 22 base::MessageLoop::current()->task_runner() == io_thread_task_runner_) { |
| 23 ShutdownIPCSupportOnIOThread(); |
| 24 } else { |
| 25 ShutdownIPCSupportAndWaitForNoChannels(); |
| 26 event_.Wait(); |
| 27 } |
| 28 } |
| 29 |
| 30 void ScopedIPCSupportHelper::Init( |
| 31 ProcessDelegate* process_delegate, |
| 32 scoped_refptr<base::TaskRunner> io_thread_task_runner) { |
| 33 io_thread_task_runner_ = io_thread_task_runner; |
| 34 // Note: Run delegate methods on the I/O thread. |
| 35 InitIPCSupport(io_thread_task_runner_, process_delegate, |
| 36 io_thread_task_runner_); |
| 37 } |
| 38 |
| 39 void ScopedIPCSupportHelper::OnShutdownCompleteImpl() { |
| 40 event_.Signal(); |
| 41 } |
| 42 |
| 43 } // namespace internal |
| 44 |
| 45 ScopedIPCSupport::ScopedIPCSupport( |
| 46 scoped_refptr<base::TaskRunner> io_thread_task_runner) { |
| 47 helper_.Init(this, io_thread_task_runner.Pass()); |
| 48 } |
| 49 |
| 50 ScopedIPCSupport::~ScopedIPCSupport() { |
| 51 } |
| 52 |
| 53 void ScopedIPCSupport::OnShutdownComplete() { |
| 54 helper_.OnShutdownCompleteImpl(); |
| 55 } |
| 56 |
| 57 } // namespace test |
| 58 } // namespace edk |
| 59 } // namespace mojo |
OLD | NEW |