| 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 "jingle/notifier/base/weak_xmpp_client.h" | 5 #include "jingle/notifier/base/weak_xmpp_client.h" |
| 6 | 6 |
| 7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
| 8 | 8 |
| 9 namespace notifier { | 9 namespace notifier { |
| 10 | 10 |
| 11 WeakXmppClient::WeakXmppClient(rtc::TaskParent* parent) | 11 WeakXmppClient::WeakXmppClient(rtc::TaskParent* parent) |
| 12 : buzz::XmppClient(parent), | 12 : buzz::XmppClient(parent), |
| 13 weak_ptr_factory_(this) {} | 13 weak_ptr_factory_(this) {} |
| 14 | 14 |
| 15 WeakXmppClient::~WeakXmppClient() { | 15 WeakXmppClient::~WeakXmppClient() { |
| 16 DCHECK(CalledOnValidThread()); | 16 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); |
| 17 Invalidate(); | 17 Invalidate(); |
| 18 } | 18 } |
| 19 | 19 |
| 20 void WeakXmppClient::Invalidate() { | 20 void WeakXmppClient::Invalidate() { |
| 21 DCHECK(CalledOnValidThread()); | 21 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); |
| 22 // We don't want XmppClient raising any signals once its invalidated. | 22 // We don't want XmppClient raising any signals once its invalidated. |
| 23 SignalStateChange.disconnect_all(); | 23 SignalStateChange.disconnect_all(); |
| 24 SignalLogInput.disconnect_all(); | 24 SignalLogInput.disconnect_all(); |
| 25 SignalLogOutput.disconnect_all(); | 25 SignalLogOutput.disconnect_all(); |
| 26 weak_ptr_factory_.InvalidateWeakPtrs(); | 26 weak_ptr_factory_.InvalidateWeakPtrs(); |
| 27 } | 27 } |
| 28 | 28 |
| 29 base::WeakPtr<WeakXmppClient> WeakXmppClient::AsWeakPtr() { | 29 base::WeakPtr<WeakXmppClient> WeakXmppClient::AsWeakPtr() { |
| 30 DCHECK(CalledOnValidThread()); | 30 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); |
| 31 return weak_ptr_factory_.GetWeakPtr(); | 31 return weak_ptr_factory_.GetWeakPtr(); |
| 32 } | 32 } |
| 33 | 33 |
| 34 void WeakXmppClient::Stop() { | 34 void WeakXmppClient::Stop() { |
| 35 DCHECK(CalledOnValidThread()); | 35 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); |
| 36 // We don't want XmppClient used after it has been stopped. | 36 // We don't want XmppClient used after it has been stopped. |
| 37 Invalidate(); | 37 Invalidate(); |
| 38 buzz::XmppClient::Stop(); | 38 buzz::XmppClient::Stop(); |
| 39 } | 39 } |
| 40 | 40 |
| 41 } // namespace notifier | 41 } // namespace notifier |
| OLD | NEW |