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

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

Issue 1712143002: [mojo-edk] Add support for transferring mach ports. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix build Created 4 years, 9 months 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/mach_port_relay.cc ('k') | mojo/edk/system/node_channel.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/edk/system/node_channel.h
diff --git a/mojo/edk/system/node_channel.h b/mojo/edk/system/node_channel.h
index 7dc1050062129f116bcf86540ed73df0eedfc9cd..c8a97caf5e3b5076dbfae74698b16257a975e0c9 100644
--- a/mojo/edk/system/node_channel.h
+++ b/mojo/edk/system/node_channel.h
@@ -5,7 +5,9 @@
#ifndef MOJO_EDK_SYSTEM_NODE_CHANNEL_H_
#define MOJO_EDK_SYSTEM_NODE_CHANNEL_H_
+#include <queue>
#include <unordered_map>
+#include <utility>
#include "base/macros.h"
#include "base/memory/ref_counted.h"
@@ -18,12 +20,20 @@
#include "mojo/edk/system/channel.h"
#include "mojo/edk/system/ports/name.h"
+#if defined(OS_MACOSX) && !defined(OS_IOS)
+#include "mojo/edk/system/mach_port_relay.h"
+#endif
+
namespace mojo {
namespace edk {
// Wraps a Channel to send and receive Node control messages.
class NodeChannel : public base::RefCountedThreadSafe<NodeChannel>,
- public Channel::Delegate {
+ public Channel::Delegate
+#if defined(OS_MACOSX) && !defined(OS_IOS)
+ , public MachPortRelay::Observer
+#endif
+ {
public:
class Delegate {
public:
@@ -52,7 +62,7 @@ class NodeChannel : public base::RefCountedThreadSafe<NodeChannel>,
virtual void OnIntroduce(const ports::NodeName& from_node,
const ports::NodeName& name,
ScopedPlatformHandle channel_handle) = 0;
-#if defined(OS_WIN)
+#if defined(OS_WIN) || (defined(OS_MACOSX) && !defined(OS_IOS))
virtual void OnRelayPortsMessage(const ports::NodeName& from_node,
base::ProcessHandle from_process,
const ports::NodeName& destination,
@@ -60,6 +70,10 @@ class NodeChannel : public base::RefCountedThreadSafe<NodeChannel>,
#endif
virtual void OnChannelError(const ports::NodeName& node) = 0;
+
+#if defined(OS_MACOSX) && !defined(OS_IOS)
+ virtual MachPortRelay* GetMachPortRelay() = 0;
+#endif
};
static scoped_refptr<NodeChannel> Create(
@@ -106,7 +120,7 @@ class NodeChannel : public base::RefCountedThreadSafe<NodeChannel>,
void Introduce(const ports::NodeName& name,
ScopedPlatformHandle channel_handle);
-#if defined(OS_WIN)
+#if defined(OS_WIN) || (defined(OS_MACOSX) && !defined(OS_IOS))
// Relay the message to the specified node via this channel. This is used to
// pass windows handles between two processes that do not have permission to
// duplicate handles into the other's address space. The relay process is
@@ -118,6 +132,10 @@ class NodeChannel : public base::RefCountedThreadSafe<NodeChannel>,
private:
friend class base::RefCountedThreadSafe<NodeChannel>;
+ using PendingMessageQueue = std::queue<Channel::MessagePtr>;
+ using PendingRelayMessageQueue =
+ std::queue<std::pair<ports::NodeName, Channel::MessagePtr>>;
+
NodeChannel(Delegate* delegate,
ScopedPlatformHandle platform_handle,
scoped_refptr<base::TaskRunner> io_task_runner);
@@ -129,6 +147,13 @@ class NodeChannel : public base::RefCountedThreadSafe<NodeChannel>,
ScopedPlatformHandleVectorPtr handles) override;
void OnChannelError() override;
+#if defined(OS_MACOSX) && !defined(OS_IOS)
+ // MachPortRelay::Observer:
+ void OnProcessReady(base::ProcessHandle process) override;
+
+ void ProcessPendingMessagesWithMachPorts();
+#endif
+
void WriteChannelMessage(Channel::MessagePtr message);
Delegate* const delegate_;
@@ -143,6 +168,12 @@ class NodeChannel : public base::RefCountedThreadSafe<NodeChannel>,
base::Lock remote_process_handle_lock_;
base::ProcessHandle remote_process_handle_ = base::kNullProcessHandle;
+#if defined(OS_MACOSX) && !defined(OS_IOS)
+ base::Lock pending_mach_messages_lock_;
+ PendingMessageQueue pending_write_messages_;
+ PendingRelayMessageQueue pending_relay_messages_;
+#endif
+
DISALLOW_COPY_AND_ASSIGN(NodeChannel);
};
« no previous file with comments | « mojo/edk/system/mach_port_relay.cc ('k') | mojo/edk/system/node_channel.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698