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 "base/sys_byteorder.h" | 7 #include "base/sys_byteorder.h" |
8 #include "content/common/p2p_messages.h" | 8 #include "content/common/p2p_messages.h" |
9 #include "ipc/ipc_sender.h" | 9 #include "ipc/ipc_sender.h" |
10 #include "jingle/glue/fake_ssl_client_socket.h" | 10 #include "jingle/glue/fake_ssl_client_socket.h" |
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
249 if (result < 0) { | 249 if (result < 0) { |
250 LOG(ERROR) << "P2PSocketHostTcpBase::OnConnected: unable to get local" | 250 LOG(ERROR) << "P2PSocketHostTcpBase::OnConnected: unable to get local" |
251 << " address: " << result; | 251 << " address: " << result; |
252 OnError(); | 252 OnError(); |
253 return false; | 253 return false; |
254 } | 254 } |
255 | 255 |
256 VLOG(1) << "Local address: " << local_address.ToString(); | 256 VLOG(1) << "Local address: " << local_address.ToString(); |
257 | 257 |
258 net::IPEndPoint remote_address; | 258 net::IPEndPoint remote_address; |
| 259 |
| 260 // |remote_address| could be empty if it is connected through a proxy. |
259 result = socket_->GetPeerAddress(&remote_address); | 261 result = socket_->GetPeerAddress(&remote_address); |
260 if (result < 0) { | 262 if (result < 0) { |
261 LOG(ERROR) << "P2PSocketHostTcpBase::OnConnected: unable to get peer" | 263 LOG(ERROR) << "P2PSocketHostTcpBase::OnConnected: unable to get peer" |
262 << " address: " << result; | 264 << " address: " << result; |
263 OnError(); | 265 OnError(); |
264 return false; | 266 return false; |
265 } | 267 } |
266 VLOG(1) << "Remote address: " << remote_address.ToString(); | 268 VLOG(1) << "Remote address: " << remote_address.ToString(); |
267 if (remote_address_.ip_address.address().empty()) { | 269 if (remote_address_.ip_address.address().empty() && |
| 270 !remote_address.address().empty()) { |
268 // Save |remote_address| if address is empty. | 271 // Save |remote_address| if address is empty. |
269 remote_address_.ip_address = remote_address; | 272 remote_address_.ip_address = remote_address; |
270 } | 273 } |
271 | 274 |
272 // If we are not doing TLS, we are ready to send data now. | 275 // If we are not doing TLS, we are ready to send data now. |
273 // In case of TLS SignalConnect will be sent only after TLS handshake is | 276 // In case of TLS SignalConnect will be sent only after TLS handshake is |
274 // successfull. So no buffering will be done at socket handlers if any | 277 // successful. So no buffering will be done at socket handlers if any |
275 // packets sent before that by the application. | 278 // packets sent before that by the application. |
276 message_sender_->Send(new P2PMsg_OnSocketCreated( | 279 message_sender_->Send(new P2PMsg_OnSocketCreated( |
277 id_, local_address, remote_address)); | 280 id_, local_address, remote_address)); |
278 return true; | 281 return true; |
279 } | 282 } |
280 | 283 |
281 void P2PSocketHostTcpBase::DoRead() { | 284 void P2PSocketHostTcpBase::DoRead() { |
282 int result; | 285 int result; |
283 do { | 286 do { |
284 if (!read_buffer_.get()) { | 287 if (!read_buffer_.get()) { |
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
610 } else { | 613 } else { |
611 packet_size += kTurnChannelDataHeaderSize; | 614 packet_size += kTurnChannelDataHeaderSize; |
612 // Calculate any padding if present. | 615 // Calculate any padding if present. |
613 if (packet_size % 4) | 616 if (packet_size % 4) |
614 *pad_bytes = 4 - packet_size % 4; | 617 *pad_bytes = 4 - packet_size % 4; |
615 } | 618 } |
616 return packet_size; | 619 return packet_size; |
617 } | 620 } |
618 | 621 |
619 } // namespace content | 622 } // namespace content |
OLD | NEW |