From 59326aacf6020c3cfa8978a334c36b2dcc1a99bb Mon Sep 17 00:00:00 2001 From: "darin@chromium.org" Date: Fri, 25 Sep 2009 23:34:34 +0000 Subject: Implement ScopedRunnableMethodFactory using WeakPtr. This required some changes to WeakPtr to support the addition of WeakPtrFactory::HasWeakPtrs(), which is used to implement ScopedRunnableMethodFactory::empty(). Now, the WeakReferenceOwner just holds a pointer to the Flag class, and the Flag holds a back-pointer that it can use to clear the WeakReferenceOwner's pointer when the Flag is destroyed. I use the null'ness of this back-pointer in place of the bool member that was previously used to indicate if the WeakReference is valid. It was also necessary to expose a HasOneRef method on RefCounted. I included one on RefCountedThreadSafe for completeness. Finally, I switched HttpCache over to using WeakPtr instead of RevocableStore so that I could delete RevocableStore. (I'm making this change to consolidate similar functionality.) R=abarth BUG=none TEST=none Review URL: http://codereview.chromium.org/235027 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@27287 0039d316-1c4b-4281-b951-d872f2087c98 --- base/ref_counted.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'base/ref_counted.h') diff --git a/base/ref_counted.h b/base/ref_counted.h index 79f9f55..097d16e 100644 --- a/base/ref_counted.h +++ b/base/ref_counted.h @@ -13,6 +13,9 @@ namespace base { namespace subtle { class RefCountedBase { + public: + bool HasOneRef() const { return ref_count_ == 1; } + protected: RefCountedBase(); ~RefCountedBase(); @@ -34,6 +37,9 @@ class RefCountedBase { }; class RefCountedThreadSafeBase { + public: + bool HasOneRef() const; + protected: RefCountedThreadSafeBase(); ~RefCountedThreadSafeBase(); -- cgit v1.1