Index: base/memory/scoped_nsobject.h |
diff --git a/base/memory/scoped_nsobject.h b/base/memory/scoped_nsobject.h |
index 5d98e3f19796a9c7bbbd483a67f4b137a71f98c6..a5b6dbf86560672218c1f1ab8b6a217ed4f75909 100644 |
--- a/base/memory/scoped_nsobject.h |
+++ b/base/memory/scoped_nsobject.h |
@@ -8,21 +8,17 @@ |
#import <Foundation/Foundation.h> |
#include "base/basictypes.h" |
#include "base/compiler_specific.h" |
-#include "base/memory/scoped_policy.h" |
// scoped_nsobject<> is patterned after scoped_ptr<>, but maintains ownership |
// of an NSObject subclass object. Style deviations here are solely for |
// compatibility with scoped_ptr<>'s interface, with which everyone is already |
// familiar. |
// |
-// By default, scoped_nsobject<> takes ownership of an object (in the |
-// constructor or in reset()) by taking over the caller's existing ownership |
-// claim. The caller must own the object it gives to scoped_nsobject<>, and |
-// relinquishes an ownership claim to that object. scoped_nsobject<> does not |
-// call -retain. This behavior is parametrized by the |OwnershipPolicy| enum. |
-// If the value |RETAIN| is passed (in the constructor or in reset()), then |
-// scoped_nsobject<> will call -retain on the object, and the initial |
-// ownership is not changed. |
+// scoped_nsobject<> takes ownership of an object (in the constructor or in |
+// reset()) by taking over the caller's existing ownership claim. The caller |
+// must own the object it gives to scoped_nsobject<>, and relinquishes an |
+// ownership claim to that object. scoped_nsobject<> does not call -retain, |
+// callers have to call this manually if appropriate. |
// |
// scoped_nsprotocol<> has the same behavior as scoped_nsobject, but can be used |
// with protocols. |
@@ -36,13 +32,7 @@ |
template<typename NST> |
class scoped_nsprotocol { |
public: |
- explicit scoped_nsprotocol( |
- NST object = nil, |
- base::scoped_policy::OwnershipPolicy policy = base::scoped_policy::ASSUME) |
- : object_(object) { |
- if (policy == base::scoped_policy::RETAIN) |
- [object retain]; |
- } |
+ explicit scoped_nsprotocol(NST object = nil) : object_(object) {} |
scoped_nsprotocol(const scoped_nsprotocol<NST>& that) |
: object_([that.object_ retain]) { |
@@ -53,15 +43,11 @@ class scoped_nsprotocol { |
} |
scoped_nsprotocol& operator=(const scoped_nsprotocol<NST>& that) { |
- reset(that.get(), base::scoped_policy::RETAIN); |
+ reset([that.get() retain]); |
return *this; |
} |
- void reset(NST object = nil, |
- base::scoped_policy::OwnershipPolicy policy = |
- base::scoped_policy::ASSUME) { |
- if (policy == base::scoped_policy::RETAIN) |
- [object retain]; |
+ void reset(NST object = nil) { |
// We intentionally do not check that object != object_ as the caller must |
// either already have an ownership claim over whatever it passes to this |
// method, or call it with the |RETAIN| policy which will have ensured that |
@@ -124,11 +110,8 @@ bool operator!=(C p1, const scoped_nsprotocol<C>& p2) { |
template<typename NST> |
class scoped_nsobject : public scoped_nsprotocol<NST*> { |
public: |
- explicit scoped_nsobject( |
- NST* object = nil, |
- base::scoped_policy::OwnershipPolicy policy = base::scoped_policy::ASSUME) |
- : scoped_nsprotocol<NST*>(object, policy) { |
- } |
+ explicit scoped_nsobject(NST* object = nil) |
+ : scoped_nsprotocol<NST*>(object) {} |
scoped_nsobject(const scoped_nsobject<NST>& that) |
: scoped_nsprotocol<NST*>(that) { |
@@ -144,11 +127,7 @@ class scoped_nsobject : public scoped_nsprotocol<NST*> { |
template<> |
class scoped_nsobject<id> : public scoped_nsprotocol<id> { |
public: |
- explicit scoped_nsobject( |
- id object = nil, |
- base::scoped_policy::OwnershipPolicy policy = base::scoped_policy::ASSUME) |
- : scoped_nsprotocol<id>(object, policy) { |
- } |
+ explicit scoped_nsobject(id object = nil) : scoped_nsprotocol<id>(object) {} |
scoped_nsobject(const scoped_nsobject<id>& that) |
: scoped_nsprotocol<id>(that) { |
@@ -166,9 +145,7 @@ class scoped_nsobject<id> : public scoped_nsprotocol<id> { |
template<> |
class scoped_nsobject<NSAutoreleasePool> { |
private: |
- explicit scoped_nsobject(NSAutoreleasePool* object = nil, |
- base::scoped_policy::OwnershipPolicy policy = |
- base::scoped_policy::ASSUME); |
+ explicit scoped_nsobject(NSAutoreleasePool* object = nil); |
DISALLOW_COPY_AND_ASSIGN(scoped_nsobject); |
}; |
#endif // BASE_MEMORY_SCOPED_NSOBJECT_H_ |