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

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

Issue 8898036: base::Bind: Convert proxy_resolving_client_socket.[cc,h] and deps. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years 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
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_pool.h" 5 #include "net/socket/socks_client_socket_pool.h"
6 6
7 #include "base/time.h" 7 #include "base/time.h"
csilv 2011/12/14 20:10:19 #include base/bind.h, base/bind_helpers.h
James Hawkins 2011/12/14 20:59:05 Done.
8 #include "base/values.h" 8 #include "base/values.h"
9 #include "net/base/net_errors.h" 9 #include "net/base/net_errors.h"
10 #include "net/socket/client_socket_factory.h" 10 #include "net/socket/client_socket_factory.h"
11 #include "net/socket/client_socket_handle.h" 11 #include "net/socket/client_socket_handle.h"
12 #include "net/socket/client_socket_pool_base.h" 12 #include "net/socket/client_socket_pool_base.h"
13 #include "net/socket/socks5_client_socket.h" 13 #include "net/socket/socks5_client_socket.h"
14 #include "net/socket/socks_client_socket.h" 14 #include "net/socket/socks_client_socket.h"
15 #include "net/socket/transport_client_socket_pool.h" 15 #include "net/socket/transport_client_socket_pool.h"
16 16
17 namespace net { 17 namespace net {
(...skipping 25 matching lines...) Expand all
43 const base::TimeDelta& timeout_duration, 43 const base::TimeDelta& timeout_duration,
44 TransportClientSocketPool* transport_pool, 44 TransportClientSocketPool* transport_pool,
45 HostResolver* host_resolver, 45 HostResolver* host_resolver,
46 Delegate* delegate, 46 Delegate* delegate,
47 NetLog* net_log) 47 NetLog* net_log)
48 : ConnectJob(group_name, timeout_duration, delegate, 48 : ConnectJob(group_name, timeout_duration, delegate,
49 BoundNetLog::Make(net_log, NetLog::SOURCE_CONNECT_JOB)), 49 BoundNetLog::Make(net_log, NetLog::SOURCE_CONNECT_JOB)),
50 socks_params_(socks_params), 50 socks_params_(socks_params),
51 transport_pool_(transport_pool), 51 transport_pool_(transport_pool),
52 resolver_(host_resolver), 52 resolver_(host_resolver),
53 ALLOW_THIS_IN_INITIALIZER_LIST( 53 ALLOW_THIS_IN_INITIALIZER_LIST(callback_(
54 callback_old_(this, &SOCKSConnectJob::OnIOComplete)) { 54 base::Bind(&SOCKSConnectJob::OnIOComplete, base::Unretained(this)))) {
55 } 55 }
56 56
57 SOCKSConnectJob::~SOCKSConnectJob() { 57 SOCKSConnectJob::~SOCKSConnectJob() {
58 // We don't worry about cancelling the tcp socket since the destructor in 58 // We don't worry about cancelling the tcp socket since the destructor in
59 // scoped_ptr<ClientSocketHandle> transport_socket_handle_ will take care of 59 // scoped_ptr<ClientSocketHandle> transport_socket_handle_ will take care of
60 // it. 60 // it.
61 } 61 }
62 62
63 LoadState SOCKSConnectJob::GetLoadState() const { 63 LoadState SOCKSConnectJob::GetLoadState() const {
64 switch (next_state_) { 64 switch (next_state_) {
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 break; 108 break;
109 } 109 }
110 } while (rv != ERR_IO_PENDING && next_state_ != STATE_NONE); 110 } while (rv != ERR_IO_PENDING && next_state_ != STATE_NONE);
111 111
112 return rv; 112 return rv;
113 } 113 }
114 114
115 int SOCKSConnectJob::DoTransportConnect() { 115 int SOCKSConnectJob::DoTransportConnect() {
116 next_state_ = STATE_TRANSPORT_CONNECT_COMPLETE; 116 next_state_ = STATE_TRANSPORT_CONNECT_COMPLETE;
117 transport_socket_handle_.reset(new ClientSocketHandle()); 117 transport_socket_handle_.reset(new ClientSocketHandle());
118 return transport_socket_handle_->Init(group_name(), 118 return transport_socket_handle_->Init(
119 socks_params_->transport_params(), 119 group_name(), socks_params_->transport_params(),
120 socks_params_->destination().priority(), 120 socks_params_->destination().priority(), callback_, transport_pool_,
121 &callback_old_, 121 net_log());
122 transport_pool_,
123 net_log());
124 } 122 }
125 123
126 int SOCKSConnectJob::DoTransportConnectComplete(int result) { 124 int SOCKSConnectJob::DoTransportConnectComplete(int result) {
127 if (result != OK) 125 if (result != OK)
128 return ERR_PROXY_CONNECTION_FAILED; 126 return ERR_PROXY_CONNECTION_FAILED;
129 127
130 // Reset the timer to just the length of time allowed for SOCKS handshake 128 // Reset the timer to just the length of time allowed for SOCKS handshake
131 // so that a fast TCP connection plus a slow SOCKS failure doesn't take 129 // so that a fast TCP connection plus a slow SOCKS failure doesn't take
132 // longer to timeout than it should. 130 // longer to timeout than it should.
133 ResetTimer(base::TimeDelta::FromSeconds(kSOCKSConnectJobTimeoutInSeconds)); 131 ResetTimer(base::TimeDelta::FromSeconds(kSOCKSConnectJobTimeoutInSeconds));
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 return base_.histograms(); 299 return base_.histograms();
302 }; 300 };
303 301
304 bool SOCKSClientSocketPool::CloseOneIdleConnection() { 302 bool SOCKSClientSocketPool::CloseOneIdleConnection() {
305 if (base_.CloseOneIdleSocket()) 303 if (base_.CloseOneIdleSocket())
306 return true; 304 return true;
307 return base_.CloseOneIdleConnectionInLayeredPool(); 305 return base_.CloseOneIdleConnectionInLayeredPool();
308 } 306 }
309 307
310 } // namespace net 308 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698