| 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 #include "remoting/host/chromium_port_allocator_factory.h" | 5 #include "remoting/host/chromium_port_allocator_factory.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "net/url_request/url_request_context_getter.h" | 8 #include "net/url_request/url_request_context_getter.h" |
| 9 #include "remoting/protocol/chromium_port_allocator.h" | 9 #include "remoting/protocol/chromium_port_allocator.h" |
| 10 #include "remoting/protocol/network_settings.h" | 10 #include "remoting/protocol/network_settings.h" |
| 11 | 11 |
| 12 namespace remoting { | 12 namespace remoting { |
| 13 | 13 |
| 14 ChromiumPortAllocatorFactory::ChromiumPortAllocatorFactory( | 14 ChromiumPortAllocatorFactory::ChromiumPortAllocatorFactory( |
| 15 const protocol::NetworkSettings& network_settings, | 15 const protocol::NetworkSettings& network_settings, |
| 16 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter) | 16 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter) |
| 17 : network_settings_(network_settings), | 17 : network_settings_(network_settings), |
| 18 url_request_context_getter_(url_request_context_getter) { | 18 url_request_context_getter_(url_request_context_getter) { |
| 19 } | 19 } |
| 20 | 20 |
| 21 ChromiumPortAllocatorFactory::~ChromiumPortAllocatorFactory() {} | 21 ChromiumPortAllocatorFactory::~ChromiumPortAllocatorFactory() {} |
| 22 | 22 |
| 23 talk_base::scoped_refptr<webrtc::PortAllocatorFactoryInterface> | 23 rtc::scoped_refptr<webrtc::PortAllocatorFactoryInterface> |
| 24 ChromiumPortAllocatorFactory::Create( | 24 ChromiumPortAllocatorFactory::Create( |
| 25 const protocol::NetworkSettings& network_settings, | 25 const protocol::NetworkSettings& network_settings, |
| 26 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter) { | 26 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter) { |
| 27 talk_base::RefCountedObject<ChromiumPortAllocatorFactory>* allocator_factory = | 27 rtc::RefCountedObject<ChromiumPortAllocatorFactory>* allocator_factory = |
| 28 new talk_base::RefCountedObject<ChromiumPortAllocatorFactory>( | 28 new rtc::RefCountedObject<ChromiumPortAllocatorFactory>( |
| 29 network_settings, url_request_context_getter); | 29 network_settings, url_request_context_getter); |
| 30 return allocator_factory; | 30 return allocator_factory; |
| 31 } | 31 } |
| 32 | 32 |
| 33 cricket::PortAllocator* ChromiumPortAllocatorFactory::CreatePortAllocator( | 33 cricket::PortAllocator* ChromiumPortAllocatorFactory::CreatePortAllocator( |
| 34 const std::vector<StunConfiguration>& stun_servers, | 34 const std::vector<StunConfiguration>& stun_servers, |
| 35 const std::vector<TurnConfiguration>& turn_configurations) { | 35 const std::vector<TurnConfiguration>& turn_configurations) { |
| 36 scoped_ptr<protocol::ChromiumPortAllocator> port_allocator( | 36 scoped_ptr<protocol::ChromiumPortAllocator> port_allocator( |
| 37 protocol::ChromiumPortAllocator::Create(url_request_context_getter_, | 37 protocol::ChromiumPortAllocator::Create(url_request_context_getter_, |
| 38 network_settings_)); | 38 network_settings_)); |
| 39 | 39 |
| 40 std::vector<talk_base::SocketAddress> stun_hosts; | 40 std::vector<rtc::SocketAddress> stun_hosts; |
| 41 typedef std::vector<StunConfiguration>::const_iterator StunIt; | 41 typedef std::vector<StunConfiguration>::const_iterator StunIt; |
| 42 for (StunIt stun_it = stun_servers.begin(); stun_it != stun_servers.end(); | 42 for (StunIt stun_it = stun_servers.begin(); stun_it != stun_servers.end(); |
| 43 ++stun_it) { | 43 ++stun_it) { |
| 44 stun_hosts.push_back(stun_it->server); | 44 stun_hosts.push_back(stun_it->server); |
| 45 } | 45 } |
| 46 port_allocator->SetStunHosts(stun_hosts); | 46 port_allocator->SetStunHosts(stun_hosts); |
| 47 | 47 |
| 48 // TODO(aiguha): Figure out how to translate |turn_configurations| into | 48 // TODO(aiguha): Figure out how to translate |turn_configurations| into |
| 49 // turn hosts so we can set |port_allocator|'s relay hosts. | 49 // turn hosts so we can set |port_allocator|'s relay hosts. |
| 50 | 50 |
| 51 return port_allocator.release(); | 51 return port_allocator.release(); |
| 52 } | 52 } |
| 53 | 53 |
| 54 } // namespace remoting | 54 } // namespace remoting |
| 55 | 55 |
| OLD | NEW |