Index: base/mac/scoped_launch_data.h |
diff --git a/base/mac/scoped_launch_data.h b/base/mac/scoped_launch_data.h |
index 7629310bda4f9749ca2fbc554ee1d98f8a2c4194..8f8e759fc223827e7850cedbc564ef6cfe0b5e56 100644 |
--- a/base/mac/scoped_launch_data.h |
+++ b/base/mac/scoped_launch_data.h |
@@ -7,78 +7,28 @@ |
#include <launch.h> |
-#include <algorithm> |
- |
-#include "base/compiler_specific.h" |
-#include "base/macros.h" |
- |
-namespace { |
- |
-inline void LaunchDataFree(launch_data_t data) { |
-#pragma clang diagnostic push |
-#pragma clang diagnostic ignored "-Wdeprecated-declarations" |
- return launch_data_free(data); |
-#pragma clang diagnostic pop |
-} |
- |
-} // namespace |
+#include "base/scoped_generic.h" |
namespace base { |
namespace mac { |
-// Just like scoped_ptr<> but for launch_data_t. |
-class ScopedLaunchData { |
- public: |
- typedef launch_data_t element_type; |
+namespace internal { |
- explicit ScopedLaunchData(launch_data_t object = NULL) |
- : object_(object) { |
- } |
- |
- ~ScopedLaunchData() { |
- if (object_) |
- LaunchDataFree(object_); |
- } |
- |
- void reset(launch_data_t object = NULL) { |
- if (object != object_) { |
- if (object_) |
- LaunchDataFree(object_); |
- object_ = object; |
- } |
- } |
- |
- bool operator==(launch_data_t that) const { |
- return object_ == that; |
- } |
+struct ScopedLaunchDataTraits { |
+ static launch_data_t InvalidValue() { return nullptr; } |
- bool operator!=(launch_data_t that) const { |
- return object_ != that; |
- } |
- |
- operator launch_data_t() const { |
- return object_; |
- } |
- |
- launch_data_t get() const { |
- return object_; |
- } |
- |
- void swap(ScopedLaunchData& that) { |
- std::swap(object_, that.object_); |
- } |
- |
- launch_data_t release() WARN_UNUSED_RESULT { |
- launch_data_t temp = object_; |
- object_ = NULL; |
- return temp; |
+ static void Free(launch_data_t ldt) { |
+#pragma clang diagnostic push |
+#pragma clang diagnostic ignored "-Wdeprecated-declarations" |
+ launch_data_free(ldt); |
+#pragma clang diagnostic pop |
} |
+}; |
- private: |
- launch_data_t object_; |
+} // namespace internal |
- DISALLOW_COPY_AND_ASSIGN(ScopedLaunchData); |
-}; |
+using ScopedLaunchData = |
+ ScopedGeneric<launch_data_t, internal::ScopedLaunchDataTraits>; |
} // namespace mac |
} // namespace base |