| 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 "jingle/glue/proxy_resolving_client_socket.h" | 5 #include "jingle/glue/proxy_resolving_client_socket.h" |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/bind_helpers.h" | 9 #include "base/bind_helpers.h" |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| (...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 339 } | 339 } |
| 340 | 340 |
| 341 bool ProxyResolvingClientSocket::IsConnectedAndIdle() const { | 341 bool ProxyResolvingClientSocket::IsConnectedAndIdle() const { |
| 342 if (!transport_.get() || !transport_->socket()) | 342 if (!transport_.get() || !transport_->socket()) |
| 343 return false; | 343 return false; |
| 344 return transport_->socket()->IsConnectedAndIdle(); | 344 return transport_->socket()->IsConnectedAndIdle(); |
| 345 } | 345 } |
| 346 | 346 |
| 347 int ProxyResolvingClientSocket::GetPeerAddress( | 347 int ProxyResolvingClientSocket::GetPeerAddress( |
| 348 net::IPEndPoint* address) const { | 348 net::IPEndPoint* address) const { |
| 349 if (transport_.get() && transport_->socket()) | 349 if (!transport_.get() || !transport_->socket()) { |
| 350 NOTREACHED(); |
| 351 return net::ERR_SOCKET_NOT_CONNECTED; |
| 352 } |
| 353 if (proxy_info_.is_direct()) |
| 350 return transport_->socket()->GetPeerAddress(address); | 354 return transport_->socket()->GetPeerAddress(address); |
| 351 NOTREACHED(); | 355 |
| 352 return net::ERR_SOCKET_NOT_CONNECTED; | 356 net::IPAddressNumber ip_number; |
| 357 if (net::ParseIPLiteralToNumber(dest_host_port_pair_.host(), &ip_number)) { |
| 358 *address = net::IPEndPoint(ip_number, dest_host_port_pair_.port()); |
| 359 } else { |
| 360 *address = |
| 361 net::IPEndPoint(net::IPAddressNumber(), dest_host_port_pair_.port()); |
| 362 } |
| 363 |
| 364 return net::OK; |
| 353 } | 365 } |
| 354 | 366 |
| 355 int ProxyResolvingClientSocket::GetLocalAddress( | 367 int ProxyResolvingClientSocket::GetLocalAddress( |
| 356 net::IPEndPoint* address) const { | 368 net::IPEndPoint* address) const { |
| 357 if (transport_.get() && transport_->socket()) | 369 if (transport_.get() && transport_->socket()) |
| 358 return transport_->socket()->GetLocalAddress(address); | 370 return transport_->socket()->GetLocalAddress(address); |
| 359 NOTREACHED(); | 371 NOTREACHED(); |
| 360 return net::ERR_SOCKET_NOT_CONNECTED; | 372 return net::ERR_SOCKET_NOT_CONNECTED; |
| 361 } | 373 } |
| 362 | 374 |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 410 return false; | 422 return false; |
| 411 } | 423 } |
| 412 | 424 |
| 413 void ProxyResolvingClientSocket::CloseTransportSocket() { | 425 void ProxyResolvingClientSocket::CloseTransportSocket() { |
| 414 if (transport_.get() && transport_->socket()) | 426 if (transport_.get() && transport_->socket()) |
| 415 transport_->socket()->Disconnect(); | 427 transport_->socket()->Disconnect(); |
| 416 transport_.reset(); | 428 transport_.reset(); |
| 417 } | 429 } |
| 418 | 430 |
| 419 } // namespace jingle_glue | 431 } // namespace jingle_glue |
| OLD | NEW |