Index: base/weak_ptr.h |
diff --git a/base/weak_ptr.h b/base/weak_ptr.h |
index 1bc963e7ef65e19514191e727646c59fd945bcad..85a26d162c80003a7bc6bd588eafe05bd9fb588d 100644 |
--- a/base/weak_ptr.h |
+++ b/base/weak_ptr.h |
@@ -65,24 +65,11 @@ class WeakReference { |
public: |
class Flag : public RefCounted<Flag>, public NonThreadSafe { |
public: |
- Flag(Flag** handle) : handle_(handle) { |
- } |
- |
- ~Flag() { |
- if (handle_) |
- *handle_ = NULL; |
- } |
- |
- void AddRef() { |
- DCHECK(CalledOnValidThread()); |
- RefCounted<Flag>::AddRef(); |
- } |
- |
- void Release() { |
- DCHECK(CalledOnValidThread()); |
- RefCounted<Flag>::Release(); |
- } |
+ Flag(Flag** handle); |
+ ~Flag(); |
+ void AddRef(); |
+ void Release(); |
void Invalidate() { handle_ = NULL; } |
bool is_valid() const { return handle_ != NULL; } |
@@ -90,10 +77,10 @@ class WeakReference { |
Flag** handle_; |
}; |
- WeakReference() {} |
- WeakReference(Flag* flag) : flag_(flag) {} |
+ WeakReference(); |
+ WeakReference(Flag* flag); |
- bool is_valid() const { return flag_ && flag_->is_valid(); } |
+ bool is_valid() const; |
private: |
scoped_refptr<Flag> flag_; |
@@ -101,29 +88,16 @@ class WeakReference { |
class WeakReferenceOwner { |
public: |
- WeakReferenceOwner() : flag_(NULL) { |
- } |
- |
- ~WeakReferenceOwner() { |
- Invalidate(); |
- } |
+ WeakReferenceOwner(); |
+ ~WeakReferenceOwner(); |
- WeakReference GetRef() const { |
- if (!flag_) |
- flag_ = new WeakReference::Flag(&flag_); |
- return WeakReference(flag_); |
- } |
+ WeakReference GetRef() const; |
bool HasRefs() const { |
return flag_ != NULL; |
} |
- void Invalidate() { |
- if (flag_) { |
- flag_->Invalidate(); |
- flag_ = NULL; |
- } |
- } |
+ void Invalidate(); |
private: |
mutable WeakReference::Flag* flag_; |
@@ -135,12 +109,10 @@ class WeakReferenceOwner { |
// base class gives us a way to access ref_ in a protected fashion. |
class WeakPtrBase { |
public: |
- WeakPtrBase() { |
- } |
+ WeakPtrBase(); |
protected: |
- WeakPtrBase(const WeakReference& ref) : ref_(ref) { |
- } |
+ WeakPtrBase(const WeakReference& ref); |
WeakReference ref_; |
}; |