| 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 { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 void BindStateBase::Release() { | 24 void BindStateBase::Release() { |
| 25 if (!AtomicRefCountDec(&ref_count_)) | 25 if (!AtomicRefCountDec(&ref_count_)) |
| 26 destructor_(this); | 26 destructor_(this); |
| 27 } | 27 } |
| 28 | 28 |
| 29 CallbackBase<CopyMode::MoveOnly>::CallbackBase(CallbackBase&& c) = default; | 29 CallbackBase<CopyMode::MoveOnly>::CallbackBase(CallbackBase&& c) = default; |
| 30 | 30 |
| 31 CallbackBase<CopyMode::MoveOnly>& | 31 CallbackBase<CopyMode::MoveOnly>& |
| 32 CallbackBase<CopyMode::MoveOnly>::operator=(CallbackBase&& c) = default; | 32 CallbackBase<CopyMode::MoveOnly>::operator=(CallbackBase&& c) = default; |
| 33 | 33 |
| 34 CallbackBase<CopyMode::MoveOnly>::CallbackBase( |
| 35 const CallbackBase<CopyMode::Copyable>& c) |
| 36 : bind_state_(c.bind_state_) {} |
| 37 |
| 38 CallbackBase<CopyMode::MoveOnly>& CallbackBase<CopyMode::MoveOnly>::operator=( |
| 39 const CallbackBase<CopyMode::Copyable>& c) { |
| 40 bind_state_ = c.bind_state_; |
| 41 return *this; |
| 42 } |
| 43 |
| 34 void CallbackBase<CopyMode::MoveOnly>::Reset() { | 44 void CallbackBase<CopyMode::MoveOnly>::Reset() { |
| 35 // NULL the bind_state_ last, since it may be holding the last ref to whatever | 45 // NULL the bind_state_ last, since it may be holding the last ref to whatever |
| 36 // object owns us, and we may be deleted after that. | 46 // object owns us, and we may be deleted after that. |
| 37 bind_state_ = nullptr; | 47 bind_state_ = nullptr; |
| 38 } | 48 } |
| 39 | 49 |
| 40 bool CallbackBase<CopyMode::MoveOnly>::IsCancelled() const { | 50 bool CallbackBase<CopyMode::MoveOnly>::IsCancelled() const { |
| 41 DCHECK(bind_state_); | 51 DCHECK(bind_state_); |
| 42 return bind_state_->IsCancelled(); | 52 return bind_state_->IsCancelled(); |
| 43 } | 53 } |
| (...skipping 26 matching lines...) Expand all Loading... |
| 70 } | 80 } |
| 71 | 81 |
| 72 CallbackBase<CopyMode::Copyable>& | 82 CallbackBase<CopyMode::Copyable>& |
| 73 CallbackBase<CopyMode::Copyable>::operator=(CallbackBase&& c) = default; | 83 CallbackBase<CopyMode::Copyable>::operator=(CallbackBase&& c) = default; |
| 74 | 84 |
| 75 template class CallbackBase<CopyMode::MoveOnly>; | 85 template class CallbackBase<CopyMode::MoveOnly>; |
| 76 template class CallbackBase<CopyMode::Copyable>; | 86 template class CallbackBase<CopyMode::Copyable>; |
| 77 | 87 |
| 78 } // namespace internal | 88 } // namespace internal |
| 79 } // namespace base | 89 } // namespace base |
| OLD | NEW |