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/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" |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 const std::string& string, int* value) { | 43 const std::string& string, int* value) { |
44 if (!base::StringToInt(string, value) || *value <= 0 || *value >= 65536) { | 44 if (!base::StringToInt(string, value) || *value <= 0 || *value >= 65536) { |
45 LOG(ERROR) << "Received invalid port number from relay server: " << string; | 45 LOG(ERROR) << "Received invalid port number from relay server: " << string; |
46 return false; | 46 return false; |
47 } | 47 } |
48 return true; | 48 return true; |
49 } | 49 } |
50 | 50 |
51 } // namespace | 51 } // namespace |
52 | 52 |
| 53 P2PPortAllocator::Config::Config() |
| 54 : stun_server_port(0), |
| 55 relay_server_port(0), |
| 56 legacy_relay(false), |
| 57 disable_tcp_transport(false) { |
| 58 } |
| 59 |
| 60 P2PPortAllocator::Config::~Config() { |
| 61 } |
| 62 |
53 P2PPortAllocator::P2PPortAllocator( | 63 P2PPortAllocator::P2PPortAllocator( |
54 WebKit::WebFrame* web_frame, | 64 WebKit::WebFrame* web_frame, |
55 P2PSocketDispatcher* socket_dispatcher, | 65 P2PSocketDispatcher* socket_dispatcher, |
56 talk_base::NetworkManager* network_manager, | 66 talk_base::NetworkManager* network_manager, |
57 talk_base::PacketSocketFactory* socket_factory, | 67 talk_base::PacketSocketFactory* socket_factory, |
58 const webkit_glue::P2PTransport::Config& config) | 68 const Config& config) |
59 : cricket::BasicPortAllocator(network_manager, socket_factory), | 69 : cricket::BasicPortAllocator(network_manager, socket_factory), |
60 web_frame_(web_frame), | 70 web_frame_(web_frame), |
61 socket_dispatcher_(socket_dispatcher), | 71 socket_dispatcher_(socket_dispatcher), |
62 config_(config) { | 72 config_(config) { |
63 uint32 flags = 0; | 73 uint32 flags = 0; |
64 if (config_.disable_tcp_transport) | 74 if (config_.disable_tcp_transport) |
65 flags |= cricket::PORTALLOCATOR_DISABLE_TCP; | 75 flags |= cricket::PORTALLOCATOR_DISABLE_TCP; |
66 set_flags(flags); | 76 set_flags(flags); |
67 } | 77 } |
68 | 78 |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
296 talk_base::SocketAddress address(relay_ip_.ip(), relay_ssltcp_port_); | 306 talk_base::SocketAddress address(relay_ip_.ip(), relay_ssltcp_port_); |
297 ports.push_back(cricket::ProtocolAddress(address, cricket::PROTO_SSLTCP)); | 307 ports.push_back(cricket::ProtocolAddress(address, cricket::PROTO_SSLTCP)); |
298 } | 308 } |
299 if (!ports.empty()) | 309 if (!ports.empty()) |
300 config->AddRelay(ports, 0.0f); | 310 config->AddRelay(ports, 0.0f); |
301 } | 311 } |
302 ConfigReady(config); | 312 ConfigReady(config); |
303 } | 313 } |
304 | 314 |
305 } // namespace content | 315 } // namespace content |
OLD | NEW |