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

Side by Side Diff: base/memory/ref_counted.cc

Issue 2783393002: Revert of Assert sequence validity on non-thread-safe RefCount manipulations (2) (Closed)
Patch Set: Created 3 years, 8 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 unified diff | Download patch
« no previous file with comments | « base/memory/ref_counted.h ('k') | cc/trees/proxy_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
7 #include "base/threading/thread_collision_warner.h" 6 #include "base/threading/thread_collision_warner.h"
8 7
9 namespace base { 8 namespace base {
10 namespace {
11
12 #if DCHECK_IS_ON()
13 AtomicRefCount g_cross_thread_ref_count_access_allow_count = 0;
14 #endif
15
16 } // namespace
17 9
18 namespace subtle { 10 namespace subtle {
19 11
20 bool RefCountedThreadSafeBase::HasOneRef() const { 12 bool RefCountedThreadSafeBase::HasOneRef() const {
21 return AtomicRefCountIsOne(&ref_count_); 13 return AtomicRefCountIsOne(&ref_count_);
22 } 14 }
23 15
24 RefCountedThreadSafeBase::RefCountedThreadSafeBase() = default; 16 RefCountedThreadSafeBase::RefCountedThreadSafeBase() = default;
25 17
26 RefCountedThreadSafeBase::~RefCountedThreadSafeBase() { 18 RefCountedThreadSafeBase::~RefCountedThreadSafeBase() {
(...skipping 17 matching lines...) Expand all
44 #endif 36 #endif
45 if (!AtomicRefCountDec(&ref_count_)) { 37 if (!AtomicRefCountDec(&ref_count_)) {
46 #if DCHECK_IS_ON() 38 #if DCHECK_IS_ON()
47 in_dtor_ = true; 39 in_dtor_ = true;
48 #endif 40 #endif
49 return true; 41 return true;
50 } 42 }
51 return false; 43 return false;
52 } 44 }
53 45
54 #if DCHECK_IS_ON()
55 bool RefCountedBase::CalledOnValidSequence() const {
56 return sequence_checker_.CalledOnValidSequence() ||
57 !AtomicRefCountIsZero(&g_cross_thread_ref_count_access_allow_count);
58 }
59 #endif
60
61 } // namespace subtle 46 } // namespace subtle
62 47
63 #if DCHECK_IS_ON()
64 ScopedAllowCrossThreadRefCountAccess::ScopedAllowCrossThreadRefCountAccess() {
65 AtomicRefCountInc(&g_cross_thread_ref_count_access_allow_count);
66 }
67
68 ScopedAllowCrossThreadRefCountAccess::~ScopedAllowCrossThreadRefCountAccess() {
69 AtomicRefCountDec(&g_cross_thread_ref_count_access_allow_count);
70 }
71 #endif
72
73 } // namespace base 48 } // namespace base
OLDNEW
« no previous file with comments | « base/memory/ref_counted.h ('k') | cc/trees/proxy_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698