[go: nahoru, domu]

blob: 0fb9c6273ff1f2b73d00c27799e8d941aa6462bc [file] [log] [blame]
Avi Drissmanea1be232022-09-14 23:29:061// Copyright 2015 The Chromium Authors
erikchen1c1e6652015-10-01 18:51:322// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#include "ipc/mach_port_attachment_mac.h"
6
avi246998d2015-12-22 02:39:047#include <stdint.h>
8
Avi Drissman0b200712023-08-16 20:35:499#include "base/apple/mach_logging.h"
erikchen3722a322015-10-07 20:51:5510
erikchen1c1e6652015-10-01 18:51:3211namespace IPC {
12namespace internal {
13
14MachPortAttachmentMac::MachPortAttachmentMac(mach_port_t mach_port)
erikchen3722a322015-10-07 20:51:5515 : mach_port_(mach_port), owns_mach_port_(true) {
16 if (mach_port != MACH_PORT_NULL) {
17 kern_return_t kr = mach_port_mod_refs(mach_task_self(), mach_port,
18 MACH_PORT_RIGHT_SEND, 1);
19 MACH_LOG_IF(ERROR, kr != KERN_SUCCESS, kr)
20 << "MachPortAttachmentMac mach_port_mod_refs";
21 }
22}
sammc57ed9f982016-03-10 06:28:3523MachPortAttachmentMac::MachPortAttachmentMac(mach_port_t mach_port,
24 FromWire from_wire)
25 : mach_port_(mach_port), owns_mach_port_(true) {}
erikchen1c1e6652015-10-01 18:51:3226
erikchen3722a322015-10-07 20:51:5527MachPortAttachmentMac::~MachPortAttachmentMac() {
28 if (mach_port_ != MACH_PORT_NULL && owns_mach_port_) {
29 kern_return_t kr = mach_port_mod_refs(mach_task_self(), mach_port_,
30 MACH_PORT_RIGHT_SEND, -1);
31 MACH_LOG_IF(ERROR, kr != KERN_SUCCESS, kr)
32 << "~MachPortAttachmentMac mach_port_mod_refs";
33 }
34}
erikchen1c1e6652015-10-01 18:51:3235
sammc6ed3efb2016-11-23 03:17:3536MessageAttachment::Type MachPortAttachmentMac::GetType() const {
37 return Type::MACH_PORT;
erikchen1c1e6652015-10-01 18:51:3238}
39
40} // namespace internal
41} // namespace IPC