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

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

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
« no previous file with comments | « no previous file | base/memory/ref_counted.cc » ('j') | remoting/host/BUILD.gn » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #ifndef BASE_MEMORY_REF_COUNTED_H_ 5 #ifndef BASE_MEMORY_REF_COUNTED_H_
6 #define BASE_MEMORY_REF_COUNTED_H_ 6 #define BASE_MEMORY_REF_COUNTED_H_
7 7
8 #include <cassert> 8 #include <cassert>
9 #include <iosfwd> 9 #include <iosfwd>
10 10
(...skipping 24 matching lines...) Expand all
35 { 35 {
36 } 36 }
37 37
38 ~RefCountedBase() { 38 ~RefCountedBase() {
39 #ifndef NDEBUG 39 #ifndef NDEBUG
40 DCHECK(in_dtor_) << "RefCounted object deleted without calling Release()"; 40 DCHECK(in_dtor_) << "RefCounted object deleted without calling Release()";
41 #endif 41 #endif
42 } 42 }
43 43
44 44
45 void AddRef() const { 45 void AddRef() const;
46 // TODO(maruel): Add back once it doesn't assert 500 times/sec.
47 // Current thread books the critical section "AddRelease"
48 // without release it.
49 // DFAKE_SCOPED_LOCK_THREAD_LOCKED(add_release_);
50 #ifndef NDEBUG
51 DCHECK(!in_dtor_);
52 #endif
53 ++ref_count_;
54 }
55 46
56 // Returns true if the object should self-delete. 47 // Returns true if the object should self-delete.
57 bool Release() const { 48 bool Release() const;
58 // TODO(maruel): Add back once it doesn't assert 500 times/sec.
59 // Current thread books the critical section "AddRelease"
60 // without release it.
61 // DFAKE_SCOPED_LOCK_THREAD_LOCKED(add_release_);
62 #ifndef NDEBUG
63 DCHECK(!in_dtor_);
64 #endif
65 if (--ref_count_ == 0) {
66 #ifndef NDEBUG
67 in_dtor_ = true;
68 #endif
69 return true;
70 }
71 return false;
72 }
73 49
74 private: 50 private:
75 mutable int ref_count_; 51 mutable int ref_count_;
76 #ifndef NDEBUG 52 #ifndef NDEBUG
77 mutable bool in_dtor_; 53 mutable bool in_dtor_;
78 #endif 54 #endif
79 55
80 DFAKE_MUTEX(add_release_); 56 DFAKE_MUTEX(add_release_);
81 57
82 DISALLOW_COPY_AND_ASSIGN(RefCountedBase); 58 DISALLOW_COPY_AND_ASSIGN(RefCountedBase);
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after
445 bool operator!=(const T* lhs, const scoped_refptr<U>& rhs) { 421 bool operator!=(const T* lhs, const scoped_refptr<U>& rhs) {
446 return !operator==(lhs, rhs); 422 return !operator==(lhs, rhs);
447 } 423 }
448 424
449 template <typename T> 425 template <typename T>
450 std::ostream& operator<<(std::ostream& out, const scoped_refptr<T>& p) { 426 std::ostream& operator<<(std::ostream& out, const scoped_refptr<T>& p) {
451 return out << p.get(); 427 return out << p.get();
452 } 428 }
453 429
454 #endif // BASE_MEMORY_REF_COUNTED_H_ 430 #endif // BASE_MEMORY_REF_COUNTED_H_
OLDNEW
« no previous file with comments | « no previous file | base/memory/ref_counted.cc » ('j') | remoting/host/BUILD.gn » ('J')

Powered by Google App Engine
This is Rietveld 408576698