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

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: 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/BUILD.gn ('k') | mojo/edk/system/channel.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/edk/system/channel.h
diff --git a/mojo/edk/system/channel.h b/mojo/edk/system/channel.h
index 54b64121ef9a0c486a4e090eca26559655dd07d5..9932c9c71fc0d1695dab89bc6d40491adb70a0a4 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) || defined(OS_ANDROID)
};
+
+#if defined(OS_MACOSX) && !defined(OS_IOS)
+ struct MachPortsEntry {
+ uint16_t index;
+ uint32_t mach_port;
+ static_assert(sizeof(mach_port_t) <= sizeof(uint32_t),
+ "mach_port_t must be no larger than uint32_t");
+ };
+ 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 ports, will be removed.
+ ScopedPlatformHandleVectorPtr TakeHandlesForTransport();
#if defined(OS_WIN)
// Prepares the handles in this message for use in a different process.
@@ -131,13 +147,17 @@ class Channel : public base::RefCountedThreadSafe<Channel> {
Header* header_;
#if defined(OS_WIN)
- // On Windows, handles are serialized in the data buffer along with the
- // rest of the payload.
+ // On Windows, handles are serialised into the extra header section.
PlatformHandle* handles_ = nullptr;
#else
ScopedPlatformHandleVectorPtr handle_vector_;
#endif
+#if defined(OS_MACOSX) && !defined(OS_IOS)
+ // On OSX, handles are serialised into the extra header section.
+ MachPortsEntry* mach_ports_ = nullptr;
+#endif
+
DISALLOW_COPY_AND_ASSIGN(Message);
};
« no previous file with comments | « mojo/edk/system/BUILD.gn ('k') | mojo/edk/system/channel.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698