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

Unified Diff: base/mac/scoped_launch_data.h

Issue 1551943002: Rewrite most of the scopers in //base/mac to use ScopedTypeRef or ScopedGeneric. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix iOS Created 5 years 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
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

Powered by Google App Engine
This is Rietveld 408576698