diff options
author | darin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-25 23:34:34 +0000 |
---|---|---|
committer | darin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-25 23:34:34 +0000 |
commit | 59326aacf6020c3cfa8978a334c36b2dcc1a99bb (patch) | |
tree | 698940cee180d498131c98b9efbb2de30b642161 /base/ref_counted.h | |
parent | 754f7e974507e71f6ac40eec66bcb73f13d868c6 (diff) | |
download | chromium_src-59326aacf6020c3cfa8978a334c36b2dcc1a99bb.zip chromium_src-59326aacf6020c3cfa8978a334c36b2dcc1a99bb.tar.gz chromium_src-59326aacf6020c3cfa8978a334c36b2dcc1a99bb.tar.bz2 |
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
Diffstat (limited to 'base/ref_counted.h')
-rw-r--r-- | base/ref_counted.h | 6 |
1 files changed, 6 insertions, 0 deletions
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(); |