1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "base/memory/ref_counted.h"
6 #include "base/threading/thread_collision_warner.h"
12 bool RefCountedThreadSafeBase::HasOneRef() const {
13 return AtomicRefCountIsOne(
14 &const_cast<RefCountedThreadSafeBase
*>(this)->ref_count_
);
17 RefCountedThreadSafeBase::RefCountedThreadSafeBase() : ref_count_(0) {
23 RefCountedThreadSafeBase::~RefCountedThreadSafeBase() {
25 DCHECK(in_dtor_
) << "RefCountedThreadSafe object deleted without "
30 void RefCountedThreadSafeBase::AddRef() const {
34 AtomicRefCountInc(&ref_count_
);
37 bool RefCountedThreadSafeBase::Release() const {
40 DCHECK(!AtomicRefCountIsZero(&ref_count_
));
42 if (!AtomicRefCountDec(&ref_count_
)) {