| 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 #ifndef MOJO_EDK_TEST_SCOPED_IPC_SUPPORT_H_ |
| 6 #define MOJO_EDK_TEST_SCOPED_IPC_SUPPORT_H_ |
| 7 |
| 8 #include "base/callback.h" |
| 9 #include "base/memory/ref_counted.h" |
| 10 #include "base/synchronization/waitable_event.h" |
| 11 #include "base/task_runner.h" |
| 12 #include "mojo/edk/embedder/process_delegate.h" |
| 13 #include "mojo/edk/embedder/process_type.h" |
| 14 #include "mojo/edk/embedder/scoped_platform_handle.h" |
| 15 #include "mojo/public/cpp/system/macros.h" |
| 16 |
| 17 namespace mojo { |
| 18 namespace test { |
| 19 |
| 20 namespace internal { |
| 21 |
| 22 class ScopedIPCSupportHelper { |
| 23 public: |
| 24 ScopedIPCSupportHelper(); |
| 25 ~ScopedIPCSupportHelper(); |
| 26 |
| 27 void Init(embedder::ProcessType process_type, |
| 28 embedder::ProcessDelegate* process_delegate, |
| 29 scoped_refptr<base::TaskRunner> io_thread_task_runner, |
| 30 embedder::ScopedPlatformHandle platform_handle); |
| 31 |
| 32 void OnShutdownCompleteImpl(); |
| 33 |
| 34 private: |
| 35 scoped_refptr<base::TaskRunner> io_thread_task_runner_; |
| 36 |
| 37 // Set after shut down. |
| 38 base::WaitableEvent event_; |
| 39 |
| 40 MOJO_DISALLOW_COPY_AND_ASSIGN(ScopedIPCSupportHelper); |
| 41 }; |
| 42 |
| 43 } // namespace internal |
| 44 |
| 45 // A simple class that calls |mojo::embedder::InitIPCSupport()| (with |
| 46 // |ProcessType::NONE|) on construction and |ShutdownIPCSupport()| on |
| 47 // destruction (or |ShutdownIPCSupportOnIOThread()| if destroyed on the I/O |
| 48 // thread). |
| 49 class ScopedIPCSupport : public embedder::ProcessDelegate { |
| 50 public: |
| 51 explicit ScopedIPCSupport( |
| 52 scoped_refptr<base::TaskRunner> io_thread_task_runner); |
| 53 ~ScopedIPCSupport() override; |
| 54 |
| 55 private: |
| 56 // |ProcessDelegate| implementation: |
| 57 // Note: Executed on the I/O thread. |
| 58 void OnShutdownComplete() override; |
| 59 |
| 60 internal::ScopedIPCSupportHelper helper_; |
| 61 |
| 62 MOJO_DISALLOW_COPY_AND_ASSIGN(ScopedIPCSupport); |
| 63 }; |
| 64 |
| 65 } // namespace test |
| 66 } // namespace mojo |
| 67 |
| 68 #endif // MOJO_EDK_TEST_SCOPED_IPC_SUPPORT_H_ |
| OLD | NEW |