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 #ifndef REMOTING_PROTOCOL_LIBJINGLE_TRANSPORT_FACTORY_H_ | 5 #ifndef REMOTING_PROTOCOL_LIBJINGLE_TRANSPORT_FACTORY_H_ |
6 #define REMOTING_PROTOCOL_LIBJINGLE_TRANSPORT_FACTORY_H_ | 6 #define REMOTING_PROTOCOL_LIBJINGLE_TRANSPORT_FACTORY_H_ |
7 | 7 |
8 #include <list> | 8 #include <list> |
9 | 9 |
10 #include "base/callback_forward.h" | 10 #include "base/callback_forward.h" |
11 #include "remoting/protocol/network_settings.h" | 11 #include "remoting/protocol/network_settings.h" |
12 #include "remoting/protocol/transport.h" | 12 #include "remoting/protocol/transport.h" |
13 | 13 |
14 namespace cricket { | 14 namespace cricket { |
15 class HttpPortAllocatorBase; | 15 class HttpPortAllocatorBase; |
16 class PortAllocator; | |
17 } // namespace cricket | 16 } // namespace cricket |
18 | 17 |
19 namespace net { | |
20 class URLRequestContextGetter; | |
21 } // namespace net | |
22 | |
23 namespace rtc { | 18 namespace rtc { |
24 class NetworkManager; | |
25 class PacketSocketFactory; | |
26 class SocketAddress; | 19 class SocketAddress; |
27 } // namespace rtc | 20 } // namespace rtc |
28 | 21 |
29 namespace remoting { | 22 namespace remoting { |
30 | 23 |
31 class SignalStrategy; | 24 class SignalStrategy; |
32 class JingleInfoRequest; | 25 class JingleInfoRequest; |
33 | 26 |
34 namespace protocol { | 27 namespace protocol { |
35 | 28 |
36 class LibjingleTransportFactory : public TransportFactory { | 29 // TODO(sergeyu): Remove this class and move all code to IceTransportFactory. |
| 30 class LibjingleTransportFactory { |
37 public: | 31 public: |
38 // |signal_strategy| must outlive LibjingleTransportFactory. Need to use | 32 // |signal_strategy| must outlive LibjingleTransportFactory. Need to use |
39 // cricket::HttpPortAllocatorBase pointer for the |port_allocator|, so that it | 33 // cricket::HttpPortAllocatorBase pointer for the |port_allocator|, so that it |
40 // is possible to configure |port_allocator| with STUN/Relay addresses. | 34 // is possible to configure |port_allocator| with STUN/Relay addresses. |
41 LibjingleTransportFactory( | 35 LibjingleTransportFactory( |
42 SignalStrategy* signal_strategy, | 36 SignalStrategy* signal_strategy, |
43 scoped_ptr<cricket::HttpPortAllocatorBase> port_allocator, | 37 scoped_ptr<cricket::HttpPortAllocatorBase> port_allocator, |
44 const NetworkSettings& network_settings, | 38 const NetworkSettings& network_settings, |
45 TransportRole role); | 39 TransportRole role); |
| 40 ~LibjingleTransportFactory(); |
46 | 41 |
47 ~LibjingleTransportFactory() override; | 42 void PrepareTokens(); |
48 | 43 scoped_ptr<Transport> CreateTransport(); |
49 // TransportFactory interface. | |
50 void PrepareTokens() override; | |
51 scoped_ptr<Transport> CreateTransport() override; | |
52 | 44 |
53 private: | 45 private: |
54 void EnsureFreshJingleInfo(); | 46 void EnsureFreshJingleInfo(); |
55 void OnJingleInfo(const std::string& relay_token, | 47 void OnJingleInfo(const std::string& relay_token, |
56 const std::vector<std::string>& relay_hosts, | 48 const std::vector<std::string>& relay_hosts, |
57 const std::vector<rtc::SocketAddress>& stun_hosts); | 49 const std::vector<rtc::SocketAddress>& stun_hosts); |
58 | 50 |
59 SignalStrategy* signal_strategy_; | 51 SignalStrategy* signal_strategy_; |
60 scoped_ptr<cricket::HttpPortAllocatorBase> port_allocator_; | 52 scoped_ptr<cricket::HttpPortAllocatorBase> port_allocator_; |
61 NetworkSettings network_settings_; | 53 NetworkSettings network_settings_; |
62 TransportRole role_; | 54 TransportRole role_; |
63 | 55 |
64 base::TimeTicks last_jingle_info_update_time_; | 56 base::TimeTicks last_jingle_info_update_time_; |
65 scoped_ptr<JingleInfoRequest> jingle_info_request_; | 57 scoped_ptr<JingleInfoRequest> jingle_info_request_; |
66 | 58 |
67 // When there is an active |jingle_info_request_| stores list of callbacks to | 59 // When there is an active |jingle_info_request_| stores list of callbacks to |
68 // be called once the |jingle_info_request_| is finished. | 60 // be called once the |jingle_info_request_| is finished. |
69 std::list<base::Closure> on_jingle_info_callbacks_; | 61 std::list<base::Closure> on_jingle_info_callbacks_; |
70 | 62 |
71 DISALLOW_COPY_AND_ASSIGN(LibjingleTransportFactory); | 63 DISALLOW_COPY_AND_ASSIGN(LibjingleTransportFactory); |
72 }; | 64 }; |
73 | 65 |
74 } // namespace protocol | 66 } // namespace protocol |
75 } // namespace remoting | 67 } // namespace remoting |
76 | 68 |
77 #endif // REMOTING_PROTOCOL_LIBJINGLE_TRANSPORT_FACTORY_H_ | 69 #endif // REMOTING_PROTOCOL_LIBJINGLE_TRANSPORT_FACTORY_H_ |
OLD | NEW |