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. 4 5 #ifndef REMOTING_PROTOCOL_LIBJINGLE_TRANSPORT_FACTORY_H_ 6 #define REMOTING_PROTOCOL_LIBJINGLE_TRANSPORT_FACTORY_H_ 7 8 #include "remoting/protocol/transport.h" 9 10 namespace cricket { 11 class HttpPortAllocatorBase; 12 class PortAllocator; 13 } // namespace cricket 14 15 namespace net { 16 class URLRequestContextGetter; 17 } // namespace net 18 19 namespace talk_base { 20 class NetworkManager; 21 class PacketSocketFactory; 22 } // namespace talk_base 23 24 namespace remoting { 25 26 struct NetworkSettings; 27 28 namespace protocol { 29 30 class LibjingleTransportFactory : public TransportFactory { 31 public: 32 // Creates an instance of the class using ChromiumPortAllocator. 33 // Must be called from an IO thread. 34 static scoped_ptr<LibjingleTransportFactory> Create( 35 const NetworkSettings& network_settings, 36 const scoped_refptr<net::URLRequestContextGetter>& 37 url_request_context_getter); 38 39 // Need to use cricket::HttpPortAllocatorBase pointer for the 40 // |port_allocator|, so that it is possible to configure 41 // |port_allocator| with STUN/Relay addresses. 42 // TODO(sergeyu): Reconsider this design. 43 LibjingleTransportFactory( 44 scoped_ptr<cricket::HttpPortAllocatorBase> port_allocator, 45 bool incoming_only); 46 47 // Creates BasicNetworkManager, ChromiumPacketSocketFactory and 48 // BasicPortAllocator. 49 LibjingleTransportFactory(); 50 51 virtual ~LibjingleTransportFactory(); 52 53 // TransportFactory interface. 54 virtual void SetTransportConfig(const TransportConfig& config) OVERRIDE; 55 virtual scoped_ptr<StreamTransport> CreateStreamTransport() OVERRIDE; 56 virtual scoped_ptr<DatagramTransport> CreateDatagramTransport() OVERRIDE; 57 58 private: 59 scoped_ptr<talk_base::NetworkManager> network_manager_; 60 scoped_ptr<talk_base::PacketSocketFactory> socket_factory_; 61 // Points to the same port allocator as |port_allocator_| or NULL if 62 // |port_allocator_| is not HttpPortAllocatorBase. 63 cricket::HttpPortAllocatorBase* http_port_allocator_; 64 scoped_ptr<cricket::PortAllocator> port_allocator_; 65 bool incoming_only_; 66 67 DISALLOW_COPY_AND_ASSIGN(LibjingleTransportFactory); 68 }; 69 70 } // namespace protocol 71 } // namespace remoting 72 73 #endif // REMOTING_PROTOCOL_LIBJINGLE_TRANSPORT_FACTORY_H_ 74