bryeung@chromium.org | 84b42de | 2012-06-09 11:11:01 +0900 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
ajwong@chromium.org | fa0ff43 | 2011-02-19 08:29:31 +0900 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #include "base/callback_internal.h" |
| 6 | |
ajwong@chromium.org | abd7000 | 2011-12-20 09:10:04 +0900 | [diff] [blame] | 7 | #include "base/logging.h" |
| 8 | |
ajwong@chromium.org | fa0ff43 | 2011-02-19 08:29:31 +0900 | [diff] [blame] | 9 | namespace base { |
| 10 | namespace internal { |
| 11 | |
| 12 | bool CallbackBase::is_null() const { |
ajwong@chromium.org | c9c79af | 2011-11-22 04:23:44 +0900 | [diff] [blame] | 13 | return bind_state_.get() == NULL; |
ajwong@chromium.org | fa0ff43 | 2011-02-19 08:29:31 +0900 | [diff] [blame] | 14 | } |
| 15 | |
| 16 | void CallbackBase::Reset() { |
ajwong@chromium.org | fa0ff43 | 2011-02-19 08:29:31 +0900 | [diff] [blame] | 17 | polymorphic_invoke_ = NULL; |
mattm@chromium.org | bf27cb7 | 2012-06-14 08:15:16 +0900 | [diff] [blame] | 18 | // NULL the bind_state_ last, since it may be holding the last ref to whatever |
| 19 | // object owns us, and we may be deleted after that. |
| 20 | bind_state_ = NULL; |
ajwong@chromium.org | fa0ff43 | 2011-02-19 08:29:31 +0900 | [diff] [blame] | 21 | } |
| 22 | |
| 23 | bool CallbackBase::Equals(const CallbackBase& other) const { |
ajwong@chromium.org | c9c79af | 2011-11-22 04:23:44 +0900 | [diff] [blame] | 24 | return bind_state_.get() == other.bind_state_.get() && |
ajwong@chromium.org | fa0ff43 | 2011-02-19 08:29:31 +0900 | [diff] [blame] | 25 | polymorphic_invoke_ == other.polymorphic_invoke_; |
| 26 | } |
| 27 | |
ajwong@chromium.org | abd7000 | 2011-12-20 09:10:04 +0900 | [diff] [blame] | 28 | CallbackBase::CallbackBase(BindStateBase* bind_state) |
| 29 | : bind_state_(bind_state), |
| 30 | polymorphic_invoke_(NULL) { |
rsleevi@chromium.org | 7501b03 | 2013-06-01 06:37:53 +0900 | [diff] [blame] | 31 | DCHECK(!bind_state_.get() || bind_state_->HasOneRef()); |
ajwong@chromium.org | fa0ff43 | 2011-02-19 08:29:31 +0900 | [diff] [blame] | 32 | } |
| 33 | |
| 34 | CallbackBase::~CallbackBase() { |
| 35 | } |
| 36 | |
ajwong@chromium.org | fa0ff43 | 2011-02-19 08:29:31 +0900 | [diff] [blame] | 37 | } // namespace internal |
bryeung@chromium.org | 84b42de | 2012-06-09 11:11:01 +0900 | [diff] [blame] | 38 | } // namespace base |