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 <stdint.h> | 7 #include <stdint.h> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
11 #include "base/bind_helpers.h" | 11 #include "base/bind_helpers.h" |
12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
13 #include "base/logging.h" | 13 #include "base/logging.h" |
14 #include "net/base/io_buffer.h" | 14 #include "net/base/io_buffer.h" |
| 15 #include "net/base/ip_address.h" |
15 #include "net/base/load_flags.h" | 16 #include "net/base/load_flags.h" |
16 #include "net/base/net_errors.h" | 17 #include "net/base/net_errors.h" |
17 #include "net/http/http_auth_controller.h" | 18 #include "net/http/http_auth_controller.h" |
18 #include "net/http/http_network_session.h" | 19 #include "net/http/http_network_session.h" |
19 #include "net/http/proxy_client_socket.h" | 20 #include "net/http/proxy_client_socket.h" |
20 #include "net/socket/client_socket_handle.h" | 21 #include "net/socket/client_socket_handle.h" |
21 #include "net/socket/client_socket_pool_manager.h" | 22 #include "net/socket/client_socket_pool_manager.h" |
22 #include "net/url_request/url_request_context.h" | 23 #include "net/url_request/url_request_context.h" |
23 #include "net/url_request/url_request_context_getter.h" | 24 #include "net/url_request/url_request_context_getter.h" |
24 | 25 |
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
347 int ProxyResolvingClientSocket::GetPeerAddress( | 348 int ProxyResolvingClientSocket::GetPeerAddress( |
348 net::IPEndPoint* address) const { | 349 net::IPEndPoint* address) const { |
349 if (!transport_.get() || !transport_->socket()) { | 350 if (!transport_.get() || !transport_->socket()) { |
350 NOTREACHED(); | 351 NOTREACHED(); |
351 return net::ERR_SOCKET_NOT_CONNECTED; | 352 return net::ERR_SOCKET_NOT_CONNECTED; |
352 } | 353 } |
353 | 354 |
354 if (proxy_info_.is_direct()) | 355 if (proxy_info_.is_direct()) |
355 return transport_->socket()->GetPeerAddress(address); | 356 return transport_->socket()->GetPeerAddress(address); |
356 | 357 |
357 net::IPAddressNumber ip_number; | 358 net::IPAddress ip_address; |
358 if (!net::ParseIPLiteralToNumber(dest_host_port_pair_.host(), &ip_number)) { | 359 if (!ip_address.AssignFromIPLiteral(dest_host_port_pair_.host())) { |
359 // Do not expose the proxy IP address to the caller. | 360 // Do not expose the proxy IP address to the caller. |
360 return net::ERR_NAME_NOT_RESOLVED; | 361 return net::ERR_NAME_NOT_RESOLVED; |
361 } | 362 } |
362 | 363 |
363 *address = net::IPEndPoint(ip_number, dest_host_port_pair_.port()); | 364 *address = net::IPEndPoint(ip_address, dest_host_port_pair_.port()); |
364 return net::OK; | 365 return net::OK; |
365 } | 366 } |
366 | 367 |
367 int ProxyResolvingClientSocket::GetLocalAddress( | 368 int ProxyResolvingClientSocket::GetLocalAddress( |
368 net::IPEndPoint* address) const { | 369 net::IPEndPoint* address) const { |
369 if (transport_.get() && transport_->socket()) | 370 if (transport_.get() && transport_->socket()) |
370 return transport_->socket()->GetLocalAddress(address); | 371 return transport_->socket()->GetLocalAddress(address); |
371 NOTREACHED(); | 372 NOTREACHED(); |
372 return net::ERR_SOCKET_NOT_CONNECTED; | 373 return net::ERR_SOCKET_NOT_CONNECTED; |
373 } | 374 } |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
425 return 0; | 426 return 0; |
426 } | 427 } |
427 | 428 |
428 void ProxyResolvingClientSocket::CloseTransportSocket() { | 429 void ProxyResolvingClientSocket::CloseTransportSocket() { |
429 if (transport_.get() && transport_->socket()) | 430 if (transport_.get() && transport_->socket()) |
430 transport_->socket()->Disconnect(); | 431 transport_->socket()->Disconnect(); |
431 transport_.reset(); | 432 transport_.reset(); |
432 } | 433 } |
433 | 434 |
434 } // namespace jingle_glue | 435 } // namespace jingle_glue |
OLD | NEW |