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/browser/renderer_host/p2p/socket_host_tcp.h" | 5 #include "content/browser/renderer_host/p2p/socket_host_tcp.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/location.h" | 10 #include "base/location.h" |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 | 90 |
91 net::HostPortPair dest_host_port_pair; | 91 net::HostPortPair dest_host_port_pair; |
92 // If there is a domain name, let's try it first, it's required by some proxy | 92 // If there is a domain name, let's try it first, it's required by some proxy |
93 // to only take hostname for CONNECT. If it has been DNS resolved, the result | 93 // to only take hostname for CONNECT. If it has been DNS resolved, the result |
94 // is likely cached and shouldn't cause 2nd DNS resolution in the case of | 94 // is likely cached and shouldn't cause 2nd DNS resolution in the case of |
95 // direct connect (i.e. no proxy). | 95 // direct connect (i.e. no proxy). |
96 if (!remote_address.hostname.empty()) { | 96 if (!remote_address.hostname.empty()) { |
97 dest_host_port_pair = net::HostPortPair(remote_address.hostname, | 97 dest_host_port_pair = net::HostPortPair(remote_address.hostname, |
98 remote_address.ip_address.port()); | 98 remote_address.ip_address.port()); |
99 } else { | 99 } else { |
100 DCHECK(!remote_address.ip_address.address().empty()); | 100 DCHECK(!remote_address.ip_address.address_number().empty()); |
101 dest_host_port_pair = net::HostPortPair::FromIPEndPoint( | 101 dest_host_port_pair = net::HostPortPair::FromIPEndPoint( |
102 remote_address.ip_address); | 102 remote_address.ip_address); |
103 } | 103 } |
104 | 104 |
105 // TODO(mallinath) - We are ignoring local_address altogether. We should | 105 // TODO(mallinath) - We are ignoring local_address altogether. We should |
106 // find a way to inject this into ProxyResolvingClientSocket. This could be | 106 // find a way to inject this into ProxyResolvingClientSocket. This could be |
107 // a problem on multi-homed host. | 107 // a problem on multi-homed host. |
108 | 108 |
109 // The default SSLConfig is good enough for us for now. | 109 // The default SSLConfig is good enough for us for now. |
110 const net::SSLConfig ssl_config; | 110 const net::SSLConfig ssl_config; |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 context.transport_security_state = | 189 context.transport_security_state = |
190 url_context_->GetURLRequestContext()->transport_security_state(); | 190 url_context_->GetURLRequestContext()->transport_security_state(); |
191 DCHECK(context.transport_security_state); | 191 DCHECK(context.transport_security_state); |
192 | 192 |
193 // Default ssl config. | 193 // Default ssl config. |
194 const net::SSLConfig ssl_config; | 194 const net::SSLConfig ssl_config; |
195 net::HostPortPair dest_host_port_pair; | 195 net::HostPortPair dest_host_port_pair; |
196 | 196 |
197 // Calling net::HostPortPair::FromIPEndPoint will crash if the IP address is | 197 // Calling net::HostPortPair::FromIPEndPoint will crash if the IP address is |
198 // empty. | 198 // empty. |
199 if (!remote_address_.ip_address.address().empty()) { | 199 if (!remote_address_.ip_address.address_number().empty()) { |
200 net::HostPortPair::FromIPEndPoint(remote_address_.ip_address); | 200 net::HostPortPair::FromIPEndPoint(remote_address_.ip_address); |
201 } else { | 201 } else { |
202 dest_host_port_pair.set_port(remote_address_.ip_address.port()); | 202 dest_host_port_pair.set_port(remote_address_.ip_address.port()); |
203 } | 203 } |
204 if (!remote_address_.hostname.empty()) | 204 if (!remote_address_.hostname.empty()) |
205 dest_host_port_pair.set_host(remote_address_.hostname); | 205 dest_host_port_pair.set_host(remote_address_.hostname); |
206 | 206 |
207 net::ClientSocketFactory* socket_factory = | 207 net::ClientSocketFactory* socket_factory = |
208 net::ClientSocketFactory::GetDefaultFactory(); | 208 net::ClientSocketFactory::GetDefaultFactory(); |
209 DCHECK(socket_factory); | 209 DCHECK(socket_factory); |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
269 // GetPeerAddress returns ERR_NAME_NOT_RESOLVED if the socket is connected | 269 // GetPeerAddress returns ERR_NAME_NOT_RESOLVED if the socket is connected |
270 // through a proxy. | 270 // through a proxy. |
271 result = socket_->GetPeerAddress(&remote_address); | 271 result = socket_->GetPeerAddress(&remote_address); |
272 if (result < 0 && result != net::ERR_NAME_NOT_RESOLVED) { | 272 if (result < 0 && result != net::ERR_NAME_NOT_RESOLVED) { |
273 LOG(ERROR) << "P2PSocketHostTcpBase::OnConnected: unable to get peer" | 273 LOG(ERROR) << "P2PSocketHostTcpBase::OnConnected: unable to get peer" |
274 << " address: " << result; | 274 << " address: " << result; |
275 OnError(); | 275 OnError(); |
276 return false; | 276 return false; |
277 } | 277 } |
278 | 278 |
279 if (!remote_address.address().empty()) { | 279 if (!remote_address.address_number().empty()) { |
280 VLOG(1) << "Remote address: " << remote_address.ToString(); | 280 VLOG(1) << "Remote address: " << remote_address.ToString(); |
281 if (remote_address_.ip_address.address().empty()) { | 281 if (remote_address_.ip_address.address_number().empty()) { |
282 // Save |remote_address| if address is empty. | 282 // Save |remote_address| if address is empty. |
283 remote_address_.ip_address = remote_address; | 283 remote_address_.ip_address = remote_address; |
284 } | 284 } |
285 } else { | 285 } else { |
286 VLOG(1) << "Remote address is unknown since connection is proxied"; | 286 VLOG(1) << "Remote address is unknown since connection is proxied"; |
287 } | 287 } |
288 | 288 |
289 // If we are not doing TLS, we are ready to send data now. | 289 // If we are not doing TLS, we are ready to send data now. |
290 // In case of TLS SignalConnect will be sent only after TLS handshake is | 290 // In case of TLS SignalConnect will be sent only after TLS handshake is |
291 // successful. So no buffering will be done at socket handlers if any | 291 // successful. So no buffering will be done at socket handlers if any |
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
633 } else { | 633 } else { |
634 packet_size += kTurnChannelDataHeaderSize; | 634 packet_size += kTurnChannelDataHeaderSize; |
635 // Calculate any padding if present. | 635 // Calculate any padding if present. |
636 if (packet_size % 4) | 636 if (packet_size % 4) |
637 *pad_bytes = 4 - packet_size % 4; | 637 *pad_bytes = 4 - packet_size % 4; |
638 } | 638 } |
639 return packet_size; | 639 return packet_size; |
640 } | 640 } |
641 | 641 |
642 } // namespace content | 642 } // namespace content |
OLD | NEW |