tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

mach_ipc_mac.h (2685B)


      1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
      2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
      3 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
      4 // Use of this source code is governed by a BSD-style license that can be
      5 // found in the LICENSE file.
      6 
      7 #ifndef BASE_MACH_IPC_MAC_H_
      8 #define BASE_MACH_IPC_MAC_H_
      9 
     10 #include <mach/mach.h>
     11 #include <mach/message.h>
     12 #include <sys/types.h>
     13 
     14 #include "mozilla/Maybe.h"
     15 #include "mozilla/MozPromise.h"
     16 #include "mozilla/UniquePtrExtensions.h"
     17 #include "mozilla/ipc/LaunchError.h"
     18 
     19 //==============================================================================
     20 // Helper function for sending a minimal mach IPC messages with a single send
     21 // right attached. The endpoint will not be consumed unless the
     22 // `endpoint_disposition` argument is set to a consuming disposition, and
     23 // `KERN_SUCCESS` is returned.
     24 kern_return_t MachSendPortSendRight(
     25    mach_port_t endpoint, mach_port_t attachment,
     26    mozilla::Maybe<mach_msg_timeout_t> opt_timeout,
     27    mach_msg_type_name_t endpoint_disposition = MACH_MSG_TYPE_COPY_SEND);
     28 
     29 //==============================================================================
     30 // Helper function for receiving a minimal mach IPC message with a single send
     31 // right attached.
     32 // If the `audit_token` parameter is provided, it will be populated with the
     33 // sender's audit token, which can be used to verify the identity of the sender.
     34 kern_return_t MachReceivePortSendRight(
     35    const mozilla::UniqueMachReceiveRight& endpoint,
     36    mozilla::Maybe<mach_msg_timeout_t> opt_timeout,
     37    mozilla::UniqueMachSendRight* attachment,
     38    audit_token_t* audit_token = nullptr);
     39 
     40 #ifdef XP_MACOSX
     41 //==============================================================================
     42 // Called by XRE_InitChildProcess to check-in with the parent process, sending
     43 // the child process task port to the parent, and receiving any ports sent by
     44 // the parent process.
     45 bool MachChildProcessCheckIn(
     46    const char* bootstrap_service_name, mach_msg_timeout_t timeout,
     47    std::vector<mozilla::UniqueMachSendRight>& send_rights);
     48 
     49 //==============================================================================
     50 // Called by MacProcessLauncher to transfer ports to the child process, and
     51 // acquire the child process task port.
     52 using MachHandleProcessCheckInPromise =
     53    mozilla::MozPromise<task_t, mozilla::ipc::LaunchError, true>;
     54 RefPtr<MachHandleProcessCheckInPromise> MachHandleProcessCheckIn(
     55    mozilla::UniqueMachReceiveRight endpoint, pid_t child_pid,
     56    mozilla::TimeDuration timeout,
     57    std::vector<mozilla::UniqueMachSendRight> send_rights);
     58 #endif
     59 
     60 #endif  // BASE_MACH_IPC_MAC_H_