diff options
Diffstat (limited to 'base/memory/weak_ptr.h')
-rw-r--r-- | base/memory/weak_ptr.h | 23 |
1 files changed, 7 insertions, 16 deletions
diff --git a/base/memory/weak_ptr.h b/base/memory/weak_ptr.h index 0c6b4a7..edb9d93 100644 --- a/base/memory/weak_ptr.h +++ b/base/memory/weak_ptr.h @@ -55,7 +55,7 @@ #include "base/base_api.h" #include "base/logging.h" #include "base/memory/ref_counted.h" -#include "base/threading/thread_checker.h" +#include "base/threading/non_thread_safe.h" namespace base { @@ -65,23 +65,19 @@ namespace internal { class BASE_API WeakReference { public: - // While Flag is bound to a specific thread, it may be deleted from another - // via base::WeakPtr::~WeakPtr(). - class Flag : public RefCountedThreadSafe<Flag> { + class Flag : public RefCounted<Flag>, public base::NonThreadSafe { public: - explicit Flag(Flag** handle); + Flag(Flag** handle); + ~Flag(); + void AddRef() const; + void Release() const; void Invalidate(); bool IsValid() const; - void DetachFromThread() { thread_checker_.DetachFromThread(); } + void DetachFromThread() { base::NonThreadSafe::DetachFromThread(); } private: - friend class base::RefCountedThreadSafe<Flag>; - - ~Flag(); - - ThreadChecker thread_checker_; Flag** handle_; }; @@ -239,11 +235,6 @@ class WeakPtrFactory { return weak_reference_owner_.HasRefs(); } - // Indicates that this object will be used on another thread from now on. - void DetachFromThread() { - weak_reference_owner_.DetachFromThread(); - } - private: internal::WeakReferenceOwner weak_reference_owner_; T* ptr_; |