OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/bind.h" | 7 #include "base/bind.h" |
8 #include "base/string_number_conversions.h" | 8 #include "base/string_number_conversions.h" |
9 #include "base/string_split.h" | 9 #include "base/string_split.h" |
10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
11 #include "content/renderer/p2p/host_address_request.h" | 11 #include "content/renderer/p2p/host_address_request.h" |
12 #include "jingle/glue/utils.h" | 12 #include "jingle/glue/utils.h" |
13 #include "net/base/ip_endpoint.h" | 13 #include "net/base/ip_endpoint.h" |
| 14 #include "ppapi/c/dev/ppb_transport_dev.h" |
14 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" | 15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" |
15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURLError.h" | 16 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURLError.h" |
16 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURLLoader.h" | 17 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURLLoader.h" |
17 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURLLoaderOptions.h
" | 18 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURLLoaderOptions.h
" |
18 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURLRequest.h" | 19 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURLRequest.h" |
19 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURLResponse.h" | 20 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURLResponse.h" |
20 | 21 |
21 using WebKit::WebString; | 22 using WebKit::WebString; |
22 using WebKit::WebURL; | 23 using WebKit::WebURL; |
23 using WebKit::WebURLLoader; | 24 using WebKit::WebURLLoader; |
(...skipping 28 matching lines...) Expand all Loading... |
52 P2PPortAllocator::P2PPortAllocator( | 53 P2PPortAllocator::P2PPortAllocator( |
53 WebKit::WebFrame* web_frame, | 54 WebKit::WebFrame* web_frame, |
54 P2PSocketDispatcher* socket_dispatcher, | 55 P2PSocketDispatcher* socket_dispatcher, |
55 talk_base::NetworkManager* network_manager, | 56 talk_base::NetworkManager* network_manager, |
56 talk_base::PacketSocketFactory* socket_factory, | 57 talk_base::PacketSocketFactory* socket_factory, |
57 const webkit_glue::P2PTransport::Config& config) | 58 const webkit_glue::P2PTransport::Config& config) |
58 : cricket::BasicPortAllocator(network_manager, socket_factory), | 59 : cricket::BasicPortAllocator(network_manager, socket_factory), |
59 web_frame_(web_frame), | 60 web_frame_(web_frame), |
60 socket_dispatcher_(socket_dispatcher), | 61 socket_dispatcher_(socket_dispatcher), |
61 config_(config) { | 62 config_(config) { |
| 63 uint32 flags = 0; |
| 64 if (config_.disable_tcp_transport) |
| 65 flags |= cricket::PORTALLOCATOR_DISABLE_TCP; |
| 66 set_flags(flags); |
62 } | 67 } |
63 | 68 |
64 P2PPortAllocator::~P2PPortAllocator() { | 69 P2PPortAllocator::~P2PPortAllocator() { |
65 } | 70 } |
66 | 71 |
67 cricket::PortAllocatorSession* P2PPortAllocator::CreateSession( | 72 cricket::PortAllocatorSession* P2PPortAllocator::CreateSession( |
68 const std::string& name, | 73 const std::string& name, |
69 const std::string& session_type) { | 74 const std::string& session_type) { |
70 return new P2PPortAllocatorSession(this, name, session_type); | 75 return new P2PPortAllocatorSession(this, name, session_type); |
71 } | 76 } |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
250 cricket::PortConfiguration* config = | 255 cricket::PortConfiguration* config = |
251 new cricket::PortConfiguration(stun_server_address_, | 256 new cricket::PortConfiguration(stun_server_address_, |
252 relay_username_, relay_password_, ""); | 257 relay_username_, relay_password_, ""); |
253 | 258 |
254 cricket::PortConfiguration::PortList ports; | 259 cricket::PortConfiguration::PortList ports; |
255 if (relay_ip_.ip() != 0) { | 260 if (relay_ip_.ip() != 0) { |
256 if (relay_udp_port_ > 0) { | 261 if (relay_udp_port_ > 0) { |
257 talk_base::SocketAddress address(relay_ip_.ip(), relay_udp_port_); | 262 talk_base::SocketAddress address(relay_ip_.ip(), relay_udp_port_); |
258 ports.push_back(cricket::ProtocolAddress(address, cricket::PROTO_UDP)); | 263 ports.push_back(cricket::ProtocolAddress(address, cricket::PROTO_UDP)); |
259 } | 264 } |
260 if (relay_tcp_port_ > 0) { | 265 if (relay_tcp_port_ > 0 && !allocator_->config_.disable_tcp_transport) { |
261 talk_base::SocketAddress address(relay_ip_.ip(), relay_tcp_port_); | 266 talk_base::SocketAddress address(relay_ip_.ip(), relay_tcp_port_); |
262 ports.push_back(cricket::ProtocolAddress(address, cricket::PROTO_TCP)); | 267 ports.push_back(cricket::ProtocolAddress(address, cricket::PROTO_TCP)); |
263 } | 268 } |
264 if (relay_ssltcp_port_ > 0) { | 269 if (relay_ssltcp_port_ > 0 && !allocator_->config_.disable_tcp_transport) { |
265 talk_base::SocketAddress address(relay_ip_.ip(), relay_ssltcp_port_); | 270 talk_base::SocketAddress address(relay_ip_.ip(), relay_ssltcp_port_); |
266 ports.push_back(cricket::ProtocolAddress(address, cricket::PROTO_SSLTCP)); | 271 ports.push_back(cricket::ProtocolAddress(address, cricket::PROTO_SSLTCP)); |
267 } | 272 } |
268 } | 273 } |
269 config->AddRelay(ports, 0.0f); | 274 config->AddRelay(ports, 0.0f); |
270 ConfigReady(config); | 275 ConfigReady(config); |
271 } | 276 } |
272 | 277 |
273 } // namespace content | 278 } // namespace content |
OLD | NEW |