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 // A thin wrapper around buzz::XmppClient that exposes weak pointers | 5 // A thin wrapper around buzz::XmppClient that exposes weak pointers |
6 // so that users know when the buzz::XmppClient becomes invalid to use | 6 // so that users know when the buzz::XmppClient becomes invalid to use |
7 // (not necessarily only at destruction time). | 7 // (not necessarily only at destruction time). |
8 | 8 |
9 #ifndef JINGLE_NOTIFIER_BASE_WEAK_XMPP_CLIENT_H_ | 9 #ifndef JINGLE_NOTIFIER_BASE_WEAK_XMPP_CLIENT_H_ |
10 #define JINGLE_NOTIFIER_BASE_WEAK_XMPP_CLIENT_H_ | 10 #define JINGLE_NOTIFIER_BASE_WEAK_XMPP_CLIENT_H_ |
(...skipping 22 matching lines...) Expand all Loading... |
33 // Returns a weak pointer that is invalidated when the XmppClient | 33 // Returns a weak pointer that is invalidated when the XmppClient |
34 // becomes invalid to use. | 34 // becomes invalid to use. |
35 base::WeakPtr<WeakXmppClient> AsWeakPtr(); | 35 base::WeakPtr<WeakXmppClient> AsWeakPtr(); |
36 | 36 |
37 // Invalidates all weak pointers to this object. (This method is | 37 // Invalidates all weak pointers to this object. (This method is |
38 // necessary as calling Abort() does not always lead to Stop() being | 38 // necessary as calling Abort() does not always lead to Stop() being |
39 // called, so it's not a reliable way to cause an invalidation.) | 39 // called, so it's not a reliable way to cause an invalidation.) |
40 void Invalidate(); | 40 void Invalidate(); |
41 | 41 |
42 protected: | 42 protected: |
43 virtual void Stop() OVERRIDE; | 43 virtual void Stop() override; |
44 | 44 |
45 private: | 45 private: |
46 // We use our own WeakPtrFactory instead of inheriting from | 46 // We use our own WeakPtrFactory instead of inheriting from |
47 // SupportsWeakPtr since we want to invalidate in other places | 47 // SupportsWeakPtr since we want to invalidate in other places |
48 // besides the destructor. | 48 // besides the destructor. |
49 base::WeakPtrFactory<WeakXmppClient> weak_ptr_factory_; | 49 base::WeakPtrFactory<WeakXmppClient> weak_ptr_factory_; |
50 | 50 |
51 DISALLOW_COPY_AND_ASSIGN(WeakXmppClient); | 51 DISALLOW_COPY_AND_ASSIGN(WeakXmppClient); |
52 }; | 52 }; |
53 | 53 |
54 } // namespace notifier | 54 } // namespace notifier |
55 | 55 |
56 #endif // JINGLE_NOTIFIER_BASE_WEAK_XMPP_CLIENT_H_ | 56 #endif // JINGLE_NOTIFIER_BASE_WEAK_XMPP_CLIENT_H_ |
OLD | NEW |