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
3 // found in the LICENSE file.
5 #include "jingle/notifier/base/weak_xmpp_client.h"
7 #include "base/compiler_specific.h"
11 WeakXmppClient::WeakXmppClient(rtc::TaskParent
* parent
)
12 : buzz::XmppClient(parent
),
13 weak_ptr_factory_(this) {}
15 WeakXmppClient::~WeakXmppClient() {
16 DCHECK(CalledOnValidThread());
20 void WeakXmppClient::Invalidate() {
21 DCHECK(CalledOnValidThread());
22 // We don't want XmppClient raising any signals once its invalidated.
23 SignalStateChange
.disconnect_all();
24 SignalLogInput
.disconnect_all();
25 SignalLogOutput
.disconnect_all();
26 weak_ptr_factory_
.InvalidateWeakPtrs();
29 base::WeakPtr
<WeakXmppClient
> WeakXmppClient::AsWeakPtr() {
30 DCHECK(CalledOnValidThread());
31 return weak_ptr_factory_
.GetWeakPtr();
34 void WeakXmppClient::Stop() {
35 DCHECK(CalledOnValidThread());
36 // We don't want XmppClient used after it has been stopped.
38 buzz::XmppClient::Stop();
41 } // namespace notifier