| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_CHROMIUM_PORT_ALLOCATOR_H_ | 5 #ifndef REMOTING_PROTOCOL_CHROMIUM_PORT_ALLOCATOR_H_ |
| 6 #define REMOTING_PROTOCOL_CHROMIUM_PORT_ALLOCATOR_H_ | 6 #define REMOTING_PROTOCOL_CHROMIUM_PORT_ALLOCATOR_H_ |
| 7 | 7 |
| 8 #include <set> | 8 #include <set> |
| 9 | 9 |
| 10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| 11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "net/url_request/url_request_context_getter.h" | 12 #include "remoting/protocol/port_allocator_factory.h" |
| 13 #include "third_party/webrtc/p2p/client/httpportallocator.h" | 13 #include "third_party/webrtc/p2p/client/httpportallocator.h" |
| 14 | 14 |
| 15 namespace net { |
| 16 class URLRequestContextGetter; |
| 17 } // namespace net |
| 18 |
| 15 namespace remoting { | 19 namespace remoting { |
| 16 namespace protocol { | 20 namespace protocol { |
| 17 | 21 |
| 18 struct NetworkSettings; | 22 struct NetworkSettings; |
| 19 | 23 |
| 20 // An implementation of cricket::PortAllocator for libjingle that | 24 // An implementation of cricket::PortAllocator that uses Chromium's network |
| 21 // uses Chromium's network stack and configures itself according | 25 // stack. |
| 22 // to the specified NetworkSettings. | |
| 23 class ChromiumPortAllocator : public cricket::HttpPortAllocatorBase { | 26 class ChromiumPortAllocator : public cricket::HttpPortAllocatorBase { |
| 24 public: | 27 public: |
| 25 static scoped_ptr<ChromiumPortAllocator> Create( | 28 static scoped_ptr<ChromiumPortAllocator> Create( |
| 26 const scoped_refptr<net::URLRequestContextGetter>& url_context, | 29 const scoped_refptr<net::URLRequestContextGetter>& url_context); |
| 27 const NetworkSettings& network_settings); | |
| 28 | 30 |
| 29 ~ChromiumPortAllocator() override; | 31 ~ChromiumPortAllocator() override; |
| 30 | 32 |
| 31 // cricket::HttpPortAllocatorBase overrides. | 33 // cricket::HttpPortAllocatorBase overrides. |
| 32 cricket::PortAllocatorSession* CreateSessionInternal( | 34 cricket::PortAllocatorSession* CreateSessionInternal( |
| 33 const std::string& content_name, | 35 const std::string& content_name, |
| 34 int component, | 36 int component, |
| 35 const std::string& ice_username_fragment, | 37 const std::string& ice_username_fragment, |
| 36 const std::string& ice_password) override; | 38 const std::string& ice_password) override; |
| 37 | 39 |
| 38 private: | 40 private: |
| 39 ChromiumPortAllocator( | 41 ChromiumPortAllocator( |
| 40 const scoped_refptr<net::URLRequestContextGetter>& url_context, | 42 const scoped_refptr<net::URLRequestContextGetter>& url_context, |
| 41 scoped_ptr<rtc::NetworkManager> network_manager, | 43 scoped_ptr<rtc::NetworkManager> network_manager, |
| 42 scoped_ptr<rtc::PacketSocketFactory> socket_factory); | 44 scoped_ptr<rtc::PacketSocketFactory> socket_factory); |
| 43 | 45 |
| 44 scoped_refptr<net::URLRequestContextGetter> url_context_; | 46 scoped_refptr<net::URLRequestContextGetter> url_context_; |
| 45 scoped_ptr<rtc::NetworkManager> network_manager_; | 47 scoped_ptr<rtc::NetworkManager> network_manager_; |
| 46 scoped_ptr<rtc::PacketSocketFactory> socket_factory_; | 48 scoped_ptr<rtc::PacketSocketFactory> socket_factory_; |
| 47 | 49 |
| 48 DISALLOW_COPY_AND_ASSIGN(ChromiumPortAllocator); | 50 DISALLOW_COPY_AND_ASSIGN(ChromiumPortAllocator); |
| 49 }; | 51 }; |
| 50 | 52 |
| 53 class ChromiumPortAllocatorFactory : public PortAllocatorFactory { |
| 54 public: |
| 55 ChromiumPortAllocatorFactory( |
| 56 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter); |
| 57 ~ChromiumPortAllocatorFactory() override; |
| 58 |
| 59 // PortAllocatorFactory interface. |
| 60 scoped_ptr<cricket::HttpPortAllocatorBase> CreatePortAllocator() override; |
| 61 |
| 62 private: |
| 63 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter_; |
| 64 |
| 65 DISALLOW_COPY_AND_ASSIGN(ChromiumPortAllocatorFactory); |
| 66 }; |
| 67 |
| 51 } // namespace protocol | 68 } // namespace protocol |
| 52 } // namespace remoting | 69 } // namespace remoting |
| 53 | 70 |
| 54 #endif // REMOTING_HOST_HOST_PORT_ALLOCATOR_H_ | 71 #endif // REMOTING_HOST_HOST_PORT_ALLOCATOR_H_ |
| OLD | NEW |