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