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" |
(...skipping 27 matching lines...) Expand all Loading... |
38 | 38 |
39 BASE_EXPORT 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 using ScopedMachSendRight = |
49 public base::ScopedGeneric<mach_port_t, internal::SendRightTraits> { | 49 ScopedGeneric<mach_port_t, internal::SendRightTraits>; |
50 public: | |
51 explicit ScopedMachSendRight(mach_port_t port = traits_type::InvalidValue()) | |
52 : ScopedGeneric(port) {} | |
53 | |
54 operator mach_port_t() const { return get(); } | |
55 }; | |
56 | 50 |
57 // A scoper for handling a Mach port's receive right. There is only one | 51 // A scoper for handling a Mach port's receive right. There is only one |
58 // receive right per port. This takes ownership of the receive right on | 52 // receive right per port. This takes ownership of the receive right on |
59 // construction and then destroys the right on destruction, turning all | 53 // construction and then destroys the right on destruction, turning all |
60 // outstanding send rights into dead names. | 54 // outstanding send rights into dead names. |
61 class BASE_EXPORT ScopedMachReceiveRight : | 55 using ScopedMachReceiveRight = |
62 public base::ScopedGeneric<mach_port_t, internal::ReceiveRightTraits> { | 56 ScopedGeneric<mach_port_t, internal::ReceiveRightTraits>; |
63 public: | |
64 explicit ScopedMachReceiveRight( | |
65 mach_port_t port = traits_type::InvalidValue()) : ScopedGeneric(port) {} | |
66 | |
67 operator mach_port_t() const { return get(); } | |
68 }; | |
69 | 57 |
70 // A scoper for handling a Mach port set. A port set can have only one | 58 // A scoper for handling a Mach port set. A port set can have only one |
71 // reference. This takes ownership of that single reference on construction and | 59 // reference. This takes ownership of that single reference on construction and |
72 // destroys the port set on destruction. Destroying a port set does not destroy | 60 // destroys the port set on destruction. Destroying a port set does not destroy |
73 // the receive rights that are members of the port set. | 61 // the receive rights that are members of the port set. |
74 class BASE_EXPORT ScopedMachPortSet : | 62 using ScopedMachPortSet = ScopedGeneric<mach_port_t, internal::PortSetTraits>; |
75 public ScopedGeneric<mach_port_t, internal::PortSetTraits> { | |
76 public: | |
77 explicit ScopedMachPortSet(mach_port_t port = traits_type::InvalidValue()) | |
78 : ScopedGeneric(port) {} | |
79 | |
80 operator mach_port_t() const { return get(); } | |
81 }; | |
82 | 63 |
83 } // namespace mac | 64 } // namespace mac |
84 } // namespace base | 65 } // namespace base |
85 | 66 |
86 #endif // BASE_MAC_SCOPED_MACH_PORT_H_ | 67 #endif // BASE_MAC_SCOPED_MACH_PORT_H_ |
OLD | NEW |