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

Side by Side Diff: remoting/jingle_glue/xmpp_signal_strategy.h

Issue 9005034: Refactor SignalStrategy so that it can be reused for multiple connections. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: - Created 8 years, 11 months 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 | « remoting/jingle_glue/signal_strategy.h ('k') | remoting/jingle_glue/xmpp_signal_strategy.cc » ('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 // The XmppSignalStrategy encapsulates all the logic to perform the signaling 5 // The XmppSignalStrategy encapsulates all the logic to perform the signaling
6 // STUN/ICE for jingle via a direct XMPP connection. 6 // STUN/ICE for jingle via a direct XMPP connection.
7 // 7 //
8 // This class is not threadsafe. 8 // This class is not threadsafe.
9 9
10 #ifndef REMOTING_JINGLE_GLUE_XMPP_SIGNAL_STRATEGY_H_ 10 #ifndef REMOTING_JINGLE_GLUE_XMPP_SIGNAL_STRATEGY_H_
11 #define REMOTING_JINGLE_GLUE_XMPP_SIGNAL_STRATEGY_H_ 11 #define REMOTING_JINGLE_GLUE_XMPP_SIGNAL_STRATEGY_H_
12 12
13 #include "remoting/jingle_glue/signal_strategy.h" 13 #include "remoting/jingle_glue/signal_strategy.h"
14 14
15 #include <vector> 15 #include <vector>
16 16
17 #include "base/compiler_specific.h" 17 #include "base/compiler_specific.h"
18 #include "base/observer_list.h"
18 #include "third_party/libjingle/source/talk/base/sigslot.h" 19 #include "third_party/libjingle/source/talk/base/sigslot.h"
19 #include "third_party/libjingle/source/talk/xmpp/xmppclient.h" 20 #include "third_party/libjingle/source/talk/xmpp/xmppclient.h"
20 21
21 namespace remoting { 22 namespace remoting {
22 23
23 class JingleThread; 24 class JingleThread;
24 25
25 class XmppSignalStrategy : public SignalStrategy, 26 class XmppSignalStrategy : public SignalStrategy,
26 public buzz::XmppStanzaHandler, 27 public buzz::XmppStanzaHandler,
27 public sigslot::has_slots<> { 28 public sigslot::has_slots<> {
28 public: 29 public:
29 XmppSignalStrategy(JingleThread* thread, 30 XmppSignalStrategy(JingleThread* thread,
30 const std::string& username, 31 const std::string& username,
31 const std::string& auth_token, 32 const std::string& auth_token,
32 const std::string& auth_token_service); 33 const std::string& auth_token_service);
33 virtual ~XmppSignalStrategy(); 34 virtual ~XmppSignalStrategy();
34 35
35 // SignalStrategy interface. 36 // SignalStrategy interface.
36 virtual void Init(StatusObserver* observer) OVERRIDE; 37 virtual void Connect() OVERRIDE;
37 virtual void Close() OVERRIDE; 38 virtual void Disconnect() OVERRIDE;
39 virtual State GetState() const OVERRIDE;
40 virtual std::string GetLocalJid() const OVERRIDE;
38 virtual void AddListener(Listener* listener) OVERRIDE; 41 virtual void AddListener(Listener* listener) OVERRIDE;
39 virtual void RemoveListener(Listener* listener) OVERRIDE; 42 virtual void RemoveListener(Listener* listener) OVERRIDE;
40 virtual bool SendStanza(buzz::XmlElement* stanza) OVERRIDE; 43 virtual bool SendStanza(buzz::XmlElement* stanza) OVERRIDE;
41 virtual std::string GetNextId() OVERRIDE; 44 virtual std::string GetNextId() OVERRIDE;
42 45
43 // buzz::XmppStanzaHandler interface. 46 // buzz::XmppStanzaHandler interface.
44 virtual bool HandleStanza(const buzz::XmlElement* stanza) OVERRIDE; 47 virtual bool HandleStanza(const buzz::XmlElement* stanza) OVERRIDE;
45 48
46 private: 49 private:
47 void OnConnectionStateChanged(buzz::XmppEngine::State state); 50 void OnConnectionStateChanged(buzz::XmppEngine::State state);
48 static buzz::PreXmppAuth* CreatePreXmppAuth( 51 static buzz::PreXmppAuth* CreatePreXmppAuth(
49 const buzz::XmppClientSettings& settings); 52 const buzz::XmppClientSettings& settings);
50 53
51 JingleThread* thread_; 54 JingleThread* thread_;
52 55
53 std::string username_; 56 std::string username_;
54 std::string auth_token_; 57 std::string auth_token_;
55 std::string auth_token_service_; 58 std::string auth_token_service_;
56 buzz::XmppClient* xmpp_client_; 59 buzz::XmppClient* xmpp_client_;
57 60
58 StatusObserver* observer_; 61 State state_;
59 std::vector<Listener*> listeners_;
60 62
63 ObserverList<Listener> listeners_;
61 64
62 DISALLOW_COPY_AND_ASSIGN(XmppSignalStrategy); 65 DISALLOW_COPY_AND_ASSIGN(XmppSignalStrategy);
63 }; 66 };
64 67
65 } // namespace remoting 68 } // namespace remoting
66 69
67 #endif // REMOTING_JINGLE_GLUE_XMPP_SIGNAL_STRATEGY_H_ 70 #endif // REMOTING_JINGLE_GLUE_XMPP_SIGNAL_STRATEGY_H_
OLDNEW
« no previous file with comments | « remoting/jingle_glue/signal_strategy.h ('k') | remoting/jingle_glue/xmpp_signal_strategy.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698