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

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

Issue 958703003: Remove dependency on XMPP implementation in WebRTC (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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
6 // STUN/ICE for jingle via a direct XMPP connection.
7 //
8 // This class is not threadsafe.
9
10 #ifndef REMOTING_SIGNALING_XMPP_SIGNAL_STRATEGY_H_ 5 #ifndef REMOTING_SIGNALING_XMPP_SIGNAL_STRATEGY_H_
11 #define REMOTING_SIGNALING_XMPP_SIGNAL_STRATEGY_H_ 6 #define REMOTING_SIGNALING_XMPP_SIGNAL_STRATEGY_H_
12 7
13 #include "remoting/signaling/signal_strategy.h" 8 #include "remoting/signaling/signal_strategy.h"
14 9
15 #include <vector>
16
17 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
18 #include "base/observer_list.h" 11 #include "base/memory/ref_counted.h"
19 #include "base/threading/non_thread_safe.h" 12 #include "base/memory/scoped_ptr.h"
20 #include "base/timer/timer.h"
21 #include "third_party/webrtc/base/sigslot.h"
22 #include "third_party/webrtc/libjingle/xmpp/xmppclient.h"
23 13
24 namespace net { 14 namespace net {
25 class ClientSocketFactory; 15 class ClientSocketFactory;
26 class URLRequestContextGetter; 16 class URLRequestContextGetter;
27 } // namespace net 17 } // namespace net
28 18
29 namespace rtc {
30 class TaskRunner;
31 } // namespace rtc
32
33 namespace remoting { 19 namespace remoting {
34 20
35 class JingleThread; 21 // XmppSignalStrategy implements SignalStrategy using direct XMPP connection.
36 22 class XmppSignalStrategy : public SignalStrategy {
37 class XmppSignalStrategy : public base::NonThreadSafe,
38 public SignalStrategy,
39 public buzz::XmppStanzaHandler,
40 public sigslot::has_slots<> {
41 public: 23 public:
42 // XMPP Server configuration for XmppSignalStrategy. 24 // XMPP Server configuration for XmppSignalStrategy.
43 struct XmppServerConfig { 25 struct XmppServerConfig {
44 XmppServerConfig(); 26 XmppServerConfig();
45 ~XmppServerConfig(); 27 ~XmppServerConfig();
46 28
47 std::string host; 29 std::string host;
48 int port; 30 int port;
49 bool use_tls; 31 bool use_tls;
50 32
(...skipping 12 matching lines...) Expand all
63 void Connect() override; 45 void Connect() override;
64 void Disconnect() override; 46 void Disconnect() override;
65 State GetState() const override; 47 State GetState() const override;
66 Error GetError() const override; 48 Error GetError() const override;
67 std::string GetLocalJid() const override; 49 std::string GetLocalJid() const override;
68 void AddListener(Listener* listener) override; 50 void AddListener(Listener* listener) override;
69 void RemoveListener(Listener* listener) override; 51 void RemoveListener(Listener* listener) override;
70 bool SendStanza(scoped_ptr<buzz::XmlElement> stanza) override; 52 bool SendStanza(scoped_ptr<buzz::XmlElement> stanza) override;
71 std::string GetNextId() override; 53 std::string GetNextId() override;
72 54
73 // buzz::XmppStanzaHandler interface.
74 bool HandleStanza(const buzz::XmlElement* stanza) override;
75
76 // This method is used to update the auth info (for example when the OAuth 55 // This method is used to update the auth info (for example when the OAuth
77 // access token is renewed). It is OK to call this even when we are in the 56 // access token is renewed). It is OK to call this even when we are in the
78 // CONNECTED state. It will be used on the next Connect() call. 57 // CONNECTED state. It will be used on the next Connect() call.
79 void SetAuthInfo(const std::string& username, 58 void SetAuthInfo(const std::string& username,
80 const std::string& auth_token, 59 const std::string& auth_token,
81 const std::string& auth_service); 60 const std::string& auth_service);
82 61
83 // Use this method to override the default resource name used (optional). 62 private:
84 // This will be used on the next Connect() call. 63 class Core;
85 void SetResourceName(const std::string& resource_name);
86 64
87 private: 65 scoped_ptr<Core> core_;
88 static buzz::PreXmppAuth* CreatePreXmppAuth(
89 const buzz::XmppClientSettings& settings);
90
91 void OnConnectionStateChanged(buzz::XmppEngine::State state);
92 void SetState(State new_state);
93
94 void SendKeepAlive();
95
96 net::ClientSocketFactory* socket_factory_;
97 scoped_refptr<net::URLRequestContextGetter> request_context_getter_;
98 std::string resource_name_;
99 scoped_ptr<rtc::TaskRunner> task_runner_;
100 buzz::XmppClient* xmpp_client_;
101 XmppServerConfig xmpp_server_config_;
102
103 State state_;
104 Error error_;
105
106 ObserverList<Listener, true> listeners_;
107
108 base::RepeatingTimer<XmppSignalStrategy> keep_alive_timer_;
109 66
110 DISALLOW_COPY_AND_ASSIGN(XmppSignalStrategy); 67 DISALLOW_COPY_AND_ASSIGN(XmppSignalStrategy);
111 }; 68 };
112 69
113 } // namespace remoting 70 } // namespace remoting
114 71
115 #endif // REMOTING_SIGNALING_XMPP_SIGNAL_STRATEGY_H_ 72 #endif // REMOTING_SIGNALING_XMPP_SIGNAL_STRATEGY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698