Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(188)

Side by Side Diff: mojo/edk/test/scoped_ipc_support.h

Issue 1462083003: Add //mojo/edk/platform and move platform_task_runners.h there. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: update readme Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/platform_task_runner.h"
11 #include "mojo/edk/embedder/process_delegate.h" 10 #include "mojo/edk/embedder/process_delegate.h"
12 #include "mojo/edk/embedder/process_type.h" 11 #include "mojo/edk/embedder/process_type.h"
13 #include "mojo/edk/embedder/scoped_platform_handle.h" 12 #include "mojo/edk/embedder/scoped_platform_handle.h"
14 #include "mojo/edk/embedder/slave_process_delegate.h" 13 #include "mojo/edk/embedder/slave_process_delegate.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<embedder::PlatformTaskRunner>&& io_thread_task_runner, 31 util::RefPtr<platform::TaskRunner>&& io_thread_task_runner,
32 embedder::ScopedPlatformHandle platform_handle); 32 embedder::ScopedPlatformHandle platform_handle);
33 33
34 void OnShutdownCompleteImpl(); 34 void OnShutdownCompleteImpl();
35 35
36 private: 36 private:
37 util::RefPtr<embedder::PlatformTaskRunner> 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);
43 }; 43 };
44 44
45 } // namespace internal 45 } // namespace internal
46 46
47 // A simple class that calls |mojo::embedder::InitIPCSupport()| (with 47 // A simple class that calls |mojo::embedder::InitIPCSupport()| (with
48 // |ProcessType::NONE|) on construction and |ShutdownIPCSupport()| on 48 // |ProcessType::NONE|) on construction and |ShutdownIPCSupport()| on
49 // destruction (or |ShutdownIPCSupportOnIOThread()| if destroyed on the I/O 49 // destruction (or |ShutdownIPCSupportOnIOThread()| if destroyed on the I/O
50 // thread). 50 // thread).
51 class ScopedIPCSupport final : public embedder::ProcessDelegate { 51 class ScopedIPCSupport final : public embedder::ProcessDelegate {
52 public: 52 public:
53 explicit ScopedIPCSupport( 53 explicit ScopedIPCSupport(
54 util::RefPtr<embedder::PlatformTaskRunner>&& io_thread_task_runner); 54 util::RefPtr<platform::TaskRunner>&& io_thread_task_runner);
55 ~ScopedIPCSupport() override; 55 ~ScopedIPCSupport() override;
56 56
57 private: 57 private:
58 // |ProcessDelegate| implementation: 58 // |ProcessDelegate| implementation:
59 // Note: Executed on the I/O thread. 59 // Note: Executed on the I/O thread.
60 void OnShutdownComplete() override; 60 void OnShutdownComplete() override;
61 61
62 internal::ScopedIPCSupportHelper helper_; 62 internal::ScopedIPCSupportHelper helper_;
63 63
64 MOJO_DISALLOW_COPY_AND_ASSIGN(ScopedIPCSupport); 64 MOJO_DISALLOW_COPY_AND_ASSIGN(ScopedIPCSupport);
65 }; 65 };
66 66
67 // Like |ScopedIPCSupport|, but with |ProcessType::MASTER|. It will (optionally) 67 // Like |ScopedIPCSupport|, but with |ProcessType::MASTER|. It will (optionally)
68 // call a callback (on the I/O thread) on receiving |OnSlaveDisconnect()|. 68 // call a callback (on the I/O thread) on receiving |OnSlaveDisconnect()|.
69 class ScopedMasterIPCSupport final : public embedder::MasterProcessDelegate { 69 class ScopedMasterIPCSupport final : public embedder::MasterProcessDelegate {
70 public: 70 public:
71 explicit ScopedMasterIPCSupport( 71 explicit ScopedMasterIPCSupport(
72 util::RefPtr<embedder::PlatformTaskRunner>&& io_thread_task_runner); 72 util::RefPtr<platform::TaskRunner>&& io_thread_task_runner);
73 ScopedMasterIPCSupport( 73 ScopedMasterIPCSupport(
74 util::RefPtr<embedder::PlatformTaskRunner>&& io_thread_task_runner, 74 util::RefPtr<platform::TaskRunner>&& io_thread_task_runner,
75 base::Callback<void(embedder::SlaveInfo slave_info)> on_slave_disconnect); 75 base::Callback<void(embedder::SlaveInfo slave_info)> on_slave_disconnect);
76 ~ScopedMasterIPCSupport() override; 76 ~ScopedMasterIPCSupport() override;
77 77
78 private: 78 private:
79 // |MasterProcessDelegate| implementation: 79 // |MasterProcessDelegate| implementation:
80 // Note: Executed on the I/O thread. 80 // Note: Executed on the I/O thread.
81 void OnShutdownComplete() override; 81 void OnShutdownComplete() override;
82 void OnSlaveDisconnect(embedder::SlaveInfo slave_info) override; 82 void OnSlaveDisconnect(embedder::SlaveInfo slave_info) override;
83 83
84 internal::ScopedIPCSupportHelper helper_; 84 internal::ScopedIPCSupportHelper helper_;
85 base::Callback<void(embedder::SlaveInfo slave_info)> on_slave_disconnect_; 85 base::Callback<void(embedder::SlaveInfo slave_info)> on_slave_disconnect_;
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<embedder::PlatformTaskRunner>&& io_thread_task_runner, 95 util::RefPtr<platform::TaskRunner>&& io_thread_task_runner,
96 embedder::ScopedPlatformHandle platform_handle); 96 embedder::ScopedPlatformHandle platform_handle);
97 ScopedSlaveIPCSupport( 97 ScopedSlaveIPCSupport(
98 util::RefPtr<embedder::PlatformTaskRunner>&& io_thread_task_runner, 98 util::RefPtr<platform::TaskRunner>&& io_thread_task_runner,
99 embedder::ScopedPlatformHandle platform_handle, 99 embedder::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_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698