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

Unified Diff: base/mac/scoped_ioobject.h

Issue 1565803002: Sync Mac scopers with upstream Chromium (Closed) Base URL: https://chromium.googlesource.com/chromium/mini_chromium@master
Patch Set: Created 4 years, 11 months 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/mac/scoped_cftyperef.h ('k') | base/mac/scoped_launch_data.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/mac/scoped_ioobject.h
diff --git a/base/mac/scoped_ioobject.h b/base/mac/scoped_ioobject.h
index 570c0050c05dedcbbc3ef9e99577e2947244244b..e653110a96f61eed9d08ab5d8974287d14bb1e88 100644
--- a/base/mac/scoped_ioobject.h
+++ b/base/mac/scoped_ioobject.h
@@ -7,66 +7,27 @@
#include <IOKit/IOKitLib.h>
-#include "base/compiler_specific.h"
-#include "base/macros.h"
+#include "base/mac/scoped_typeref.h"
namespace base {
namespace mac {
-// Just like ScopedCFTypeRef but for io_object_t and subclasses.
-template<typename IOT>
-class ScopedIOObject {
- public:
- typedef IOT element_type;
+namespace internal {
- explicit ScopedIOObject(IOT object = IO_OBJECT_NULL)
- : object_(object) {
- }
-
- ~ScopedIOObject() {
- if (object_)
- IOObjectRelease(object_);
- }
-
- void reset(IOT object = IO_OBJECT_NULL) {
- if (object_)
- IOObjectRelease(object_);
- object_ = object;
- }
-
- bool operator==(IOT that) const {
- return object_ == that;
- }
-
- bool operator!=(IOT that) const {
- return object_ != that;
- }
-
- operator IOT() const {
- return object_;
- }
-
- IOT get() const {
- return object_;
- }
-
- void swap(ScopedIOObject& that) {
- IOT temp = that.object_;
- that.object_ = object_;
- object_ = temp;
- }
-
- IOT release() WARN_UNUSED_RESULT {
- IOT temp = object_;
- object_ = IO_OBJECT_NULL;
- return temp;
+template <typename IOT>
+struct ScopedIOObjectTraits {
+ static IOT InvalidValue() { return IO_OBJECT_NULL; }
+ static IOT Retain(IOT iot) {
+ IOObjectRetain(iot);
+ return iot;
}
+ static void Release(IOT iot) { IOObjectRelease(iot); }
+};
- private:
- IOT object_;
+} // namespce internal
- DISALLOW_COPY_AND_ASSIGN(ScopedIOObject);
-};
+template <typename IOT>
+using ScopedIOObject = ScopedTypeRef<IOT, internal::ScopedIOObjectTraits<IOT>>;
} // namespace mac
} // namespace base
« no previous file with comments | « base/mac/scoped_cftyperef.h ('k') | base/mac/scoped_launch_data.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698