diff options
Diffstat (limited to 'chromium/base/mac/scoped_mach_port.cc')
-rw-r--r-- | chromium/base/mac/scoped_mach_port.cc | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/chromium/base/mac/scoped_mach_port.cc b/chromium/base/mac/scoped_mach_port.cc index 9e45a856a8c..de94602e36e 100644 --- a/chromium/base/mac/scoped_mach_port.cc +++ b/chromium/base/mac/scoped_mach_port.cc @@ -4,22 +4,27 @@ #include "base/mac/scoped_mach_port.h" +#include "base/mac/mach_logging.h" + namespace base { namespace mac { +namespace internal { -ScopedMachPort::ScopedMachPort(mach_port_t port) : port_(port) { -} - -ScopedMachPort::~ScopedMachPort() { - reset(); +// static +void SendRightTraits::Free(mach_port_t port) { + kern_return_t kr = mach_port_deallocate(mach_task_self(), port); + MACH_LOG_IF(ERROR, kr != KERN_SUCCESS, kr) + << "ScopedMachSendRight mach_port_deallocate"; } -void ScopedMachPort::reset(mach_port_t port) { - if (port_ != MACH_PORT_NULL) { - mach_port_deallocate(mach_task_self(), port_); - } - port_ = port; +// static +void ReceiveRightTraits::Free(mach_port_t port) { + kern_return_t kr = + mach_port_mod_refs(mach_task_self(), port, MACH_PORT_RIGHT_RECEIVE, -1); + MACH_LOG_IF(ERROR, kr != KERN_SUCCESS, kr) + << "ScopedMachReceiveRight mach_port_mod_refs"; } +} // namespace internal } // namespace mac } // namespace base |