Index: base/memory/ref_counted.cc |
diff --git a/base/memory/ref_counted.cc b/base/memory/ref_counted.cc |
index 46bbd7ad858b152ec8a29d1b5060c24fb466be09..55f168fb94477ec09c8b69e79b0b0f2bec4391bc 100644 |
--- a/base/memory/ref_counted.cc |
+++ b/base/memory/ref_counted.cc |
@@ -3,6 +3,7 @@ |
// found in the LICENSE file. |
#include "base/memory/ref_counted.h" |
+ |
#include "base/threading/thread_collision_warner.h" |
namespace base { |
@@ -13,8 +14,6 @@ bool RefCountedThreadSafeBase::HasOneRef() const { |
return AtomicRefCountIsOne(&ref_count_); |
} |
-RefCountedThreadSafeBase::RefCountedThreadSafeBase() = default; |
- |
RefCountedThreadSafeBase::~RefCountedThreadSafeBase() { |
#if DCHECK_IS_ON() |
DCHECK(in_dtor_) << "RefCountedThreadSafe object deleted without " |
@@ -25,6 +24,10 @@ RefCountedThreadSafeBase::~RefCountedThreadSafeBase() { |
void RefCountedThreadSafeBase::AddRef() const { |
#if DCHECK_IS_ON() |
DCHECK(!in_dtor_); |
+ DCHECK(!needs_adopt_ref_) |
+ << "This RefCounted object is created with non-zero reference count." |
+ << " The first reference to such a object has to be made by AdoptRef or" |
+ << " MakeShared."; |
#endif |
AtomicRefCountInc(&ref_count_); |
} |