Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(49)

Side by Side Diff: net/socket/socks_client_socket.cc

Issue 8549004: base::Bind: Convert HostResolver::Resolve. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase. Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/socket/socks5_client_socket_unittest.cc ('k') | net/socket/socks_client_socket_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "net/socket/socks_client_socket.h" 5 #include "net/socket/socks_client_socket.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/bind.h"
8 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
9 #include "net/base/io_buffer.h" 10 #include "net/base/io_buffer.h"
10 #include "net/base/net_log.h" 11 #include "net/base/net_log.h"
11 #include "net/base/net_util.h" 12 #include "net/base/net_util.h"
12 #include "net/base/sys_addrinfo.h" 13 #include "net/base/sys_addrinfo.h"
13 #include "net/socket/client_socket_handle.h" 14 #include "net/socket/client_socket_handle.h"
14 15
15 namespace net { 16 namespace net {
16 17
17 // Every SOCKS server requests a user-id from the client. It is optional 18 // Every SOCKS server requests a user-id from the client. It is optional
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 } while (rv != ERR_IO_PENDING && next_state_ != STATE_NONE); 274 } while (rv != ERR_IO_PENDING && next_state_ != STATE_NONE);
274 return rv; 275 return rv;
275 } 276 }
276 277
277 int SOCKSClientSocket::DoResolveHost() { 278 int SOCKSClientSocket::DoResolveHost() {
278 next_state_ = STATE_RESOLVE_HOST_COMPLETE; 279 next_state_ = STATE_RESOLVE_HOST_COMPLETE;
279 // SOCKS4 only supports IPv4 addresses, so only try getting the IPv4 280 // SOCKS4 only supports IPv4 addresses, so only try getting the IPv4
280 // addresses for the target host. 281 // addresses for the target host.
281 host_request_info_.set_address_family(ADDRESS_FAMILY_IPV4); 282 host_request_info_.set_address_family(ADDRESS_FAMILY_IPV4);
282 return host_resolver_.Resolve( 283 return host_resolver_.Resolve(
283 host_request_info_, &addresses_, &io_callback_, net_log_); 284 host_request_info_, &addresses_,
285 base::Bind(&SOCKSClientSocket::OnIOComplete, base::Unretained(this)),
286 net_log_);
284 } 287 }
285 288
286 int SOCKSClientSocket::DoResolveHostComplete(int result) { 289 int SOCKSClientSocket::DoResolveHostComplete(int result) {
287 if (result != OK) { 290 if (result != OK) {
288 // Resolving the hostname failed; fail the request rather than automatically 291 // Resolving the hostname failed; fail the request rather than automatically
289 // falling back to SOCKS4a (since it can be confusing to see invalid IP 292 // falling back to SOCKS4a (since it can be confusing to see invalid IP
290 // addresses being sent to the SOCKS4 server when it doesn't support 4A.) 293 // addresses being sent to the SOCKS4 server when it doesn't support 4A.)
291 return result; 294 return result;
292 } 295 }
293 296
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
428 431
429 int SOCKSClientSocket::GetPeerAddress(AddressList* address) const { 432 int SOCKSClientSocket::GetPeerAddress(AddressList* address) const {
430 return transport_->socket()->GetPeerAddress(address); 433 return transport_->socket()->GetPeerAddress(address);
431 } 434 }
432 435
433 int SOCKSClientSocket::GetLocalAddress(IPEndPoint* address) const { 436 int SOCKSClientSocket::GetLocalAddress(IPEndPoint* address) const {
434 return transport_->socket()->GetLocalAddress(address); 437 return transport_->socket()->GetLocalAddress(address);
435 } 438 }
436 439
437 } // namespace net 440 } // namespace net
OLDNEW
« no previous file with comments | « net/socket/socks5_client_socket_unittest.cc ('k') | net/socket/socks_client_socket_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698