Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(760)

Unified Diff: base/ref_counted.h

Issue 360042: First patch in making destructors of refcounted objects private. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: base/ref_counted.h
===================================================================
--- base/ref_counted.h (revision 30973)
+++ base/ref_counted.h (working copy)
@@ -71,8 +71,13 @@
//
// 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 @@
// ...
// };
//
-// 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 {

Powered by Google App Engine
This is Rietveld 408576698