Chromium Code Reviews| Index: mojo/edk/system/child_broker_host.h |
| diff --git a/mojo/edk/system/child_broker_host.h b/mojo/edk/system/child_broker_host.h |
| index 7f4bc61e19db33cb60f4c700c0d6a67c7aeb654d..163ada13c583d0e9a442dee9449ef795e67ad6ac 100644 |
| --- a/mojo/edk/system/child_broker_host.h |
| +++ b/mojo/edk/system/child_broker_host.h |
| @@ -8,20 +8,24 @@ |
| #include <vector> |
| #include "base/compiler_specific.h" |
| +#include "base/macros.h" |
| #include "base/message_loop/message_loop.h" |
| #include "base/process/process_handle.h" |
| #include "mojo/edk/embedder/scoped_platform_handle.h" |
| +#include "mojo/edk/system/raw_channel.h" |
| #include "mojo/edk/system/system_impl_export.h" |
| namespace mojo { |
| namespace edk { |
| -// Responds to requests from a child process to exchange handles to tokens and |
| -// vice versa. There is one object of this class per child process host object. |
| +// Responds to requests from ChildBroker. This is used to handle message pipe |
| +// multiplexing and Windows sandbox messages. There is one object of this class |
| +// per child process host object. |
| // This object will delete itself when it notices that the pipe is broken. |
| class MOJO_SYSTEM_IMPL_EXPORT ChildBrokerHost |
| + : public RawChannel::Delegate |
| #if defined(OS_WIN) |
| - : NON_EXPORTED_BASE(public base::MessageLoopForIO::IOHandler) { |
| + , NON_EXPORTED_BASE(public base::MessageLoopForIO::IOHandler) { |
| #else |
| { |
| #endif |
| @@ -33,17 +37,29 @@ class MOJO_SYSTEM_IMPL_EXPORT ChildBrokerHost |
| // this class. |
| ChildBrokerHost(base::ProcessHandle child_process, ScopedPlatformHandle pipe); |
| + base::ProcessId GetProcessId(); |
| + |
| + // Sends a message to the child process to connect to |process_id| via |pipe|. |
| + void ConnectToProcess(base::ProcessId process_id, ScopedPlatformHandle pipe); |
| + |
| + // Sends a message to the child process that |pipe_id|'s other end is in |
| + // |process_id|. |
|
yzshen1
2015/12/03 23:37:50
nit: please update the comment to |peer_id|.
jam
2015/12/04 05:06:47
Done.
|
| + void ConnectMessagePipe(uint64_t pipe_id, base::ProcessId peer_pid); |
| + |
| private: |
| -#if defined(OS_WIN) |
| ~ChildBrokerHost() override; |
| -#else |
| - ~ChildBrokerHost(); |
| -#endif |
| + // RawChannel::Delegate implementation: |
| + void OnReadMessage( |
| + const MessageInTransit::View& message_view, |
| + ScopedPlatformHandleVectorPtr platform_handles) override; |
| + void OnError(Error error) override; |
| + |
| +#if defined(OS_WIN) |
| void RegisterIOHandler(); |
| void BeginRead(); |
| -#if defined(OS_WIN) |
| + // base::MessageLoopForIO::IOHandler implementation: |
| void OnIOCompleted(base::MessageLoopForIO::IOContext* context, |
| DWORD bytes_transferred, |
| DWORD error) override; |
| @@ -53,18 +69,29 @@ class MOJO_SYSTEM_IMPL_EXPORT ChildBrokerHost |
| HANDLE DuplicateFromChild(HANDLE handle); |
| #endif |
| - base::ProcessHandle child_process_; |
| - ScopedPlatformHandle pipe_; |
| + base::ProcessId process_id_; |
| + |
| + // Channel used to receive and send multiplexing related messages. |
| + RawChannel* child_channel_; |
| #if defined(OS_WIN) |
| + // Handle to the child process, used for duplication of handles. |
| + base::ProcessHandle child_process_; |
| + |
| + // Pipe used for synchronous messages from the child. Responses are written to |
| + // it as well. |
| + ScopedPlatformHandle sync_channel_; |
| + |
| base::MessageLoopForIO::IOContext read_context_; |
| base::MessageLoopForIO::IOContext write_context_; |
| -#endif |
| std::vector<char> read_data_; |
| // How many bytes in read_data_ we already read. |
| uint32_t num_bytes_read_; |
| std::vector<char> write_data_; |
| +#endif |
| + |
| + DISALLOW_COPY_AND_ASSIGN(ChildBrokerHost); |
| }; |
| } // namespace edk |