1 // Copyright 2015 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef IPC_MACH_PORT_ATTACHMENT_MAC_H_
6 #define IPC_MACH_PORT_ATTACHMENT_MAC_H_
11 #include "base/process/process_handle.h"
12 #include "ipc/ipc_message_attachment.h"
13 #include "ipc/ipc_message_support_export.h"
14 #include "ipc/mach_port_mac.h"
19 // This class represents an OSX mach_port_t attached to a Chrome IPC message.
20 class IPC_MESSAGE_SUPPORT_EXPORT MachPortAttachmentMac
21 : public MessageAttachment {
23 // This constructor increments the ref count of |mach_port_| and takes
24 // ownership of the result. Should only be called by the sender of a Chrome
26 explicit MachPortAttachmentMac(mach_port_t mach_port);
28 MachPortAttachmentMac(const MachPortAttachmentMac&) = delete;
29 MachPortAttachmentMac& operator=(const MachPortAttachmentMac&) = delete;
34 // This constructor takes ownership of |mach_port|, but does not modify its
35 // ref count. Should only be called by the receiver of a Chrome IPC message.
36 MachPortAttachmentMac(mach_port_t mach_port, FromWire from_wire);
38 Type GetType() const override;
40 mach_port_t get_mach_port() const { return mach_port_; }
42 // The caller of this method has taken ownership of |mach_port_|.
43 void reset_mach_port_ownership() { owns_mach_port_ = false; }
46 ~MachPortAttachmentMac() override;
47 const mach_port_t mach_port_;
49 // In the sender process, the attachment owns the Mach port of a newly created
50 // message. The attachment broker will eventually take ownership of
52 // In the destination process, the attachment owns |mach_port_| until
53 // ParamTraits<MachPortMac>::Read() is called, which takes ownership.
57 } // namespace internal
60 #endif // IPC_MACH_PORT_ATTACHMENT_MAC_H_