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

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

Issue 1749053002: Move //remoting/remoting_host_win.gypi:* to GN (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update for component build of Windows Created 4 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 unified diff | Download patch
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 #include "base/threading/thread_collision_warner.h" 6 #include "base/threading/thread_collision_warner.h"
7 7
8 namespace base { 8 namespace base {
9 9
10 namespace subtle { 10 namespace subtle {
11 11
12 void RefCountedBase::AddRef() const {
13 // TODO(maruel): Add back once it doesn't assert 500 times/sec.
14 // Current thread books the critical section "AddRelease"
15 // without release it.
16 // DFAKE_SCOPED_LOCK_THREAD_LOCKED(add_release_);
17 #ifndef NDEBUG
18 DCHECK(!in_dtor_);
19 #endif
20 ++ref_count_;
21 }
22
23 bool RefCountedBase::Release() const {
24 // TODO(maruel): Add back once it doesn't assert 500 times/sec.
25 // Current thread books the critical section "AddRelease"
26 // without release it.
27 // DFAKE_SCOPED_LOCK_THREAD_LOCKED(add_release_);
28 #ifndef NDEBUG
29 DCHECK(!in_dtor_);
30 #endif
31 if (--ref_count_ == 0) {
32 #ifndef NDEBUG
33 in_dtor_ = true;
34 #endif
35 return true;
36 }
37 return false;
38 }
39
12 bool RefCountedThreadSafeBase::HasOneRef() const { 40 bool RefCountedThreadSafeBase::HasOneRef() const {
13 return AtomicRefCountIsOne( 41 return AtomicRefCountIsOne(
14 &const_cast<RefCountedThreadSafeBase*>(this)->ref_count_); 42 &const_cast<RefCountedThreadSafeBase*>(this)->ref_count_);
15 } 43 }
16 44
17 RefCountedThreadSafeBase::RefCountedThreadSafeBase() : ref_count_(0) { 45 RefCountedThreadSafeBase::RefCountedThreadSafeBase() : ref_count_(0) {
18 #ifndef NDEBUG 46 #ifndef NDEBUG
19 in_dtor_ = false; 47 in_dtor_ = false;
20 #endif 48 #endif
21 } 49 }
(...skipping 22 matching lines...) Expand all
44 in_dtor_ = true; 72 in_dtor_ = true;
45 #endif 73 #endif
46 return true; 74 return true;
47 } 75 }
48 return false; 76 return false;
49 } 77 }
50 78
51 } // namespace subtle 79 } // namespace subtle
52 80
53 } // namespace base 81 } // namespace base
OLDNEW
« no previous file with comments | « base/memory/ref_counted.h ('k') | build/config/win/BUILD.gn » ('j') | remoting/host/BUILD.gn » ('J')

Powered by Google App Engine
This is Rietveld 408576698