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

Unified Diff: mojo/edk/system/child_broker_host.h

Issue 1488853002: Add multiplexing of message pipes in the new EDK. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: tsepez review comments Created 5 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « mojo/edk/system/child_broker.cc ('k') | mojo/edk/system/child_broker_host.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..a91218ab8bfdcc9708c5c37a8d4225f8a94f5f61 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|.
+ void ConnectMessagePipe(uint64_t pipe_id, base::ProcessId process_id);
+
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
« no previous file with comments | « mojo/edk/system/child_broker.cc ('k') | mojo/edk/system/child_broker_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698