| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef BASE_MAC_SCOPED_MACH_PORT_H_ | 5 #ifndef BASE_MAC_SCOPED_MACH_PORT_H_ |
| 6 #define BASE_MAC_SCOPED_MACH_PORT_H_ | 6 #define BASE_MAC_SCOPED_MACH_PORT_H_ |
| 7 | 7 |
| 8 #include <mach/mach.h> | 8 #include <mach/mach.h> |
| 9 | 9 |
| 10 #include "base/base_export.h" | 10 #include "base/base_export.h" |
| 11 #include "base/scoped_generic.h" | 11 #include "base/scoped_generic.h" |
| 12 | 12 |
| 13 namespace base { | 13 namespace base { |
| 14 namespace mac { | 14 namespace mac { |
| 15 | 15 |
| 16 namespace internal { | 16 namespace internal { |
| 17 | 17 |
| 18 struct BASE_EXPORT SendRightTraits { | 18 struct BASE_EXPORT SendRightTraits { |
| 19 static mach_port_t InvalidValue() { | 19 static mach_port_t InvalidValue() { |
| 20 return MACH_PORT_NULL; | 20 return MACH_PORT_NULL; |
| 21 } | 21 } |
| 22 | 22 |
| 23 static void Free(mach_port_t port); | 23 BASE_EXPORT static void Free(mach_port_t port); |
| 24 }; | 24 }; |
| 25 | 25 |
| 26 struct BASE_EXPORT ReceiveRightTraits { | 26 struct BASE_EXPORT ReceiveRightTraits { |
| 27 static mach_port_t InvalidValue() { | 27 static mach_port_t InvalidValue() { |
| 28 return MACH_PORT_NULL; | 28 return MACH_PORT_NULL; |
| 29 } | 29 } |
| 30 | 30 |
| 31 static void Free(mach_port_t port); | 31 BASE_EXPORT static void Free(mach_port_t port); |
| 32 }; | 32 }; |
| 33 | 33 |
| 34 struct PortSetTraits { | 34 struct PortSetTraits { |
| 35 static mach_port_t InvalidValue() { | 35 static mach_port_t InvalidValue() { |
| 36 return MACH_PORT_NULL; | 36 return MACH_PORT_NULL; |
| 37 } | 37 } |
| 38 | 38 |
| 39 static void Free(mach_port_t port); | 39 BASE_EXPORT static void Free(mach_port_t port); |
| 40 }; | 40 }; |
| 41 | 41 |
| 42 } // namespace internal | 42 } // namespace internal |
| 43 | 43 |
| 44 // A scoper for handling a Mach port that names a send right. Send rights are | 44 // A scoper for handling a Mach port that names a send right. Send rights are |
| 45 // reference counted, and this takes ownership of the right on construction | 45 // reference counted, and this takes ownership of the right on construction |
| 46 // and then removes a reference to the right on destruction. If the reference | 46 // and then removes a reference to the right on destruction. If the reference |
| 47 // is the last one on the right, the right is deallocated. | 47 // is the last one on the right, the right is deallocated. |
| 48 class BASE_EXPORT ScopedMachSendRight : | 48 class BASE_EXPORT ScopedMachSendRight : |
| 49 public base::ScopedGeneric<mach_port_t, internal::SendRightTraits> { | 49 public base::ScopedGeneric<mach_port_t, internal::SendRightTraits> { |
| (...skipping 27 matching lines...) Expand all Loading... |
| 77 explicit ScopedMachPortSet(mach_port_t port = traits_type::InvalidValue()) | 77 explicit ScopedMachPortSet(mach_port_t port = traits_type::InvalidValue()) |
| 78 : ScopedGeneric(port) {} | 78 : ScopedGeneric(port) {} |
| 79 | 79 |
| 80 operator mach_port_t() const { return get(); } | 80 operator mach_port_t() const { return get(); } |
| 81 }; | 81 }; |
| 82 | 82 |
| 83 } // namespace mac | 83 } // namespace mac |
| 84 } // namespace base | 84 } // namespace base |
| 85 | 85 |
| 86 #endif // BASE_MAC_SCOPED_MACH_PORT_H_ | 86 #endif // BASE_MAC_SCOPED_MACH_PORT_H_ |
| OLD | NEW |