Chromium Code Reviews| Index: base/mac/scoped_launch_data.h |
| diff --git a/base/mac/scoped_launch_data.h b/base/mac/scoped_launch_data.h |
| index c2bb31efbe6982d36987006784a766acd718dd7f..da62006bfb25367767cdd95737d3d4aed274e8a4 100644 |
| --- a/base/mac/scoped_launch_data.h |
| +++ b/base/mac/scoped_launch_data.h |
| @@ -7,67 +7,23 @@ |
| #include <launch.h> |
| -#include <algorithm> |
| - |
| -#include "base/compiler_specific.h" |
| -#include "base/macros.h" |
| +#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; |
| - |
| - explicit ScopedLaunchData(launch_data_t object = NULL) |
| - : object_(object) { |
| - } |
| - |
| - ~ScopedLaunchData() { |
| - if (object_) |
| - launch_data_free(object_); |
| - } |
| - |
| - void reset(launch_data_t object = NULL) { |
| - if (object != object_) { |
| - if (object_) |
| - launch_data_free(object_); |
| - object_ = object; |
| - } |
| - } |
| - |
| - bool operator==(launch_data_t that) const { |
| - return object_ == that; |
| - } |
| - |
| - bool operator!=(launch_data_t that) const { |
| - return object_ != that; |
| - } |
| +namespace internal { |
| - 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; |
| - } |
| +struct ScopedLaunchDataTraits { |
| + static launch_data_t InvalidValue() { return nullptr; } |
| + static void Free(launch_data_t ldt) { launch_data_free(ldt); } |
|
Mark Mentovai
2016/01/06 16:22:58
I had to ignore -Wdeprecated-declarations to use l
|
| +}; |
| - private: |
| - launch_data_t object_; |
| +} // namespace internal |
| - DISALLOW_COPY_AND_ASSIGN(ScopedLaunchData); |
| -}; |
| +// Just like scoped_ptr<> but for launch_data_t. |
| +using ScopedLaunchData = |
| + ScopedGeneric<launch_data_t, internal::ScopedLaunchDataTraits>; |
| } // namespace mac |
| } // namespace base |