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/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
10 #include "base/strings/string_split.h" | 10 #include "base/strings/string_split.h" |
11 #include "base/strings/string_util.h" | 11 #include "base/strings/string_util.h" |
12 #include "content/public/common/content_switches.h" | 12 #include "content/public/common/content_switches.h" |
13 #include "content/renderer/p2p/host_address_request.h" | 13 #include "content/renderer/p2p/host_address_request.h" |
14 #include "jingle/glue/utils.h" | 14 #include "jingle/glue/utils.h" |
15 #include "net/base/escape.h" | 15 #include "net/base/escape.h" |
16 #include "net/base/ip_endpoint.h" | 16 #include "net/base/ip_endpoint.h" |
17 #include "third_party/WebKit/public/platform/WebURLError.h" | 17 #include "third_party/WebKit/public/platform/WebURLError.h" |
18 #include "third_party/WebKit/public/platform/WebURLLoader.h" | 18 #include "third_party/WebKit/public/platform/WebURLLoader.h" |
19 #include "third_party/WebKit/public/platform/WebURLRequest.h" | 19 #include "third_party/WebKit/public/platform/WebURLRequest.h" |
20 #include "third_party/WebKit/public/platform/WebURLResponse.h" | 20 #include "third_party/WebKit/public/platform/WebURLResponse.h" |
21 #include "third_party/WebKit/public/web/WebFrame.h" | 21 #include "third_party/WebKit/public/web/WebFrame.h" |
22 #include "third_party/WebKit/public/web/WebURLLoaderOptions.h" | 22 #include "third_party/WebKit/public/web/WebURLLoaderOptions.h" |
23 | 23 |
24 using WebKit::WebString; | 24 using blink::WebString; |
25 using WebKit::WebURL; | 25 using blink::WebURL; |
26 using WebKit::WebURLLoader; | 26 using blink::WebURLLoader; |
27 using WebKit::WebURLLoaderOptions; | 27 using blink::WebURLLoaderOptions; |
28 using WebKit::WebURLRequest; | 28 using blink::WebURLRequest; |
29 using WebKit::WebURLResponse; | 29 using blink::WebURLResponse; |
30 | 30 |
31 namespace content { | 31 namespace content { |
32 | 32 |
33 namespace { | 33 namespace { |
34 | 34 |
35 // URL used to create a relay session. | 35 // URL used to create a relay session. |
36 const char kCreateRelaySessionURL[] = "/create_session"; | 36 const char kCreateRelaySessionURL[] = "/create_session"; |
37 | 37 |
38 // Number of times we will try to request relay session. | 38 // Number of times we will try to request relay session. |
39 const int kRelaySessionRetries = 3; | 39 const int kRelaySessionRetries = 3; |
(...skipping 22 matching lines...) Expand all Loading... |
62 } | 62 } |
63 | 63 |
64 P2PPortAllocator::Config::RelayServerConfig::RelayServerConfig() | 64 P2PPortAllocator::Config::RelayServerConfig::RelayServerConfig() |
65 : port(0) { | 65 : port(0) { |
66 } | 66 } |
67 | 67 |
68 P2PPortAllocator::Config::RelayServerConfig::~RelayServerConfig() { | 68 P2PPortAllocator::Config::RelayServerConfig::~RelayServerConfig() { |
69 } | 69 } |
70 | 70 |
71 P2PPortAllocator::P2PPortAllocator( | 71 P2PPortAllocator::P2PPortAllocator( |
72 WebKit::WebFrame* web_frame, | 72 blink::WebFrame* web_frame, |
73 P2PSocketDispatcher* socket_dispatcher, | 73 P2PSocketDispatcher* socket_dispatcher, |
74 talk_base::NetworkManager* network_manager, | 74 talk_base::NetworkManager* network_manager, |
75 talk_base::PacketSocketFactory* socket_factory, | 75 talk_base::PacketSocketFactory* socket_factory, |
76 const Config& config) | 76 const Config& config) |
77 : cricket::BasicPortAllocator(network_manager, socket_factory), | 77 : cricket::BasicPortAllocator(network_manager, socket_factory), |
78 web_frame_(web_frame), | 78 web_frame_(web_frame), |
79 socket_dispatcher_(socket_dispatcher), | 79 socket_dispatcher_(socket_dispatcher), |
80 config_(config) { | 80 config_(config) { |
81 uint32 flags = 0; | 81 uint32 flags = 0; |
82 if (config_.disable_tcp_transport) | 82 if (config_.disable_tcp_transport) |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 return; | 146 return; |
147 } | 147 } |
148 relay_session_response_.append(data, data + data_length); | 148 relay_session_response_.append(data, data + data_length); |
149 } | 149 } |
150 | 150 |
151 void P2PPortAllocatorSession::didFinishLoading(WebURLLoader* loader, | 151 void P2PPortAllocatorSession::didFinishLoading(WebURLLoader* loader, |
152 double finish_time) { | 152 double finish_time) { |
153 ParseRelayResponse(); | 153 ParseRelayResponse(); |
154 } | 154 } |
155 | 155 |
156 void P2PPortAllocatorSession::didFail(WebKit::WebURLLoader* loader, | 156 void P2PPortAllocatorSession::didFail(blink::WebURLLoader* loader, |
157 const WebKit::WebURLError& error) { | 157 const blink::WebURLError& error) { |
158 DCHECK_EQ(loader, relay_session_request_.get()); | 158 DCHECK_EQ(loader, relay_session_request_.get()); |
159 DCHECK_NE(error.reason, 0); | 159 DCHECK_NE(error.reason, 0); |
160 | 160 |
161 LOG(ERROR) << "Relay session request failed."; | 161 LOG(ERROR) << "Relay session request failed."; |
162 | 162 |
163 // Retry the request. | 163 // Retry the request. |
164 AllocateLegacyRelaySession(); | 164 AllocateLegacyRelaySession(); |
165 } | 165 } |
166 | 166 |
167 void P2PPortAllocatorSession::GetPortConfigurations() { | 167 void P2PPortAllocatorSession::GetPortConfigurations() { |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
389 protocol, | 389 protocol, |
390 relay_info.config.secure)); | 390 relay_info.config.secure)); |
391 relay_server.credentials = credentials; | 391 relay_server.credentials = credentials; |
392 port_config->AddRelay(relay_server); | 392 port_config->AddRelay(relay_server); |
393 } | 393 } |
394 } | 394 } |
395 ConfigReady(port_config); | 395 ConfigReady(port_config); |
396 } | 396 } |
397 | 397 |
398 } // namespace content | 398 } // namespace content |
OLD | NEW |