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

Unified Diff: base/mac/scoped_typeref.h

Issue 1855483004: [iOS/OS X] Allow base::scoped_nsobject<> to be used when ARC is enabled. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Revert changes to build/config/compiler/BUILD.gn Created 4 years, 9 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
Index: base/mac/scoped_typeref.h
diff --git a/base/mac/scoped_typeref.h b/base/mac/scoped_typeref.h
index 551ddf23ec9094512edf9c6da1fca32896d9f05e..9d094dbe74e9cd9cb2e8e44dc7de8bd86eb3256b 100644
--- a/base/mac/scoped_typeref.h
+++ b/base/mac/scoped_typeref.h
@@ -54,7 +54,7 @@ class ScopedTypeRef {
typedef T element_type;
ScopedTypeRef(
- T object = Traits::InvalidValue(),
+ __unsafe_unretained T object = Traits::InvalidValue(),
base::scoped_policy::OwnershipPolicy policy = base::scoped_policy::ASSUME)
: object_(object) {
if (object_ && policy == base::scoped_policy::RETAIN)
@@ -99,9 +99,9 @@ class ScopedTypeRef {
return &object_;
}
- void reset(T object = Traits::InvalidValue(),
+ void reset(__unsafe_unretained T object = Traits::InvalidValue(),
base::scoped_policy::OwnershipPolicy policy =
- base::scoped_policy::ASSUME) {
+ base::scoped_policy::ASSUME) {
if (object && policy == base::scoped_policy::RETAIN)
object = Traits::Retain(object);
if (object_)
@@ -109,24 +109,16 @@ class ScopedTypeRef {
object_ = object;
}
- bool operator==(T that) const {
- return object_ == that;
- }
+ bool operator==(__unsafe_unretained T that) const { return object_ == that; }
- bool operator!=(T that) const {
- return object_ != that;
- }
+ bool operator!=(__unsafe_unretained T that) const { return object_ != that; }
- operator T() const {
- return object_;
- }
+ operator T() const __attribute((ns_returns_not_retained)) { return object_; }
- T get() const {
- return object_;
- }
+ T get() const __attribute((ns_returns_not_retained)) { return object_; }
void swap(ScopedTypeRef& that) {
- T temp = that.object_;
+ __unsafe_unretained T temp = that.object_;
that.object_ = object_;
object_ = temp;
}
@@ -134,14 +126,14 @@ class ScopedTypeRef {
// ScopedTypeRef<>::release() is like scoped_ptr<>::release. It is NOT
// a wrapper for Release(). To force a ScopedTypeRef<> object to call
// Release(), use ScopedTypeRef<>::reset().
- T release() WARN_UNUSED_RESULT {
- T temp = object_;
+ T release() __attribute((ns_returns_not_retained)) WARN_UNUSED_RESULT {
+ __unsafe_unretained T temp = object_;
object_ = Traits::InvalidValue();
return temp;
}
private:
- T object_;
+ __unsafe_unretained T object_;
};
} // namespace base

Powered by Google App Engine
This is Rietveld 408576698