| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/memory/ref_counted.h" | 5 #include "base/memory/ref_counted.h" |
| 6 | 6 |
| 7 #include "base/threading/thread_collision_warner.h" | 7 #include "base/threading/thread_collision_warner.h" |
| 8 | 8 |
| 9 namespace base { | 9 namespace base { |
| 10 namespace { | 10 namespace { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 return AtomicRefCountIsOne(&ref_count_); | 21 return AtomicRefCountIsOne(&ref_count_); |
| 22 } | 22 } |
| 23 | 23 |
| 24 RefCountedThreadSafeBase::~RefCountedThreadSafeBase() { | 24 RefCountedThreadSafeBase::~RefCountedThreadSafeBase() { |
| 25 #if DCHECK_IS_ON() | 25 #if DCHECK_IS_ON() |
| 26 DCHECK(in_dtor_) << "RefCountedThreadSafe object deleted without " | 26 DCHECK(in_dtor_) << "RefCountedThreadSafe object deleted without " |
| 27 "calling Release()"; | 27 "calling Release()"; |
| 28 #endif | 28 #endif |
| 29 } | 29 } |
| 30 | 30 |
| 31 #if !defined(ARCH_CPU_X86_FAMILY) |
| 32 bool RefCountedThreadSafeBase::Release() const { |
| 33 return ReleaseImpl(); |
| 34 } |
| 35 void RefCountedThreadSafeBase::AddRef() const { |
| 36 AddRefImpl(); |
| 37 } |
| 38 #endif |
| 39 |
| 31 #if DCHECK_IS_ON() | 40 #if DCHECK_IS_ON() |
| 32 bool RefCountedBase::CalledOnValidSequence() const { | 41 bool RefCountedBase::CalledOnValidSequence() const { |
| 33 return sequence_checker_.CalledOnValidSequence() || | 42 return sequence_checker_.CalledOnValidSequence() || |
| 34 !AtomicRefCountIsZero(&g_cross_thread_ref_count_access_allow_count); | 43 !AtomicRefCountIsZero(&g_cross_thread_ref_count_access_allow_count); |
| 35 } | 44 } |
| 36 #endif | 45 #endif |
| 37 | 46 |
| 38 } // namespace subtle | 47 } // namespace subtle |
| 39 | 48 |
| 40 #if DCHECK_IS_ON() | 49 #if DCHECK_IS_ON() |
| 41 ScopedAllowCrossThreadRefCountAccess::ScopedAllowCrossThreadRefCountAccess() { | 50 ScopedAllowCrossThreadRefCountAccess::ScopedAllowCrossThreadRefCountAccess() { |
| 42 AtomicRefCountInc(&g_cross_thread_ref_count_access_allow_count); | 51 AtomicRefCountInc(&g_cross_thread_ref_count_access_allow_count); |
| 43 } | 52 } |
| 44 | 53 |
| 45 ScopedAllowCrossThreadRefCountAccess::~ScopedAllowCrossThreadRefCountAccess() { | 54 ScopedAllowCrossThreadRefCountAccess::~ScopedAllowCrossThreadRefCountAccess() { |
| 46 AtomicRefCountDec(&g_cross_thread_ref_count_access_allow_count); | 55 AtomicRefCountDec(&g_cross_thread_ref_count_access_allow_count); |
| 47 } | 56 } |
| 48 #endif | 57 #endif |
| 49 | 58 |
| 50 } // namespace base | 59 } // namespace base |
| OLD | NEW |