| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 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 #ifndef MOJO_EDK_TEST_SCOPED_IPC_SUPPORT_H_ | 5 #ifndef MOJO_EDK_TEST_SCOPED_IPC_SUPPORT_H_ |
| 6 #define MOJO_EDK_TEST_SCOPED_IPC_SUPPORT_H_ | 6 #define MOJO_EDK_TEST_SCOPED_IPC_SUPPORT_H_ |
| 7 | 7 |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "mojo/edk/embedder/master_process_delegate.h" | 9 #include "mojo/edk/embedder/master_process_delegate.h" |
| 10 #include "mojo/edk/embedder/process_delegate.h" | 10 #include "mojo/edk/embedder/process_delegate.h" |
| 11 #include "mojo/edk/embedder/process_type.h" | 11 #include "mojo/edk/embedder/process_type.h" |
| 12 #include "mojo/edk/embedder/scoped_platform_handle.h" | |
| 13 #include "mojo/edk/embedder/slave_process_delegate.h" | 12 #include "mojo/edk/embedder/slave_process_delegate.h" |
| 13 #include "mojo/edk/platform/scoped_platform_handle.h" |
| 14 #include "mojo/edk/platform/task_runner.h" | 14 #include "mojo/edk/platform/task_runner.h" |
| 15 #include "mojo/edk/util/ref_ptr.h" | 15 #include "mojo/edk/util/ref_ptr.h" |
| 16 #include "mojo/edk/util/waitable_event.h" | 16 #include "mojo/edk/util/waitable_event.h" |
| 17 #include "mojo/public/cpp/system/macros.h" | 17 #include "mojo/public/cpp/system/macros.h" |
| 18 | 18 |
| 19 namespace mojo { | 19 namespace mojo { |
| 20 namespace test { | 20 namespace test { |
| 21 | 21 |
| 22 namespace internal { | 22 namespace internal { |
| 23 | 23 |
| 24 class ScopedIPCSupportHelper final { | 24 class ScopedIPCSupportHelper final { |
| 25 public: | 25 public: |
| 26 ScopedIPCSupportHelper(); | 26 ScopedIPCSupportHelper(); |
| 27 ~ScopedIPCSupportHelper(); | 27 ~ScopedIPCSupportHelper(); |
| 28 | 28 |
| 29 void Init(embedder::ProcessType process_type, | 29 void Init(embedder::ProcessType process_type, |
| 30 embedder::ProcessDelegate* process_delegate, | 30 embedder::ProcessDelegate* process_delegate, |
| 31 util::RefPtr<platform::TaskRunner>&& io_thread_task_runner, | 31 util::RefPtr<platform::TaskRunner>&& io_thread_task_runner, |
| 32 embedder::ScopedPlatformHandle platform_handle); | 32 platform::ScopedPlatformHandle platform_handle); |
| 33 | 33 |
| 34 void OnShutdownCompleteImpl(); | 34 void OnShutdownCompleteImpl(); |
| 35 | 35 |
| 36 private: | 36 private: |
| 37 util::RefPtr<platform::TaskRunner> io_thread_task_runner_; | 37 util::RefPtr<platform::TaskRunner> io_thread_task_runner_; |
| 38 | 38 |
| 39 // Set after shut down. | 39 // Set after shut down. |
| 40 util::ManualResetWaitableEvent event_; | 40 util::ManualResetWaitableEvent event_; |
| 41 | 41 |
| 42 MOJO_DISALLOW_COPY_AND_ASSIGN(ScopedIPCSupportHelper); | 42 MOJO_DISALLOW_COPY_AND_ASSIGN(ScopedIPCSupportHelper); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 | 86 |
| 87 MOJO_DISALLOW_COPY_AND_ASSIGN(ScopedMasterIPCSupport); | 87 MOJO_DISALLOW_COPY_AND_ASSIGN(ScopedMasterIPCSupport); |
| 88 }; | 88 }; |
| 89 | 89 |
| 90 // Like |ScopedIPCSupport|, but with |ProcessType::SLAVE|. It will (optionally) | 90 // Like |ScopedIPCSupport|, but with |ProcessType::SLAVE|. It will (optionally) |
| 91 // call a callback (on the I/O thread) on receiving |OnMasterDisconnect()|. | 91 // call a callback (on the I/O thread) on receiving |OnMasterDisconnect()|. |
| 92 class ScopedSlaveIPCSupport final : public embedder::SlaveProcessDelegate { | 92 class ScopedSlaveIPCSupport final : public embedder::SlaveProcessDelegate { |
| 93 public: | 93 public: |
| 94 ScopedSlaveIPCSupport( | 94 ScopedSlaveIPCSupport( |
| 95 util::RefPtr<platform::TaskRunner>&& io_thread_task_runner, | 95 util::RefPtr<platform::TaskRunner>&& io_thread_task_runner, |
| 96 embedder::ScopedPlatformHandle platform_handle); | 96 platform::ScopedPlatformHandle platform_handle); |
| 97 ScopedSlaveIPCSupport( | 97 ScopedSlaveIPCSupport( |
| 98 util::RefPtr<platform::TaskRunner>&& io_thread_task_runner, | 98 util::RefPtr<platform::TaskRunner>&& io_thread_task_runner, |
| 99 embedder::ScopedPlatformHandle platform_handle, | 99 platform::ScopedPlatformHandle platform_handle, |
| 100 base::Closure on_master_disconnect); | 100 base::Closure on_master_disconnect); |
| 101 ~ScopedSlaveIPCSupport() override; | 101 ~ScopedSlaveIPCSupport() override; |
| 102 | 102 |
| 103 private: | 103 private: |
| 104 // |SlaveProcessDelegate| implementation: | 104 // |SlaveProcessDelegate| implementation: |
| 105 // Note: Executed on the I/O thread. | 105 // Note: Executed on the I/O thread. |
| 106 void OnShutdownComplete() override; | 106 void OnShutdownComplete() override; |
| 107 void OnMasterDisconnect() override; | 107 void OnMasterDisconnect() override; |
| 108 | 108 |
| 109 internal::ScopedIPCSupportHelper helper_; | 109 internal::ScopedIPCSupportHelper helper_; |
| 110 base::Closure on_master_disconnect_; | 110 base::Closure on_master_disconnect_; |
| 111 | 111 |
| 112 MOJO_DISALLOW_COPY_AND_ASSIGN(ScopedSlaveIPCSupport); | 112 MOJO_DISALLOW_COPY_AND_ASSIGN(ScopedSlaveIPCSupport); |
| 113 }; | 113 }; |
| 114 | 114 |
| 115 } // namespace test | 115 } // namespace test |
| 116 } // namespace mojo | 116 } // namespace mojo |
| 117 | 117 |
| 118 #endif // MOJO_EDK_TEST_SCOPED_IPC_SUPPORT_H_ | 118 #endif // MOJO_EDK_TEST_SCOPED_IPC_SUPPORT_H_ |
| OLD | NEW |