Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(183)

Side by Side Diff: jingle/notifier/base/weak_xmpp_client.h

Issue 8589003: Add OVERRIDE to jingle/. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: includes Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « jingle/notifier/base/task_pump.h ('k') | jingle/notifier/base/xmpp_client_socket_factory.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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_
11 #pragma once 11 #pragma once
12 12
13 #include "base/basictypes.h" 13 #include "base/basictypes.h"
14 #include "base/compiler_specific.h"
14 #include "base/memory/weak_ptr.h" 15 #include "base/memory/weak_ptr.h"
15 #include "base/threading/non_thread_safe.h" 16 #include "base/threading/non_thread_safe.h"
16 #include "talk/xmpp/xmppclient.h" 17 #include "talk/xmpp/xmppclient.h"
17 18
18 namespace talk_base { 19 namespace talk_base {
19 class TaskParent; 20 class TaskParent;
20 } // namespace 21 } // namespace
21 22
22 namespace notifier { 23 namespace notifier {
23 24
24 // buzz::XmppClient's destructor isn't marked virtual, but it inherits 25 // buzz::XmppClient's destructor isn't marked virtual, but it inherits
25 // from talk_base::Task, whose destructor *is* marked virtual, so we 26 // from talk_base::Task, whose destructor *is* marked virtual, so we
26 // can safely inherit from it. 27 // can safely inherit from it.
27 class WeakXmppClient : public buzz::XmppClient { 28 class WeakXmppClient : public buzz::XmppClient {
28 public: 29 public:
29 explicit WeakXmppClient(talk_base::TaskParent* parent); 30 explicit WeakXmppClient(talk_base::TaskParent* parent);
30 31
31 virtual ~WeakXmppClient(); 32 virtual ~WeakXmppClient();
32 33
33 // Returns a weak pointer that is invalidated when the XmppClient 34 // Returns a weak pointer that is invalidated when the XmppClient
34 // becomes invalid to use. 35 // becomes invalid to use.
35 base::WeakPtr<WeakXmppClient> AsWeakPtr(); 36 base::WeakPtr<WeakXmppClient> AsWeakPtr();
36 37
37 // Invalidates all weak pointers to this object. (This method is 38 // Invalidates all weak pointers to this object. (This method is
38 // necessary as calling Abort() does not always lead to Stop() being 39 // necessary as calling Abort() does not always lead to Stop() being
39 // called, so it's not a reliable way to cause an invalidation.) 40 // called, so it's not a reliable way to cause an invalidation.)
40 void Invalidate(); 41 void Invalidate();
41 42
42 protected: 43 protected:
43 virtual void Stop(); 44 virtual void Stop() OVERRIDE;
44 45
45 private: 46 private:
46 base::NonThreadSafe non_thread_safe_; 47 base::NonThreadSafe non_thread_safe_;
47 // We use our own WeakPtrFactory instead of inheriting from 48 // We use our own WeakPtrFactory instead of inheriting from
48 // SupportsWeakPtr since we want to invalidate in other places 49 // SupportsWeakPtr since we want to invalidate in other places
49 // besides the destructor. 50 // besides the destructor.
50 base::WeakPtrFactory<WeakXmppClient> weak_ptr_factory_; 51 base::WeakPtrFactory<WeakXmppClient> weak_ptr_factory_;
51 52
52 DISALLOW_COPY_AND_ASSIGN(WeakXmppClient); 53 DISALLOW_COPY_AND_ASSIGN(WeakXmppClient);
53 }; 54 };
54 55
55 } // namespace notifier 56 } // namespace notifier
56 57
57 #endif // JINGLE_NOTIFIER_BASE_WEAK_XMPP_CLIENT_H_ 58 #endif // JINGLE_NOTIFIER_BASE_WEAK_XMPP_CLIENT_H_
OLDNEW
« no previous file with comments | « jingle/notifier/base/task_pump.h ('k') | jingle/notifier/base/xmpp_client_socket_factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698