diff options
author | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-05 21:53:08 +0000 |
---|---|---|
committer | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-05 21:53:08 +0000 |
commit | 877d55dcd3e01d1db858f154a1f369e76b2ebaf2 (patch) | |
tree | ee2364ca767826deed3d541603d6c92ca2f0062e /base/ref_counted.h | |
parent | aaa47ee9d83f773d37aa4fd4a04097425ce62063 (diff) | |
download | chromium_src-877d55dcd3e01d1db858f154a1f369e76b2ebaf2.zip chromium_src-877d55dcd3e01d1db858f154a1f369e76b2ebaf2.tar.gz chromium_src-877d55dcd3e01d1db858f154a1f369e76b2ebaf2.tar.bz2 |
First patch in making destructors of refcounted objects private.
BUG=26749
Review URL: http://codereview.chromium.org/360042
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@31136 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/ref_counted.h')
-rw-r--r-- | base/ref_counted.h | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/base/ref_counted.h b/base/ref_counted.h index ea532a4..f2e4327 100644 --- a/base/ref_counted.h +++ b/base/ref_counted.h @@ -71,8 +71,13 @@ class RefCountedThreadSafeBase { // // class MyFoo : public base::RefCounted<MyFoo> { // ... +// private: +// friend class base::RefCounted<MyFoo>; +// ~MyFoo(); // }; // +// You should always make your destructor private, to avoid any code deleting +// the object accidently while there are references to it. template <class T> class RefCounted : public subtle::RefCountedBase { public: @@ -115,10 +120,10 @@ struct DefaultRefCountedThreadSafeTraits { // ... // }; // -// If you're using the default trait, then you may choose to add compile time +// If you're using the default trait, then you should add compile time // asserts that no one else is deleting your object. i.e. // private: -// friend struct base::RefCountedThreadSafe<MyFoo>; +// friend class base::RefCountedThreadSafe<MyFoo>; // ~MyFoo(); template <class T, typename Traits = DefaultRefCountedThreadSafeTraits<T> > class RefCountedThreadSafe : public subtle::RefCountedThreadSafeBase { |