Chromium Code Reviews| Index: base/mac/mach_port_util.h |
| diff --git a/base/mac/mach_port_util.h b/base/mac/mach_port_util.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..c112eb3544a00a20770d5f8d8ec462191b809da0 |
| --- /dev/null |
| +++ b/base/mac/mach_port_util.h |
| @@ -0,0 +1,42 @@ |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef BASE_MAC_MACH_PORT_UTIL_H_ |
| +#define BASE_MAC_MACH_PORT_UTIL_H_ |
| + |
| +#include <mach/mach.h> |
| + |
| +#include "base/base_export.h" |
| +#include "base/mac/scoped_mach_port.h" |
| + |
| +namespace base { |
| + |
| +// Sends a Mach port to |dest_port|. Assumes that |dest_port| is a send once |
| +// right. Takes ownership of |dest_port|. |
| +BASE_EXPORT kern_return_t SendMachPort(mach_port_t dest_port, |
| + mach_port_t port_to_send, |
| + int disposition); |
| + |
| +// Receives a Mach port from |port_to_listen_on|, which should have exactly one |
| +// queued message. Returns |MACH_PORT_NULL| on any error. |
| +BASE_EXPORT base::mac::ScopedMachSendRight ReceiveMachPort( |
| + mach_port_t port_to_listen_on); |
| + |
| +// Creates an intermediate Mach port in |task_port| and sends |port_to_insert| |
| +// as a mach_msg to the intermediate Mach port. |
| +// |task_port| is the task port of another process. |
| +// |port_to_insert| must be a send right in the current task's name space. |
| +// Returns the intermediate port on success, and MACH_PORT_NULL on failure. |
| +// On failure, if |error_code| is not null, it is set to an error code as |
| +// defined in IPC::AttachmentBrokerPrivileged::UMAError. |
|
erikchen
2016/03/10 17:54:09
Use an enum here, and have IPC::AttachmentBrokerPr
Anand Mistry (off Chromium)
2016/03/11 00:29:04
Is this what you had in mind?
erikchen
2016/03/11 00:30:56
yup. still lgtm.
|
| +// This method takes ownership of |port_to_insert|. On success, ownership is |
| +// passed to the intermediate Mach port. |
| +BASE_EXPORT mach_port_name_t CreateIntermediateMachPort( |
| + mach_port_t task_port, |
| + base::mac::ScopedMachSendRight port_to_insert, |
| + uint32_t* error_code); |
| + |
| +} // namespace base |
| + |
| +#endif // BASE_MAC_MACH_PORT_UTIL_H_ |