| OLD | NEW |
| 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 { |
| 11 | 11 |
| 12 namespace { |
| 13 |
| 14 bool ReturnFalse(const BindStateBase*) { |
| 15 return false; |
| 16 } |
| 17 |
| 18 } // namespace |
| 19 |
| 20 BindStateBase::BindStateBase(InvokeFuncStorage polymorphic_invoke, |
| 21 void (*destructor)(BindStateBase*)) |
| 22 : BindStateBase(polymorphic_invoke, destructor, &ReturnFalse) { |
| 23 } |
| 24 |
| 12 BindStateBase::BindStateBase(InvokeFuncStorage polymorphic_invoke, | 25 BindStateBase::BindStateBase(InvokeFuncStorage polymorphic_invoke, |
| 13 void (*destructor)(BindStateBase*), | 26 void (*destructor)(BindStateBase*), |
| 14 bool (*is_cancelled)(const BindStateBase*)) | 27 bool (*is_cancelled)(const BindStateBase*)) |
| 15 : polymorphic_invoke_(polymorphic_invoke), | 28 : polymorphic_invoke_(polymorphic_invoke), |
| 16 ref_count_(0), | 29 ref_count_(0), |
| 17 destructor_(destructor), | 30 destructor_(destructor), |
| 18 is_cancelled_(is_cancelled) {} | 31 is_cancelled_(is_cancelled) {} |
| 19 | 32 |
| 20 void BindStateBase::AddRef() { | 33 void BindStateBase::AddRef() { |
| 21 AtomicRefCountInc(&ref_count_); | 34 AtomicRefCountInc(&ref_count_); |
| 22 } | 35 } |
| 23 | 36 |
| 24 void BindStateBase::Release() { | 37 void BindStateBase::Release() { |
| 25 if (!AtomicRefCountDec(&ref_count_)) | 38 if (!AtomicRefCountDec(&ref_count_)) |
| 26 destructor_(this); | 39 destructor_(this); |
| 27 } | 40 } |
| 28 | 41 |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 } | 93 } |
| 81 | 94 |
| 82 CallbackBase<CopyMode::Copyable>& | 95 CallbackBase<CopyMode::Copyable>& |
| 83 CallbackBase<CopyMode::Copyable>::operator=(CallbackBase&& c) = default; | 96 CallbackBase<CopyMode::Copyable>::operator=(CallbackBase&& c) = default; |
| 84 | 97 |
| 85 template class CallbackBase<CopyMode::MoveOnly>; | 98 template class CallbackBase<CopyMode::MoveOnly>; |
| 86 template class CallbackBase<CopyMode::Copyable>; | 99 template class CallbackBase<CopyMode::Copyable>; |
| 87 | 100 |
| 88 } // namespace internal | 101 } // namespace internal |
| 89 } // namespace base | 102 } // namespace base |
| OLD | NEW |