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

Unified Diff: mojo/edk/system/mach_port_relay.cc

Issue 1890043002: [mojo-edk] Support transferring null Mach ports. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add header comments. Created 4 years, 8 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/channel_posix.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/edk/system/mach_port_relay.cc
diff --git a/mojo/edk/system/mach_port_relay.cc b/mojo/edk/system/mach_port_relay.cc
index 2dd40e51aae207c36ebd8c8fd19c4c5a6c301036..22beb652210ecbf0fb3b5f377509de288fc4ff6b 100644
--- a/mojo/edk/system/mach_port_relay.cc
+++ b/mojo/edk/system/mach_port_relay.cc
@@ -27,6 +27,11 @@ bool MachPortRelay::ReceivePorts(PlatformHandleVector* handles) {
if (handle->type != PlatformHandle::Type::MACH_NAME)
continue;
+ if (handle->port == MACH_PORT_NULL) {
+ handle->type = PlatformHandle::Type::MACH;
+ continue;
+ }
+
base::mac::ScopedMachReceiveRight message_port(handle->port);
base::mac::ScopedMachSendRight received_port(
base::ReceiveMachPort(message_port.get()));
@@ -72,8 +77,13 @@ bool MachPortRelay::SendPortsToProcess(Channel::Message* message,
if (handle->type != PlatformHandle::Type::MACH)
continue;
+ if (handle->port == MACH_PORT_NULL) {
+ handle->type = PlatformHandle::Type::MACH_NAME;
+ num_sent++;
+ continue;
+ }
+
mach_port_name_t intermediate_port;
- DCHECK(handle->port != MACH_PORT_NULL);
intermediate_port = base::CreateIntermediateMachPort(
task_port, base::mac::ScopedMachSendRight(handle->port), nullptr);
if (intermediate_port == MACH_PORT_NULL) {
@@ -111,6 +121,12 @@ bool MachPortRelay::ExtractPortRights(Channel::Message* message,
if (handle->type != PlatformHandle::Type::MACH_NAME)
continue;
+ if (handle->port == MACH_PORT_NULL) {
+ handle->type = PlatformHandle::Type::MACH;
+ num_received++;
+ continue;
+ }
+
mach_port_t extracted_right = MACH_PORT_NULL;
mach_msg_type_name_t extracted_right_type;
kern_return_t kr =
« no previous file with comments | « mojo/edk/system/channel_posix.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698