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

Unified Diff: mojo/edk/system/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: More stuff. 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
Index: mojo/edk/system/channel.h
diff --git a/mojo/edk/system/channel.h b/mojo/edk/system/channel.h
index 0d7ccdb613f591a8659dad663f3741a628e0a549..e6ca4b961d5ee6d86f934eab88946d8819da1012 100644
--- a/mojo/edk/system/channel.h
+++ b/mojo/edk/system/channel.h
@@ -66,6 +66,17 @@ class Channel : public base::RefCountedThreadSafe<Channel> {
char padding[6];
#endif // defined(OS_CHROMEOS)
};
+
+#if defined(OS_MACOSX)
+ struct MachPortsEntry {
+ uint16_t index;
+ uint32_t mach_port;
+ static_assert(sizeof(mach_port_t) <= sizeof(uint32_t),
+ "mach_port_t must be smaller than uint32_t");
Ken Rockot(use gerrit already) 2016/03/09 08:34:31 nit: must be no larger than uint32_t
Anand Mistry (off Chromium) 2016/03/11 07:44:18 Done.
+ };
+ static_assert(sizeof(MachPortsEntry) == 6,
+ "sizeof(MachPortsEntry) must be 6 bytes");
+#endif
#pragma pack(pop)
// Allocates and owns a buffer for message data with enough capacity for
@@ -111,6 +122,11 @@ class Channel : public base::RefCountedThreadSafe<Channel> {
// handles().
void SetHandles(ScopedPlatformHandleVectorPtr new_handles);
ScopedPlatformHandleVectorPtr TakeHandles();
+ // Version of TakeHandles that returns a vector of platform handles suitable
+ // for transfer over an underlying OS mechanism. i.e. file descriptors over
+ // a unix domain socket. Any handle that cannot be transferred this way,
+ // such as Mach port, will be removed.
+ ScopedPlatformHandleVectorPtr TakeHandlesForTransport();
#if defined(OS_WIN)
// Prepares the handles in this message for use in a different process.
@@ -138,6 +154,12 @@ class Channel : public base::RefCountedThreadSafe<Channel> {
ScopedPlatformHandleVectorPtr handle_vector_;
#endif
+#if defined(OS_MACOSX)
+ // On OSX, handles which are mach ports are serialised into the data buffer
+ // after the rest of the payload.
+ MachPortsEntry* mach_ports_ = nullptr;
Ken Rockot(use gerrit already) 2016/03/09 08:34:31 nit: this comment appears to be out of date since
Anand Mistry (off Chromium) 2016/03/11 07:44:17 Done, and updated the windows comment.
+#endif
+
DISALLOW_COPY_AND_ASSIGN(Message);
};

Powered by Google App Engine
This is Rietveld 408576698