blob: 5acade0ccb8da5d11ff9fe2953d4762f377c37d3 [file] [log] [blame]
bryeung@chromium.org84b42de2012-06-09 11:11:01 +09001// Copyright (c) 2012 The Chromium Authors. All rights reserved.
ajwong@chromium.orgfa0ff432011-02-19 08:29:31 +09002// 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.orgabd70002011-12-20 09:10:04 +09007#include "base/logging.h"
8
ajwong@chromium.orgfa0ff432011-02-19 08:29:31 +09009namespace base {
10namespace internal {
11
12bool CallbackBase::is_null() const {
ajwong@chromium.orgc9c79af2011-11-22 04:23:44 +090013 return bind_state_.get() == NULL;
ajwong@chromium.orgfa0ff432011-02-19 08:29:31 +090014}
15
16void CallbackBase::Reset() {
ajwong@chromium.orgfa0ff432011-02-19 08:29:31 +090017 polymorphic_invoke_ = NULL;
mattm@chromium.orgbf27cb72012-06-14 08:15:16 +090018 // 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.orgfa0ff432011-02-19 08:29:31 +090021}
22
23bool CallbackBase::Equals(const CallbackBase& other) const {
ajwong@chromium.orgc9c79af2011-11-22 04:23:44 +090024 return bind_state_.get() == other.bind_state_.get() &&
ajwong@chromium.orgfa0ff432011-02-19 08:29:31 +090025 polymorphic_invoke_ == other.polymorphic_invoke_;
26}
27
ajwong@chromium.orgabd70002011-12-20 09:10:04 +090028CallbackBase::CallbackBase(BindStateBase* bind_state)
29 : bind_state_(bind_state),
30 polymorphic_invoke_(NULL) {
rsleevi@chromium.org7501b032013-06-01 06:37:53 +090031 DCHECK(!bind_state_.get() || bind_state_->HasOneRef());
ajwong@chromium.orgfa0ff432011-02-19 08:29:31 +090032}
33
34CallbackBase::~CallbackBase() {
35}
36
ajwong@chromium.orgfa0ff432011-02-19 08:29:31 +090037} // namespace internal
bryeung@chromium.org84b42de2012-06-09 11:11:01 +090038} // namespace base