Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(98)

Unified Diff: base/mac/scoped_mach_port.h

Issue 754433003: Update from https://crrev.com/305340 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/logging_unittest.cc ('k') | base/mac/scoped_mach_port.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « base/logging_unittest.cc ('k') | base/mac/scoped_mach_port.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698