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

Unified Diff: base/memory/ref_counted.cc

Issue 2723423002: Start BindStateBase ref count from 1 instead of 0 (Closed)
Patch Set: +MAKE_REF_COUNT_START_FROM_ONE. +document Created 3 years, 9 months 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/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_);
}

Powered by Google App Engine
This is Rietveld 408576698