Index: base/mac/scoped_mach_port.h |
diff --git a/base/mac/scoped_mach_port.h b/base/mac/scoped_mach_port.h |
index 36087c9bdecfdf5651f8a06a9d2bc08faec4d5f6..9ef90d66bf8a2c1947c68a26ff64e18675a2df37 100644 |
--- a/base/mac/scoped_mach_port.h |
+++ b/base/mac/scoped_mach_port.h |
@@ -31,6 +31,14 @@ struct BASE_EXPORT ReceiveRightTraits { |
static void Free(mach_port_t port); |
}; |
+struct PortSetTraits { |
+ static mach_port_t InvalidValue() { |
+ return MACH_PORT_NULL; |
+ } |
+ |
+ static void Free(mach_port_t port); |
+}; |
+ |
} // namespace internal |
// A scoper for handling a Mach port that names a send right. Send rights are |
@@ -59,6 +67,19 @@ class BASE_EXPORT ScopedMachReceiveRight : |
operator mach_port_t() const { return get(); } |
}; |
+// A scoper for handling a Mach port set. A port set can have only one |
+// reference. This takes ownership of that single reference on construction and |
+// destroys the port set on destruction. Destroying a port set does not destroy |
+// the receive rights that are members of the port set. |
+class BASE_EXPORT ScopedMachPortSet : |
+ public ScopedGeneric<mach_port_t, internal::PortSetTraits> { |
+ public: |
+ explicit ScopedMachPortSet(mach_port_t port = traits_type::InvalidValue()) |
+ : ScopedGeneric(port) {} |
+ |
+ operator mach_port_t() const { return get(); } |
+}; |
+ |
} // namespace mac |
} // namespace base |