| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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" | |
| 8 | |
| 9 namespace base { | 7 namespace base { |
| 10 namespace internal { | 8 namespace internal { |
| 11 | 9 |
| 12 bool CallbackBase::is_null() const { | 10 bool CallbackBase::is_null() const { |
| 13 return bind_state_.get() == NULL; | 11 return bind_state_.get() == NULL; |
| 14 } | 12 } |
| 15 | 13 |
| 16 void CallbackBase::Reset() { | 14 void CallbackBase::Reset() { |
| 17 bind_state_ = NULL; | 15 bind_state_ = NULL; |
| 18 polymorphic_invoke_ = NULL; | 16 polymorphic_invoke_ = NULL; |
| 19 } | 17 } |
| 20 | 18 |
| 21 bool CallbackBase::Equals(const CallbackBase& other) const { | 19 bool CallbackBase::Equals(const CallbackBase& other) const { |
| 22 return bind_state_.get() == other.bind_state_.get() && | 20 return bind_state_.get() == other.bind_state_.get() && |
| 23 polymorphic_invoke_ == other.polymorphic_invoke_; | 21 polymorphic_invoke_ == other.polymorphic_invoke_; |
| 24 } | 22 } |
| 25 | 23 |
| 26 CallbackBase::CallbackBase(BindStateBase* bind_state) | 24 CallbackBase::CallbackBase(InvokeFuncStorage polymorphic_invoke, |
| 27 : bind_state_(bind_state), | 25 scoped_refptr<BindStateBase>* bind_state) |
| 28 polymorphic_invoke_(NULL) { | 26 : polymorphic_invoke_(polymorphic_invoke) { |
| 29 DCHECK(!bind_state_ || bind_state_->HasOneRef()); | 27 if (bind_state) { |
| 28 bind_state_.swap(*bind_state); |
| 29 } |
| 30 } | 30 } |
| 31 | 31 |
| 32 CallbackBase::~CallbackBase() { | 32 CallbackBase::~CallbackBase() { |
| 33 } | 33 } |
| 34 | 34 |
| 35 } // namespace base | 35 } // namespace base |
| 36 } // namespace internal | 36 } // namespace internal |
| OLD | NEW |