| Index: base/memory/ref_counted.h
|
| diff --git a/base/memory/ref_counted.h b/base/memory/ref_counted.h
|
| index 6c363ccd709b71d1be8a8494f73c4b1f6c2f4a43..3695f87b080f086cb961810eae232d67e12ec34c 100644
|
| --- a/base/memory/ref_counted.h
|
| +++ b/base/memory/ref_counted.h
|
| @@ -142,10 +142,31 @@ class BASE_EXPORT RefCountedThreadSafeBase {
|
|
|
| ~RefCountedThreadSafeBase();
|
|
|
| - void AddRef() const;
|
| + void 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"
|
| + << " MakeRefCounted.";
|
| +#endif
|
| + AtomicRefCountInc(&ref_count_);
|
| + }
|
|
|
| // Returns true if the object should self-delete.
|
| - bool Release() const;
|
| + bool Release() const {
|
| +#if DCHECK_IS_ON()
|
| + DCHECK(!in_dtor_);
|
| + DCHECK(!AtomicRefCountIsZero(&ref_count_));
|
| +#endif
|
| + if (!AtomicRefCountDec(&ref_count_)) {
|
| +#if DCHECK_IS_ON()
|
| + in_dtor_ = true;
|
| +#endif
|
| + return true;
|
| + }
|
| + return false;
|
| + }
|
|
|
| private:
|
| template <typename U>
|
|
|