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 // 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 "base/observer_list.h" |
19 #include "base/timer.h" | 19 #include "base/timer.h" |
20 #include "base/threading/non_thread_safe.h" | 20 #include "base/threading/non_thread_safe.h" |
21 #include "third_party/libjingle/source/talk/base/sigslot.h" | 21 #include "third_party/libjingle/source/talk/base/sigslot.h" |
22 #include "third_party/libjingle/source/talk/xmpp/xmppclient.h" | 22 #include "third_party/libjingle/source/talk/xmpp/xmppclient.h" |
23 | 23 |
| 24 namespace net { |
| 25 class URLRequestContextGetter; |
| 26 } // namespace net |
| 27 |
| 28 namespace talk_base { |
| 29 class TaskRunner; |
| 30 } // namespace talk_base |
| 31 |
24 namespace remoting { | 32 namespace remoting { |
25 | 33 |
26 class JingleThread; | 34 class JingleThread; |
27 | 35 |
28 class XmppSignalStrategy : public base::NonThreadSafe, | 36 class XmppSignalStrategy : public base::NonThreadSafe, |
29 public SignalStrategy, | 37 public SignalStrategy, |
30 public buzz::XmppStanzaHandler, | 38 public buzz::XmppStanzaHandler, |
31 public sigslot::has_slots<> { | 39 public sigslot::has_slots<> { |
32 public: | 40 public: |
33 XmppSignalStrategy(JingleThread* thread, | 41 XmppSignalStrategy( |
34 const std::string& username, | 42 scoped_refptr<net::URLRequestContextGetter> request_context_getter, |
35 const std::string& auth_token, | 43 const std::string& username, |
36 const std::string& auth_token_service); | 44 const std::string& auth_token, |
| 45 const std::string& auth_token_service); |
37 virtual ~XmppSignalStrategy(); | 46 virtual ~XmppSignalStrategy(); |
38 | 47 |
39 // SignalStrategy interface. | 48 // SignalStrategy interface. |
40 virtual void Connect() OVERRIDE; | 49 virtual void Connect() OVERRIDE; |
41 virtual void Disconnect() OVERRIDE; | 50 virtual void Disconnect() OVERRIDE; |
42 virtual State GetState() const OVERRIDE; | 51 virtual State GetState() const OVERRIDE; |
43 virtual Error GetError() const OVERRIDE; | 52 virtual Error GetError() const OVERRIDE; |
44 virtual std::string GetLocalJid() const OVERRIDE; | 53 virtual std::string GetLocalJid() const OVERRIDE; |
45 virtual void AddListener(Listener* listener) OVERRIDE; | 54 virtual void AddListener(Listener* listener) OVERRIDE; |
46 virtual void RemoveListener(Listener* listener) OVERRIDE; | 55 virtual void RemoveListener(Listener* listener) OVERRIDE; |
(...skipping 16 matching lines...) Expand all Loading... |
63 | 72 |
64 private: | 73 private: |
65 static buzz::PreXmppAuth* CreatePreXmppAuth( | 74 static buzz::PreXmppAuth* CreatePreXmppAuth( |
66 const buzz::XmppClientSettings& settings); | 75 const buzz::XmppClientSettings& settings); |
67 | 76 |
68 void OnConnectionStateChanged(buzz::XmppEngine::State state); | 77 void OnConnectionStateChanged(buzz::XmppEngine::State state); |
69 void SetState(State new_state); | 78 void SetState(State new_state); |
70 | 79 |
71 void SendKeepAlive(); | 80 void SendKeepAlive(); |
72 | 81 |
73 JingleThread* thread_; | 82 scoped_refptr<net::URLRequestContextGetter> request_context_getter_; |
74 | |
75 std::string username_; | 83 std::string username_; |
76 std::string auth_token_; | 84 std::string auth_token_; |
77 std::string auth_token_service_; | 85 std::string auth_token_service_; |
78 std::string resource_name_; | 86 std::string resource_name_; |
| 87 scoped_ptr<talk_base::TaskRunner> task_runner_; |
79 buzz::XmppClient* xmpp_client_; | 88 buzz::XmppClient* xmpp_client_; |
80 | 89 |
81 State state_; | 90 State state_; |
82 Error error_; | 91 Error error_; |
83 | 92 |
84 ObserverList<Listener, true> listeners_; | 93 ObserverList<Listener, true> listeners_; |
85 | 94 |
86 base::RepeatingTimer<XmppSignalStrategy> keep_alive_timer_; | 95 base::RepeatingTimer<XmppSignalStrategy> keep_alive_timer_; |
87 | 96 |
88 DISALLOW_COPY_AND_ASSIGN(XmppSignalStrategy); | 97 DISALLOW_COPY_AND_ASSIGN(XmppSignalStrategy); |
89 }; | 98 }; |
90 | 99 |
91 } // namespace remoting | 100 } // namespace remoting |
92 | 101 |
93 #endif // REMOTING_JINGLE_GLUE_XMPP_SIGNAL_STRATEGY_H_ | 102 #endif // REMOTING_JINGLE_GLUE_XMPP_SIGNAL_STRATEGY_H_ |
OLD | NEW |