| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 "content/renderer/p2p/port_allocator.h" | 5 #include "content/renderer/p2p/port_allocator.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "content/public/common/content_switches.h" | 9 #include "content/public/common/content_switches.h" |
| 10 #include "content/renderer/p2p/socket_dispatcher.h" |
| 10 | 11 |
| 11 namespace content { | 12 namespace content { |
| 12 | 13 |
| 13 P2PPortAllocator::Config::Config() {} | 14 P2PPortAllocator::Config::Config() {} |
| 14 | 15 |
| 15 P2PPortAllocator::Config::~Config() { | 16 P2PPortAllocator::Config::~Config() { |
| 16 } | 17 } |
| 17 | 18 |
| 18 P2PPortAllocator::Config::RelayServerConfig::RelayServerConfig() | 19 P2PPortAllocator::Config::RelayServerConfig::RelayServerConfig() |
| 19 : port(0) { | 20 : port(0) { |
| 20 } | 21 } |
| 21 | 22 |
| 22 P2PPortAllocator::Config::RelayServerConfig::~RelayServerConfig() { | 23 P2PPortAllocator::Config::RelayServerConfig::~RelayServerConfig() { |
| 23 } | 24 } |
| 24 | 25 |
| 26 P2PPortAllocator::Params::Params( |
| 27 const scoped_refptr<P2PSocketDispatcher>& socket_dispatcher, |
| 28 rtc::PacketSocketFactory* socket_factory, |
| 29 const GURL& origin, |
| 30 const Config& config) |
| 31 : socket_dispatcher(socket_dispatcher), |
| 32 socket_factory(socket_factory), |
| 33 requesting_origin(origin), |
| 34 config(config) {} |
| 35 |
| 36 P2PPortAllocator::Params::~Params() {} |
| 37 |
| 25 P2PPortAllocator::P2PPortAllocator( | 38 P2PPortAllocator::P2PPortAllocator( |
| 26 P2PSocketDispatcher* socket_dispatcher, | 39 const Params& params, |
| 27 rtc::NetworkManager* network_manager, | 40 scoped_ptr<rtc::NetworkManager> network_manager) |
| 28 rtc::PacketSocketFactory* socket_factory, | 41 : cricket::BasicPortAllocator(network_manager.get(), params.socket_factory), |
| 29 const Config& config, | 42 network_manager_(network_manager.Pass()), |
| 30 const GURL& origin) | 43 socket_dispatcher_(params.socket_dispatcher), |
| 31 : cricket::BasicPortAllocator(network_manager, socket_factory), | 44 config_(params.config), |
| 32 socket_dispatcher_(socket_dispatcher), | 45 origin_(params.requesting_origin) { |
| 33 config_(config), | |
| 34 origin_(origin) | |
| 35 { | |
| 36 uint32 flags = 0; | 46 uint32 flags = 0; |
| 37 if (!config_.enable_multiple_routes) | 47 if (!config_.enable_multiple_routes) |
| 38 flags |= cricket::PORTALLOCATOR_DISABLE_ADAPTER_ENUMERATION; | 48 flags |= cricket::PORTALLOCATOR_DISABLE_ADAPTER_ENUMERATION; |
| 39 if (!config_.enable_nonproxied_udp) { | 49 if (!config_.enable_nonproxied_udp) { |
| 40 flags |= cricket::PORTALLOCATOR_DISABLE_UDP | | 50 flags |= cricket::PORTALLOCATOR_DISABLE_UDP | |
| 41 cricket::PORTALLOCATOR_DISABLE_STUN | | 51 cricket::PORTALLOCATOR_DISABLE_STUN | |
| 42 cricket::PORTALLOCATOR_DISABLE_UDP_RELAY; | 52 cricket::PORTALLOCATOR_DISABLE_UDP_RELAY; |
| 43 } | 53 } |
| 44 set_flags(flags); | 54 set_flags(flags); |
| 45 set_allow_tcp_listen(false); | 55 set_allow_tcp_listen(false); |
| 46 const base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess(); | 56 const base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess(); |
| 47 bool enable_webrtc_stun_origin = | 57 bool enable_webrtc_stun_origin = |
| 48 cmd_line->HasSwitch(switches::kEnableWebRtcStunOrigin); | 58 cmd_line->HasSwitch(switches::kEnableWebRtcStunOrigin); |
| 49 if (enable_webrtc_stun_origin) { | 59 if (enable_webrtc_stun_origin) { |
| 50 set_origin(origin.spec()); | 60 set_origin(origin_.spec()); |
| 51 } | 61 } |
| 52 } | 62 } |
| 53 | 63 |
| 54 P2PPortAllocator::~P2PPortAllocator() { | 64 P2PPortAllocator::~P2PPortAllocator() { |
| 55 } | 65 } |
| 56 | 66 |
| 57 cricket::PortAllocatorSession* P2PPortAllocator::CreateSessionInternal( | 67 cricket::PortAllocatorSession* P2PPortAllocator::CreateSessionInternal( |
| 58 const std::string& content_name, | 68 const std::string& content_name, |
| 59 int component, | 69 int component, |
| 60 const std::string& ice_username_fragment, | 70 const std::string& ice_username_fragment, |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 config.relays[i].port), | 115 config.relays[i].port), |
| 106 protocol, | 116 protocol, |
| 107 config.relays[i].secure)); | 117 config.relays[i].secure)); |
| 108 relay_server.credentials = credentials; | 118 relay_server.credentials = credentials; |
| 109 port_config->AddRelay(relay_server); | 119 port_config->AddRelay(relay_server); |
| 110 } | 120 } |
| 111 ConfigReady(port_config); | 121 ConfigReady(port_config); |
| 112 } | 122 } |
| 113 | 123 |
| 114 } // namespace content | 124 } // namespace content |
| OLD | NEW |