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