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/pepper_tcp_socket.h" | 5 #include "content/browser/renderer_host/pepper_tcp_socket.h" |
6 | 6 |
7 #include <string.h> | 7 #include <string.h> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
310 StartConnect(address_list_); | 310 StartConnect(address_list_); |
311 } | 311 } |
312 | 312 |
313 void PepperTCPSocket::OnConnectCompleted(int result) { | 313 void PepperTCPSocket::OnConnectCompleted(int result) { |
314 DCHECK(connection_state_ == CONNECT_IN_PROGRESS && socket_.get()); | 314 DCHECK(connection_state_ == CONNECT_IN_PROGRESS && socket_.get()); |
315 | 315 |
316 if (result != net::OK) { | 316 if (result != net::OK) { |
317 SendConnectACKError(); | 317 SendConnectACKError(); |
318 connection_state_ = BEFORE_CONNECT; | 318 connection_state_ = BEFORE_CONNECT; |
319 } else { | 319 } else { |
320 net::IPEndPoint ip_end_point; | 320 net::IPEndPoint ip_end_point_local; |
321 net::AddressList address_list; | 321 net::IPEndPoint ip_end_point_remote; |
322 PP_NetAddress_Private local_addr = | 322 PP_NetAddress_Private local_addr = |
323 NetAddressPrivateImpl::kInvalidNetAddress; | 323 NetAddressPrivateImpl::kInvalidNetAddress; |
324 PP_NetAddress_Private remote_addr = | 324 PP_NetAddress_Private remote_addr = |
325 NetAddressPrivateImpl::kInvalidNetAddress; | 325 NetAddressPrivateImpl::kInvalidNetAddress; |
326 | 326 |
327 if (socket_->GetLocalAddress(&ip_end_point) != net::OK || | 327 if (socket_->GetLocalAddress(&ip_end_point_local) != net::OK || |
328 !NetAddressPrivateImpl::IPEndPointToNetAddress(ip_end_point, | 328 !NetAddressPrivateImpl::IPEndPointToNetAddress(ip_end_point_local, |
329 &local_addr) || | 329 &local_addr) || |
330 socket_->GetPeerAddress(&address_list) != net::OK || | 330 socket_->GetPeerAddress(&ip_end_point_remote) != net::OK || |
331 !NetAddressPrivateImpl::AddressListToNetAddress(address_list, | 331 !NetAddressPrivateImpl::IPEndPointToNetAddress(ip_end_point_remote, |
332 &remote_addr)) { | 332 &remote_addr)) { |
333 SendConnectACKError(); | 333 SendConnectACKError(); |
334 connection_state_ = BEFORE_CONNECT; | 334 connection_state_ = BEFORE_CONNECT; |
335 } else { | 335 } else { |
336 manager_->Send(new PpapiMsg_PPBTCPSocket_ConnectACK( | 336 manager_->Send(new PpapiMsg_PPBTCPSocket_ConnectACK( |
337 routing_id_, plugin_dispatcher_id_, socket_id_, true, | 337 routing_id_, plugin_dispatcher_id_, socket_id_, true, |
338 local_addr, remote_addr)); | 338 local_addr, remote_addr)); |
339 connection_state_ = CONNECTED; | 339 connection_state_ = CONNECTED; |
340 } | 340 } |
341 } | 341 } |
342 } | 342 } |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
374 routing_id_, plugin_dispatcher_id_, socket_id_, true, result)); | 374 routing_id_, plugin_dispatcher_id_, socket_id_, true, result)); |
375 } else { | 375 } else { |
376 SendWriteACKError(); | 376 SendWriteACKError(); |
377 } | 377 } |
378 write_buffer_ = NULL; | 378 write_buffer_ = NULL; |
379 } | 379 } |
380 | 380 |
381 bool PepperTCPSocket::IsConnected() const { | 381 bool PepperTCPSocket::IsConnected() const { |
382 return connection_state_ == CONNECTED || connection_state_ == SSL_CONNECTED; | 382 return connection_state_ == CONNECTED || connection_state_ == SSL_CONNECTED; |
383 } | 383 } |
OLD | NEW |