| 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 14 matching lines...) Expand all Loading... |
| 25 } | 25 } |
| 26 | 26 |
| 27 CallbackBase<CopyMode::MoveOnly>& | 27 CallbackBase<CopyMode::MoveOnly>& |
| 28 CallbackBase<CopyMode::MoveOnly>::operator=(CallbackBase&& c) { | 28 CallbackBase<CopyMode::MoveOnly>::operator=(CallbackBase&& c) { |
| 29 bind_state_ = std::move(c.bind_state_); | 29 bind_state_ = std::move(c.bind_state_); |
| 30 polymorphic_invoke_ = c.polymorphic_invoke_; | 30 polymorphic_invoke_ = c.polymorphic_invoke_; |
| 31 c.polymorphic_invoke_ = nullptr; | 31 c.polymorphic_invoke_ = nullptr; |
| 32 return *this; | 32 return *this; |
| 33 } | 33 } |
| 34 | 34 |
| 35 CallbackBase<CopyMode::MoveOnly>::CallbackBase( |
| 36 const CallbackBase<CopyMode::Copyable>& c) |
| 37 : bind_state_(c.bind_state_), polymorphic_invoke_(c.polymorphic_invoke_) {} |
| 38 |
| 39 CallbackBase<CopyMode::MoveOnly>& CallbackBase<CopyMode::MoveOnly>::operator=( |
| 40 const CallbackBase<CopyMode::Copyable>& c) { |
| 41 bind_state_ = c.bind_state_; |
| 42 polymorphic_invoke_ = c.polymorphic_invoke_; |
| 43 return *this; |
| 44 } |
| 45 |
| 35 void CallbackBase<CopyMode::MoveOnly>::Reset() { | 46 void CallbackBase<CopyMode::MoveOnly>::Reset() { |
| 36 polymorphic_invoke_ = nullptr; | 47 polymorphic_invoke_ = nullptr; |
| 37 // NULL the bind_state_ last, since it may be holding the last ref to whatever | 48 // NULL the bind_state_ last, since it may be holding the last ref to whatever |
| 38 // object owns us, and we may be deleted after that. | 49 // object owns us, and we may be deleted after that. |
| 39 bind_state_ = nullptr; | 50 bind_state_ = nullptr; |
| 40 } | 51 } |
| 41 | 52 |
| 42 bool CallbackBase<CopyMode::MoveOnly>::EqualsInternal( | 53 bool CallbackBase<CopyMode::MoveOnly>::EqualsInternal( |
| 43 const CallbackBase& other) const { | 54 const CallbackBase& other) const { |
| 44 return bind_state_.get() == other.bind_state_.get() && | 55 return bind_state_.get() == other.bind_state_.get() && |
| (...skipping 29 matching lines...) Expand all Loading... |
| 74 CallbackBase<CopyMode::Copyable>::operator=(CallbackBase&& c) { | 85 CallbackBase<CopyMode::Copyable>::operator=(CallbackBase&& c) { |
| 75 *static_cast<CallbackBase<CopyMode::MoveOnly>*>(this) = std::move(c); | 86 *static_cast<CallbackBase<CopyMode::MoveOnly>*>(this) = std::move(c); |
| 76 return *this; | 87 return *this; |
| 77 } | 88 } |
| 78 | 89 |
| 79 template class CallbackBase<CopyMode::MoveOnly>; | 90 template class CallbackBase<CopyMode::MoveOnly>; |
| 80 template class CallbackBase<CopyMode::Copyable>; | 91 template class CallbackBase<CopyMode::Copyable>; |
| 81 | 92 |
| 82 } // namespace internal | 93 } // namespace internal |
| 83 } // namespace base | 94 } // namespace base |
| OLD | NEW |