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 "content/public/common/content_switches.h" | 8 #include "content/public/common/content_switches.h" |
9 | 9 |
10 namespace content { | 10 namespace content { |
11 | 11 |
12 P2PPortAllocator::Config::Config() | 12 P2PPortAllocator::Config::Config() {} |
13 : disable_tcp_transport(false) { | |
14 } | |
15 | 13 |
16 P2PPortAllocator::Config::~Config() { | 14 P2PPortAllocator::Config::~Config() { |
17 } | 15 } |
18 | 16 |
19 P2PPortAllocator::Config::RelayServerConfig::RelayServerConfig() | 17 P2PPortAllocator::Config::RelayServerConfig::RelayServerConfig() |
20 : port(0) { | 18 : port(0) { |
21 } | 19 } |
22 | 20 |
23 P2PPortAllocator::Config::RelayServerConfig::~RelayServerConfig() { | 21 P2PPortAllocator::Config::RelayServerConfig::~RelayServerConfig() { |
24 } | 22 } |
25 | 23 |
26 P2PPortAllocator::P2PPortAllocator( | 24 P2PPortAllocator::P2PPortAllocator( |
27 P2PSocketDispatcher* socket_dispatcher, | 25 P2PSocketDispatcher* socket_dispatcher, |
28 rtc::NetworkManager* network_manager, | 26 rtc::NetworkManager* network_manager, |
29 rtc::PacketSocketFactory* socket_factory, | 27 rtc::PacketSocketFactory* socket_factory, |
30 const Config& config, | 28 const Config& config, |
31 const GURL& origin) | 29 const GURL& origin) |
32 : cricket::BasicPortAllocator(network_manager, socket_factory), | 30 : cricket::BasicPortAllocator(network_manager, socket_factory), |
33 socket_dispatcher_(socket_dispatcher), | 31 socket_dispatcher_(socket_dispatcher), |
34 config_(config), | 32 config_(config), |
35 origin_(origin) | 33 origin_(origin) |
36 { | 34 { |
37 uint32 flags = 0; | 35 uint32 flags = 0; |
38 if (config_.disable_tcp_transport) | |
39 flags |= cricket::PORTALLOCATOR_DISABLE_TCP; | |
40 if (!config_.enable_multiple_routes) | 36 if (!config_.enable_multiple_routes) |
41 flags |= cricket::PORTALLOCATOR_DISABLE_ADAPTER_ENUMERATION; | 37 flags |= cricket::PORTALLOCATOR_DISABLE_ADAPTER_ENUMERATION; |
| 38 if (!config_.enable_nonproxied_udp_transport) { |
| 39 flags |= cricket::PORTALLOCATOR_DISABLE_UDP | |
| 40 cricket::PORTALLOCATOR_DISABLE_STUN | |
| 41 cricket::PORTALLOCATOR_DISABLE_UDP_RELAY; |
| 42 } |
42 set_flags(flags); | 43 set_flags(flags); |
43 set_allow_tcp_listen(false); | 44 set_allow_tcp_listen(false); |
44 const base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess(); | 45 const base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess(); |
45 bool enable_webrtc_stun_origin = | 46 bool enable_webrtc_stun_origin = |
46 cmd_line->HasSwitch(switches::kEnableWebRtcStunOrigin); | 47 cmd_line->HasSwitch(switches::kEnableWebRtcStunOrigin); |
47 if (enable_webrtc_stun_origin) { | 48 if (enable_webrtc_stun_origin) { |
48 set_origin(origin.spec()); | 49 set_origin(origin.spec()); |
49 } | 50 } |
50 } | 51 } |
51 | 52 |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 config.relays[i].port), | 104 config.relays[i].port), |
104 protocol, | 105 protocol, |
105 config.relays[i].secure)); | 106 config.relays[i].secure)); |
106 relay_server.credentials = credentials; | 107 relay_server.credentials = credentials; |
107 port_config->AddRelay(relay_server); | 108 port_config->AddRelay(relay_server); |
108 } | 109 } |
109 ConfigReady(port_config); | 110 ConfigReady(port_config); |
110 } | 111 } |
111 | 112 |
112 } // namespace content | 113 } // namespace content |
OLD | NEW |