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

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 11 matching lines...) Expand all
62 void Connect() override; 44 void Connect() override;
63 void Disconnect() override; 45 void Disconnect() override;
64 State GetState() const override; 46 State GetState() const override;
65 Error GetError() const override; 47 Error GetError() const override;
66 std::string GetLocalJid() const override; 48 std::string GetLocalJid() const override;
67 void AddListener(Listener* listener) override; 49 void AddListener(Listener* listener) override;
68 void RemoveListener(Listener* listener) override; 50 void RemoveListener(Listener* listener) override;
69 bool SendStanza(scoped_ptr<buzz::XmlElement> stanza) override; 51 bool SendStanza(scoped_ptr<buzz::XmlElement> stanza) override;
70 std::string GetNextId() override; 52 std::string GetNextId() override;
71 53
72 // buzz::XmppStanzaHandler interface.
73 bool HandleStanza(const buzz::XmlElement* stanza) override;
74
75 // This method is used to update the auth info (for example when the OAuth 54 // This method is used to update the auth info (for example when the OAuth
76 // access token is renewed). It is OK to call this even when we are in the 55 // access token is renewed). It is OK to call this even when we are in the
77 // CONNECTED state. It will be used on the next Connect() call. 56 // CONNECTED state. It will be used on the next Connect() call.
78 void SetAuthInfo(const std::string& username, 57 void SetAuthInfo(const std::string& username,
79 const std::string& auth_token); 58 const std::string& auth_token);
80 59
81 // Use this method to override the default resource name used (optional). 60 private:
82 // This will be used on the next Connect() call. 61 class Core;
83 void SetResourceName(const std::string& resource_name);
84 62
85 private: 63 scoped_ptr<Core> core_;
86 static buzz::PreXmppAuth* CreatePreXmppAuth(
87 const buzz::XmppClientSettings& settings);
88
89 void OnConnectionStateChanged(buzz::XmppEngine::State state);
90 void SetState(State new_state);
91
92 void SendKeepAlive();
93
94 net::ClientSocketFactory* socket_factory_;
95 scoped_refptr<net::URLRequestContextGetter> request_context_getter_;
96 std::string resource_name_;
97 scoped_ptr<rtc::TaskRunner> task_runner_;
98 buzz::XmppClient* xmpp_client_;
99 XmppServerConfig xmpp_server_config_;
100
101 State state_;
102 Error error_;
103
104 ObserverList<Listener, true> listeners_;
105
106 base::RepeatingTimer<XmppSignalStrategy> keep_alive_timer_;
107 64
108 DISALLOW_COPY_AND_ASSIGN(XmppSignalStrategy); 65 DISALLOW_COPY_AND_ASSIGN(XmppSignalStrategy);
109 }; 66 };
110 67
111 } // namespace remoting 68 } // namespace remoting
112 69
113 #endif // REMOTING_SIGNALING_XMPP_SIGNAL_STRATEGY_H_ 70 #endif // REMOTING_SIGNALING_XMPP_SIGNAL_STRATEGY_H_
OLDNEW
« no previous file with comments | « remoting/signaling/xmpp_login_handler_unittest.cc ('k') | remoting/signaling/xmpp_signal_strategy.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698