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

Side by Side Diff: base/callback_internal.cc

Issue 2723423002: Start BindStateBase ref count from 1 instead of 0 (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
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 #include "base/callback_internal.h" 5 #include "base/callback_internal.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 8
9 namespace base { 9 namespace base {
10 namespace internal { 10 namespace internal {
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 bool CallbackBase<CopyMode::MoveOnly>::IsCancelled() const { 67 bool CallbackBase<CopyMode::MoveOnly>::IsCancelled() const {
68 DCHECK(bind_state_); 68 DCHECK(bind_state_);
69 return bind_state_->IsCancelled(); 69 return bind_state_->IsCancelled();
70 } 70 }
71 71
72 bool CallbackBase<CopyMode::MoveOnly>::EqualsInternal( 72 bool CallbackBase<CopyMode::MoveOnly>::EqualsInternal(
73 const CallbackBase& other) const { 73 const CallbackBase& other) const {
74 return bind_state_ == other.bind_state_; 74 return bind_state_ == other.bind_state_;
75 } 75 }
76 76
77 CallbackBase<CopyMode::MoveOnly>::CallbackBase( 77 CallbackBase<CopyMode::MoveOnly>::CallbackBase(BindStateBase* bind_state)
78 BindStateBase* bind_state) 78 : bind_state_(bind_state ? AdoptRef(bind_state) : nullptr) {
79 : bind_state_(bind_state) {
80 DCHECK(!bind_state_.get() || bind_state_->HasOneRef()); 79 DCHECK(!bind_state_.get() || bind_state_->HasOneRef());
81 } 80 }
82 81
83 CallbackBase<CopyMode::MoveOnly>::~CallbackBase() {} 82 CallbackBase<CopyMode::MoveOnly>::~CallbackBase() {}
84 83
85 CallbackBase<CopyMode::Copyable>::CallbackBase( 84 CallbackBase<CopyMode::Copyable>::CallbackBase(
86 const CallbackBase& c) 85 const CallbackBase& c)
87 : CallbackBase<CopyMode::MoveOnly>(nullptr) { 86 : CallbackBase<CopyMode::MoveOnly>(nullptr) {
88 bind_state_ = c.bind_state_; 87 bind_state_ = c.bind_state_;
89 } 88 }
90 89
91 CallbackBase<CopyMode::Copyable>::CallbackBase(CallbackBase&& c) = default; 90 CallbackBase<CopyMode::Copyable>::CallbackBase(CallbackBase&& c) = default;
92 91
93 CallbackBase<CopyMode::Copyable>& 92 CallbackBase<CopyMode::Copyable>&
94 CallbackBase<CopyMode::Copyable>::operator=(const CallbackBase& c) { 93 CallbackBase<CopyMode::Copyable>::operator=(const CallbackBase& c) {
95 bind_state_ = c.bind_state_; 94 bind_state_ = c.bind_state_;
96 return *this; 95 return *this;
97 } 96 }
98 97
99 CallbackBase<CopyMode::Copyable>& 98 CallbackBase<CopyMode::Copyable>&
100 CallbackBase<CopyMode::Copyable>::operator=(CallbackBase&& c) = default; 99 CallbackBase<CopyMode::Copyable>::operator=(CallbackBase&& c) = default;
101 100
102 template class CallbackBase<CopyMode::MoveOnly>; 101 template class CallbackBase<CopyMode::MoveOnly>;
103 template class CallbackBase<CopyMode::Copyable>; 102 template class CallbackBase<CopyMode::Copyable>;
104 103
105 } // namespace internal 104 } // namespace internal
106 } // namespace base 105 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698