| 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/macros.h" | 10 #include "base/macros.h" |
| 11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
| 12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "remoting/protocol/port_allocator_base.h" | 13 #include "remoting/protocol/port_allocator_base.h" |
| 14 #include "remoting/protocol/port_allocator_factory.h" | 14 #include "remoting/protocol/port_allocator_factory.h" |
| 15 | 15 |
| 16 namespace net { | 16 namespace net { |
| 17 class URLRequestContextGetter; | 17 class URLRequestContextGetter; |
| 18 } // namespace net | 18 } // namespace net |
| 19 | 19 |
| 20 namespace remoting { | 20 namespace remoting { |
| 21 namespace protocol { | 21 namespace protocol { |
| 22 | 22 |
| 23 struct NetworkSettings; | 23 struct NetworkSettings; |
| 24 | 24 |
| 25 // An implementation of cricket::PortAllocator that uses Chromium's network | 25 // An implementation of cricket::PortAllocator that uses Chromium's network |
| 26 // stack. | 26 // stack. |
| 27 class ChromiumPortAllocator : public PortAllocatorBase { | 27 class ChromiumPortAllocator : public PortAllocatorBase { |
| 28 public: | 28 public: |
| 29 static scoped_ptr<ChromiumPortAllocator> Create( | 29 ChromiumPortAllocator( |
| 30 const scoped_refptr<net::URLRequestContextGetter>& url_context); | 30 scoped_ptr<rtc::NetworkManager> network_manager, |
| 31 scoped_ptr<rtc::PacketSocketFactory> socket_factory, |
| 32 scoped_refptr<TransportContext> transport_context, |
| 33 scoped_refptr<net::URLRequestContextGetter> url_context); |
| 34 ~ChromiumPortAllocator() override; |
| 31 | 35 |
| 32 ~ChromiumPortAllocator() override; | 36 scoped_refptr<net::URLRequestContextGetter> url_context() { |
| 37 return url_context_; |
| 38 } |
| 33 | 39 |
| 34 // PortAllocatorBase overrides. | 40 // PortAllocatorBase overrides. |
| 35 cricket::PortAllocatorSession* CreateSessionInternal( | 41 cricket::PortAllocatorSession* CreateSessionInternal( |
| 36 const std::string& content_name, | 42 const std::string& content_name, |
| 37 int component, | 43 int component, |
| 38 const std::string& ice_username_fragment, | 44 const std::string& ice_username_fragment, |
| 39 const std::string& ice_password) override; | 45 const std::string& ice_password) override; |
| 40 | 46 |
| 41 private: | 47 private: |
| 42 ChromiumPortAllocator( | |
| 43 const scoped_refptr<net::URLRequestContextGetter>& url_context, | |
| 44 scoped_ptr<rtc::NetworkManager> network_manager, | |
| 45 scoped_ptr<rtc::PacketSocketFactory> socket_factory); | |
| 46 | |
| 47 scoped_refptr<net::URLRequestContextGetter> url_context_; | 48 scoped_refptr<net::URLRequestContextGetter> url_context_; |
| 48 scoped_ptr<rtc::NetworkManager> network_manager_; | |
| 49 scoped_ptr<rtc::PacketSocketFactory> socket_factory_; | |
| 50 | 49 |
| 51 DISALLOW_COPY_AND_ASSIGN(ChromiumPortAllocator); | 50 DISALLOW_COPY_AND_ASSIGN(ChromiumPortAllocator); |
| 52 }; | 51 }; |
| 53 | 52 |
| 54 class ChromiumPortAllocatorFactory : public PortAllocatorFactory { | 53 class ChromiumPortAllocatorFactory : public PortAllocatorFactory { |
| 55 public: | 54 public: |
| 56 ChromiumPortAllocatorFactory( | 55 ChromiumPortAllocatorFactory( |
| 57 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter); | 56 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter); |
| 58 ~ChromiumPortAllocatorFactory() override; | 57 ~ChromiumPortAllocatorFactory() override; |
| 59 | 58 |
| 60 // PortAllocatorFactory interface. | 59 // PortAllocatorFactory interface. |
| 61 scoped_ptr<PortAllocatorBase> CreatePortAllocator() override; | 60 scoped_ptr<cricket::PortAllocator> CreatePortAllocator( |
| 61 scoped_refptr<TransportContext> transport_context) override; |
| 62 | 62 |
| 63 private: | 63 private: |
| 64 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter_; | 64 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter_; |
| 65 | 65 |
| 66 DISALLOW_COPY_AND_ASSIGN(ChromiumPortAllocatorFactory); | 66 DISALLOW_COPY_AND_ASSIGN(ChromiumPortAllocatorFactory); |
| 67 }; | 67 }; |
| 68 | 68 |
| 69 } // namespace protocol | 69 } // namespace protocol |
| 70 } // namespace remoting | 70 } // namespace remoting |
| 71 | 71 |
| 72 #endif // REMOTING_HOST_HOST_PORT_ALLOCATOR_H_ | 72 #endif // REMOTING_HOST_HOST_PORT_ALLOCATOR_H_ |
| OLD | NEW |