| 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_SYSTEM_IPC_SUPPORT_H_ | 5 #ifndef MOJO_EDK_SYSTEM_IPC_SUPPORT_H_ |
| 6 #define MOJO_EDK_SYSTEM_IPC_SUPPORT_H_ | 6 #define MOJO_EDK_SYSTEM_IPC_SUPPORT_H_ |
| 7 | 7 |
| 8 #include <functional> | 8 #include <functional> |
| 9 #include <memory> | 9 #include <memory> |
| 10 | 10 |
| 11 #include "base/gtest_prod_util.h" | 11 #include "base/gtest_prod_util.h" |
| 12 #include "mojo/edk/embedder/process_type.h" | 12 #include "mojo/edk/embedder/process_type.h" |
| 13 #include "mojo/edk/embedder/slave_info.h" | 13 #include "mojo/edk/embedder/slave_info.h" |
| 14 #include "mojo/edk/platform/scoped_platform_handle.h" | 14 #include "mojo/edk/platform/scoped_platform_handle.h" |
| 15 #include "mojo/edk/platform/task_runner.h" | 15 #include "mojo/edk/platform/task_runner.h" |
| 16 #include "mojo/edk/system/channel_id.h" | 16 #include "mojo/edk/system/channel_id.h" |
| 17 #include "mojo/edk/system/connection_identifier.h" | 17 #include "mojo/edk/system/connection_identifier.h" |
| 18 #include "mojo/edk/system/process_identifier.h" | 18 #include "mojo/edk/system/process_identifier.h" |
| 19 #include "mojo/edk/util/ref_ptr.h" | 19 #include "mojo/edk/util/ref_ptr.h" |
| 20 #include "mojo/public/cpp/system/macros.h" | 20 #include "mojo/public/cpp/system/macros.h" |
| 21 | 21 |
| 22 namespace mojo { | 22 namespace mojo { |
| 23 | 23 |
| 24 namespace embedder { | 24 namespace embedder { |
| 25 class PlatformSupport; | 25 class PlatformSupport; |
| 26 class ProcessDelegate; | 26 class ProcessDelegate; |
| 27 } | 27 } |
| 28 | 28 |
| 29 namespace platform { |
| 30 class PlatformHandleWatcher; |
| 31 } |
| 32 |
| 29 namespace system { | 33 namespace system { |
| 30 | 34 |
| 31 class ChannelManager; | 35 class ChannelManager; |
| 32 class ConnectionManager; | 36 class ConnectionManager; |
| 33 class MessagePipeDispatcher; | 37 class MessagePipeDispatcher; |
| 34 | 38 |
| 35 // This test (and its helper function) need to be friended. | 39 // This test (and its helper function) need to be friended. |
| 36 FORWARD_DECLARE_TEST(IPCSupportTest, MasterSlaveInternal); | 40 FORWARD_DECLARE_TEST(IPCSupportTest, MasterSlaveInternal); |
| 37 FORWARD_DECLARE_TEST(IPCSupportTest, MultiprocessMasterSlaveInternal); | 41 FORWARD_DECLARE_TEST(IPCSupportTest, MultiprocessMasterSlaveInternal); |
| 38 void MultiprocessMasterSlaveInternalTestChildTest(); | 42 void MultiprocessMasterSlaveInternalTestChildTest(); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 59 // must match the process type. |platform_handle| is only used for slave | 63 // must match the process type. |platform_handle| is only used for slave |
| 60 // processes. | 64 // processes. |
| 61 // | 65 // |
| 62 // All the (pointer) arguments must remain alive (and, in the case of task | 66 // All the (pointer) arguments must remain alive (and, in the case of task |
| 63 // runners, continue to process tasks) until |ShutdownOnIOThread()| has been | 67 // runners, continue to process tasks) until |ShutdownOnIOThread()| has been |
| 64 // called. | 68 // called. |
| 65 IPCSupport(embedder::PlatformSupport* platform_support, | 69 IPCSupport(embedder::PlatformSupport* platform_support, |
| 66 embedder::ProcessType process_type, | 70 embedder::ProcessType process_type, |
| 67 util::RefPtr<platform::TaskRunner>&& delegate_thread_task_runner, | 71 util::RefPtr<platform::TaskRunner>&& delegate_thread_task_runner, |
| 68 embedder::ProcessDelegate* process_delegate, | 72 embedder::ProcessDelegate* process_delegate, |
| 69 util::RefPtr<platform::TaskRunner>&& io_thread_task_runner, | 73 util::RefPtr<platform::TaskRunner>&& io_task_runner, |
| 74 platform::PlatformHandleWatcher* io_watcher, |
| 70 platform::ScopedPlatformHandle platform_handle); | 75 platform::ScopedPlatformHandle platform_handle); |
| 71 // Note: This object must be shut down before destruction (see | 76 // Note: This object must be shut down before destruction (see |
| 72 // |ShutdownOnIOThread()|). | 77 // |ShutdownOnIOThread()|). |
| 73 ~IPCSupport(); | 78 ~IPCSupport(); |
| 74 | 79 |
| 75 // This must be called (exactly once) on the I/O thread before this object is | 80 // This must be called (exactly once) on the I/O thread before this object is |
| 76 // destroyed (which may happen on any thread). Note: This does *not* call the | 81 // destroyed (which may happen on any thread). Note: This does *not* call the |
| 77 // process delegate's |OnShutdownComplete()|. | 82 // process delegate's |OnShutdownComplete()|. |
| 78 void ShutdownOnIOThread(); | 83 void ShutdownOnIOThread(); |
| 79 | 84 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 ChannelId* channel_id); | 127 ChannelId* channel_id); |
| 123 | 128 |
| 124 embedder::ProcessType process_type() const { return process_type_; } | 129 embedder::ProcessType process_type() const { return process_type_; } |
| 125 embedder::ProcessDelegate* process_delegate() const { | 130 embedder::ProcessDelegate* process_delegate() const { |
| 126 return process_delegate_; | 131 return process_delegate_; |
| 127 } | 132 } |
| 128 const util::RefPtr<platform::TaskRunner>& delegate_thread_task_runner() | 133 const util::RefPtr<platform::TaskRunner>& delegate_thread_task_runner() |
| 129 const { | 134 const { |
| 130 return delegate_thread_task_runner_; | 135 return delegate_thread_task_runner_; |
| 131 } | 136 } |
| 132 const util::RefPtr<platform::TaskRunner>& io_thread_task_runner() const { | 137 const util::RefPtr<platform::TaskRunner>& io_task_runner() const { |
| 133 return io_thread_task_runner_; | 138 return io_task_runner_; |
| 134 } | 139 } |
| 135 // TODO(vtl): The things that use the following should probably be moved into | 140 // TODO(vtl): The things that use the following should probably be moved into |
| 136 // this class. | 141 // this class. |
| 137 ChannelManager* channel_manager() const { return channel_manager_.get(); } | 142 ChannelManager* channel_manager() const { return channel_manager_.get(); } |
| 138 | 143 |
| 139 private: | 144 private: |
| 140 // These test |ConnectToSlaveInternal()| and |ConnectToMasterInternal()|. | 145 // These test |ConnectToSlaveInternal()| and |ConnectToMasterInternal()|. |
| 141 FRIEND_TEST_ALL_PREFIXES(IPCSupportTest, MasterSlaveInternal); | 146 FRIEND_TEST_ALL_PREFIXES(IPCSupportTest, MasterSlaveInternal); |
| 142 FRIEND_TEST_ALL_PREFIXES(IPCSupportTest, MultiprocessMasterSlaveInternal); | 147 FRIEND_TEST_ALL_PREFIXES(IPCSupportTest, MultiprocessMasterSlaveInternal); |
| 143 friend void MultiprocessMasterSlaveInternalTestChildTest(); | 148 friend void MultiprocessMasterSlaveInternalTestChildTest(); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 161 const ConnectionIdentifier& connection_id); | 166 const ConnectionIdentifier& connection_id); |
| 162 | 167 |
| 163 ConnectionManager* connection_manager() const { | 168 ConnectionManager* connection_manager() const { |
| 164 return connection_manager_.get(); | 169 return connection_manager_.get(); |
| 165 } | 170 } |
| 166 | 171 |
| 167 // These are all set on construction and reset by |ShutdownOnIOThread()|. | 172 // These are all set on construction and reset by |ShutdownOnIOThread()|. |
| 168 embedder::ProcessType process_type_; | 173 embedder::ProcessType process_type_; |
| 169 util::RefPtr<platform::TaskRunner> delegate_thread_task_runner_; | 174 util::RefPtr<platform::TaskRunner> delegate_thread_task_runner_; |
| 170 embedder::ProcessDelegate* process_delegate_; | 175 embedder::ProcessDelegate* process_delegate_; |
| 171 util::RefPtr<platform::TaskRunner> io_thread_task_runner_; | 176 util::RefPtr<platform::TaskRunner> io_task_runner_; |
| 177 platform::PlatformHandleWatcher* io_watcher_; |
| 172 | 178 |
| 173 std::unique_ptr<ConnectionManager> connection_manager_; | 179 std::unique_ptr<ConnectionManager> connection_manager_; |
| 174 std::unique_ptr<ChannelManager> channel_manager_; | 180 std::unique_ptr<ChannelManager> channel_manager_; |
| 175 | 181 |
| 176 MOJO_DISALLOW_COPY_AND_ASSIGN(IPCSupport); | 182 MOJO_DISALLOW_COPY_AND_ASSIGN(IPCSupport); |
| 177 }; | 183 }; |
| 178 | 184 |
| 179 } // namespace system | 185 } // namespace system |
| 180 } // namespace mojo | 186 } // namespace mojo |
| 181 | 187 |
| 182 #endif // MOJO_EDK_SYSTEM_IPC_SUPPORT_H_ | 188 #endif // MOJO_EDK_SYSTEM_IPC_SUPPORT_H_ |
| OLD | NEW |