Reland r247589: <webview>: Fix text selection features in mac.
[chromium-blink-merge.git] / remoting / protocol / libjingle_transport_factory.h
blob637410c97c3ba4666752a927c36b0d75ad4afd0b
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
3 // found in the LICENSE file.
5 #ifndef REMOTING_PROTOCOL_LIBJINGLE_TRANSPORT_FACTORY_H_
6 #define REMOTING_PROTOCOL_LIBJINGLE_TRANSPORT_FACTORY_H_
8 #include <list>
10 #include "base/callback_forward.h"
11 #include "remoting/jingle_glue/network_settings.h"
12 #include "remoting/protocol/transport.h"
14 namespace cricket {
15 class HttpPortAllocatorBase;
16 class PortAllocator;
17 } // namespace cricket
19 namespace net {
20 class URLRequestContextGetter;
21 } // namespace net
23 namespace talk_base {
24 class NetworkManager;
25 class PacketSocketFactory;
26 class SocketAddress;
27 } // namespace talk_base
29 namespace remoting {
31 class SignalStrategy;
32 class JingleInfoRequest;
34 namespace protocol {
36 class LibjingleTransportFactory : public TransportFactory {
37 public:
38 // |signal_strategy| must outlive LibjingleTransportFactory. Need to use
39 // cricket::HttpPortAllocatorBase pointer for the |port_allocator|, so that it
40 // is possible to configure |port_allocator| with STUN/Relay addresses.
41 LibjingleTransportFactory(
42 SignalStrategy* signal_strategy,
43 scoped_ptr<cricket::HttpPortAllocatorBase> port_allocator,
44 const NetworkSettings& network_settings);
46 virtual ~LibjingleTransportFactory();
48 // TransportFactory interface.
49 virtual void PrepareTokens() OVERRIDE;
50 virtual scoped_ptr<StreamTransport> CreateStreamTransport() OVERRIDE;
51 virtual scoped_ptr<DatagramTransport> CreateDatagramTransport() OVERRIDE;
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);
59 SignalStrategy* signal_strategy_;
60 scoped_ptr<cricket::HttpPortAllocatorBase> port_allocator_;
61 NetworkSettings network_settings_;
63 base::TimeTicks last_jingle_info_update_time_;
64 scoped_ptr<JingleInfoRequest> jingle_info_request_;
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_;
70 DISALLOW_COPY_AND_ASSIGN(LibjingleTransportFactory);
73 } // namespace protocol
74 } // namespace remoting
76 #endif // REMOTING_PROTOCOL_LIBJINGLE_TRANSPORT_FACTORY_H_