[email protected] | e34400c3 | 2012-01-24 02:49:33 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
[email protected] | a796bcec | 2010-03-22 17:17:26 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #include "net/socket/socks_client_socket_pool.h" |
| 6 | |
dcheng | c7eeda42 | 2015-12-26 03:56:48 | [diff] [blame] | 7 | #include <utility> |
| 8 | |
[email protected] | 6ecf2b9 | 2011-12-15 01:14:52 | [diff] [blame] | 9 | #include "base/bind.h" |
| 10 | #include "base/bind_helpers.h" |
[email protected] | f002abb | 2013-06-28 02:30:21 | [diff] [blame] | 11 | #include "base/time/time.h" |
[email protected] | ba00b49 | 2010-09-08 14:53:38 | [diff] [blame] | 12 | #include "base/values.h" |
[email protected] | a796bcec | 2010-03-22 17:17:26 | [diff] [blame] | 13 | #include "net/base/net_errors.h" |
mikecirone | 8b85c43 | 2016-09-08 19:11:00 | [diff] [blame] | 14 | #include "net/log/net_log_source_type.h" |
mikecirone | f22f981 | 2016-10-04 03:40:19 | [diff] [blame^] | 15 | #include "net/log/net_log_with_source.h" |
[email protected] | a796bcec | 2010-03-22 17:17:26 | [diff] [blame] | 16 | #include "net/socket/client_socket_factory.h" |
| 17 | #include "net/socket/client_socket_handle.h" |
| 18 | #include "net/socket/client_socket_pool_base.h" |
| 19 | #include "net/socket/socks5_client_socket.h" |
| 20 | #include "net/socket/socks_client_socket.h" |
[email protected] | ab73904 | 2011-04-07 15:22:28 | [diff] [blame] | 21 | #include "net/socket/transport_client_socket_pool.h" |
[email protected] | a796bcec | 2010-03-22 17:17:26 | [diff] [blame] | 22 | |
| 23 | namespace net { |
| 24 | |
mikecirone | f22f981 | 2016-10-04 03:40:19 | [diff] [blame^] | 25 | class NetLog; |
| 26 | |
[email protected] | df4b4ef | 2010-07-12 18:25:21 | [diff] [blame] | 27 | SOCKSSocketParams::SOCKSSocketParams( |
[email protected] | ab73904 | 2011-04-07 15:22:28 | [diff] [blame] | 28 | const scoped_refptr<TransportSocketParams>& proxy_server, |
[email protected] | df4b4ef | 2010-07-12 18:25:21 | [diff] [blame] | 29 | bool socks_v5, |
[email protected] | 3f6007ab | 2013-08-22 19:45:39 | [diff] [blame] | 30 | const HostPortPair& host_port_pair) |
[email protected] | ab73904 | 2011-04-07 15:22:28 | [diff] [blame] | 31 | : transport_params_(proxy_server), |
[email protected] | 5109c195 | 2013-08-20 18:44:10 | [diff] [blame] | 32 | destination_(host_port_pair), |
[email protected] | df4b4ef | 2010-07-12 18:25:21 | [diff] [blame] | 33 | socks_v5_(socks_v5) { |
[email protected] | df4b4ef | 2010-07-12 18:25:21 | [diff] [blame] | 34 | } |
| 35 | |
| 36 | SOCKSSocketParams::~SOCKSSocketParams() {} |
| 37 | |
[email protected] | a796bcec | 2010-03-22 17:17:26 | [diff] [blame] | 38 | // SOCKSConnectJobs will time out after this many seconds. Note this is on |
| 39 | // top of the timeout for the transport socket. |
| 40 | static const int kSOCKSConnectJobTimeoutInSeconds = 30; |
| 41 | |
| 42 | SOCKSConnectJob::SOCKSConnectJob( |
| 43 | const std::string& group_name, |
[email protected] | 3f6007ab | 2013-08-22 19:45:39 | [diff] [blame] | 44 | RequestPriority priority, |
mmenke | d3641e1 | 2016-01-28 16:06:15 | [diff] [blame] | 45 | ClientSocketPool::RespectLimits respect_limits, |
[email protected] | df4b4ef | 2010-07-12 18:25:21 | [diff] [blame] | 46 | const scoped_refptr<SOCKSSocketParams>& socks_params, |
[email protected] | a796bcec | 2010-03-22 17:17:26 | [diff] [blame] | 47 | const base::TimeDelta& timeout_duration, |
[email protected] | ab73904 | 2011-04-07 15:22:28 | [diff] [blame] | 48 | TransportClientSocketPool* transport_pool, |
[email protected] | 73c4532 | 2010-10-01 23:57:54 | [diff] [blame] | 49 | HostResolver* host_resolver, |
[email protected] | a796bcec | 2010-03-22 17:17:26 | [diff] [blame] | 50 | Delegate* delegate, |
[email protected] | 06650c5 | 2010-06-03 00:49:17 | [diff] [blame] | 51 | NetLog* net_log) |
tfarina | 42834111 | 2016-09-22 13:38:20 | [diff] [blame] | 52 | : ConnectJob( |
| 53 | group_name, |
| 54 | timeout_duration, |
| 55 | priority, |
| 56 | respect_limits, |
| 57 | delegate, |
| 58 | NetLogWithSource::Make(net_log, NetLogSourceType::CONNECT_JOB)), |
[email protected] | a796bcec | 2010-03-22 17:17:26 | [diff] [blame] | 59 | socks_params_(socks_params), |
[email protected] | ab73904 | 2011-04-07 15:22:28 | [diff] [blame] | 60 | transport_pool_(transport_pool), |
[email protected] | a796bcec | 2010-03-22 17:17:26 | [diff] [blame] | 61 | resolver_(host_resolver), |
mmenke | d3641e1 | 2016-01-28 16:06:15 | [diff] [blame] | 62 | callback_( |
| 63 | base::Bind(&SOCKSConnectJob::OnIOComplete, base::Unretained(this))) {} |
[email protected] | a796bcec | 2010-03-22 17:17:26 | [diff] [blame] | 64 | |
| 65 | SOCKSConnectJob::~SOCKSConnectJob() { |
| 66 | // We don't worry about cancelling the tcp socket since the destructor in |
danakj | 655b66c | 2016-04-16 00:51:38 | [diff] [blame] | 67 | // std::unique_ptr<ClientSocketHandle> transport_socket_handle_ will take care |
| 68 | // of |
[email protected] | ab73904 | 2011-04-07 15:22:28 | [diff] [blame] | 69 | // it. |
[email protected] | a796bcec | 2010-03-22 17:17:26 | [diff] [blame] | 70 | } |
| 71 | |
| 72 | LoadState SOCKSConnectJob::GetLoadState() const { |
| 73 | switch (next_state_) { |
[email protected] | ab73904 | 2011-04-07 15:22:28 | [diff] [blame] | 74 | case STATE_TRANSPORT_CONNECT: |
| 75 | case STATE_TRANSPORT_CONNECT_COMPLETE: |
| 76 | return transport_socket_handle_->GetLoadState(); |
[email protected] | 81854c4 | 2010-09-22 03:39:36 | [diff] [blame] | 77 | case STATE_SOCKS_CONNECT: |
| 78 | case STATE_SOCKS_CONNECT_COMPLETE: |
[email protected] | a796bcec | 2010-03-22 17:17:26 | [diff] [blame] | 79 | return LOAD_STATE_CONNECTING; |
| 80 | default: |
| 81 | NOTREACHED(); |
| 82 | return LOAD_STATE_IDLE; |
| 83 | } |
| 84 | } |
| 85 | |
[email protected] | a796bcec | 2010-03-22 17:17:26 | [diff] [blame] | 86 | void SOCKSConnectJob::OnIOComplete(int result) { |
| 87 | int rv = DoLoop(result); |
| 88 | if (rv != ERR_IO_PENDING) |
| 89 | NotifyDelegateOfCompletion(rv); // Deletes |this| |
| 90 | } |
| 91 | |
| 92 | int SOCKSConnectJob::DoLoop(int result) { |
[email protected] | 81854c4 | 2010-09-22 03:39:36 | [diff] [blame] | 93 | DCHECK_NE(next_state_, STATE_NONE); |
[email protected] | a796bcec | 2010-03-22 17:17:26 | [diff] [blame] | 94 | |
| 95 | int rv = result; |
| 96 | do { |
| 97 | State state = next_state_; |
[email protected] | 81854c4 | 2010-09-22 03:39:36 | [diff] [blame] | 98 | next_state_ = STATE_NONE; |
[email protected] | a796bcec | 2010-03-22 17:17:26 | [diff] [blame] | 99 | switch (state) { |
[email protected] | ab73904 | 2011-04-07 15:22:28 | [diff] [blame] | 100 | case STATE_TRANSPORT_CONNECT: |
[email protected] | a796bcec | 2010-03-22 17:17:26 | [diff] [blame] | 101 | DCHECK_EQ(OK, rv); |
[email protected] | ab73904 | 2011-04-07 15:22:28 | [diff] [blame] | 102 | rv = DoTransportConnect(); |
[email protected] | a796bcec | 2010-03-22 17:17:26 | [diff] [blame] | 103 | break; |
[email protected] | ab73904 | 2011-04-07 15:22:28 | [diff] [blame] | 104 | case STATE_TRANSPORT_CONNECT_COMPLETE: |
| 105 | rv = DoTransportConnectComplete(rv); |
[email protected] | a796bcec | 2010-03-22 17:17:26 | [diff] [blame] | 106 | break; |
[email protected] | 81854c4 | 2010-09-22 03:39:36 | [diff] [blame] | 107 | case STATE_SOCKS_CONNECT: |
[email protected] | a796bcec | 2010-03-22 17:17:26 | [diff] [blame] | 108 | DCHECK_EQ(OK, rv); |
| 109 | rv = DoSOCKSConnect(); |
| 110 | break; |
[email protected] | 81854c4 | 2010-09-22 03:39:36 | [diff] [blame] | 111 | case STATE_SOCKS_CONNECT_COMPLETE: |
[email protected] | a796bcec | 2010-03-22 17:17:26 | [diff] [blame] | 112 | rv = DoSOCKSConnectComplete(rv); |
| 113 | break; |
| 114 | default: |
| 115 | NOTREACHED() << "bad state"; |
| 116 | rv = ERR_FAILED; |
| 117 | break; |
| 118 | } |
[email protected] | 81854c4 | 2010-09-22 03:39:36 | [diff] [blame] | 119 | } while (rv != ERR_IO_PENDING && next_state_ != STATE_NONE); |
[email protected] | a796bcec | 2010-03-22 17:17:26 | [diff] [blame] | 120 | |
| 121 | return rv; |
| 122 | } |
| 123 | |
[email protected] | ab73904 | 2011-04-07 15:22:28 | [diff] [blame] | 124 | int SOCKSConnectJob::DoTransportConnect() { |
| 125 | next_state_ = STATE_TRANSPORT_CONNECT_COMPLETE; |
| 126 | transport_socket_handle_.reset(new ClientSocketHandle()); |
mmenke | d3641e1 | 2016-01-28 16:06:15 | [diff] [blame] | 127 | return transport_socket_handle_->Init( |
| 128 | group_name(), socks_params_->transport_params(), priority(), |
| 129 | respect_limits(), callback_, transport_pool_, net_log()); |
[email protected] | a796bcec | 2010-03-22 17:17:26 | [diff] [blame] | 130 | } |
| 131 | |
[email protected] | ab73904 | 2011-04-07 15:22:28 | [diff] [blame] | 132 | int SOCKSConnectJob::DoTransportConnectComplete(int result) { |
[email protected] | a796bcec | 2010-03-22 17:17:26 | [diff] [blame] | 133 | if (result != OK) |
[email protected] | f7fccee | 2010-09-16 20:53:01 | [diff] [blame] | 134 | return ERR_PROXY_CONNECTION_FAILED; |
[email protected] | a796bcec | 2010-03-22 17:17:26 | [diff] [blame] | 135 | |
| 136 | // Reset the timer to just the length of time allowed for SOCKS handshake |
| 137 | // so that a fast TCP connection plus a slow SOCKS failure doesn't take |
| 138 | // longer to timeout than it should. |
| 139 | ResetTimer(base::TimeDelta::FromSeconds(kSOCKSConnectJobTimeoutInSeconds)); |
[email protected] | 81854c4 | 2010-09-22 03:39:36 | [diff] [blame] | 140 | next_state_ = STATE_SOCKS_CONNECT; |
[email protected] | a796bcec | 2010-03-22 17:17:26 | [diff] [blame] | 141 | return result; |
| 142 | } |
| 143 | |
| 144 | int SOCKSConnectJob::DoSOCKSConnect() { |
[email protected] | 81854c4 | 2010-09-22 03:39:36 | [diff] [blame] | 145 | next_state_ = STATE_SOCKS_CONNECT_COMPLETE; |
[email protected] | a796bcec | 2010-03-22 17:17:26 | [diff] [blame] | 146 | |
| 147 | // Add a SOCKS connection on top of the tcp socket. |
[email protected] | df4b4ef | 2010-07-12 18:25:21 | [diff] [blame] | 148 | if (socks_params_->is_socks_v5()) { |
dcheng | c7eeda42 | 2015-12-26 03:56:48 | [diff] [blame] | 149 | socket_.reset(new SOCKS5ClientSocket(std::move(transport_socket_handle_), |
[email protected] | df4b4ef | 2010-07-12 18:25:21 | [diff] [blame] | 150 | socks_params_->destination())); |
[email protected] | a796bcec | 2010-03-22 17:17:26 | [diff] [blame] | 151 | } else { |
dcheng | c7eeda42 | 2015-12-26 03:56:48 | [diff] [blame] | 152 | socket_.reset(new SOCKSClientSocket(std::move(transport_socket_handle_), |
[email protected] | df4b4ef | 2010-07-12 18:25:21 | [diff] [blame] | 153 | socks_params_->destination(), |
dcheng | c7eeda42 | 2015-12-26 03:56:48 | [diff] [blame] | 154 | priority(), resolver_)); |
[email protected] | a796bcec | 2010-03-22 17:17:26 | [diff] [blame] | 155 | } |
[email protected] | 83039bb | 2011-12-09 18:43:55 | [diff] [blame] | 156 | return socket_->Connect( |
| 157 | base::Bind(&SOCKSConnectJob::OnIOComplete, base::Unretained(this))); |
[email protected] | a796bcec | 2010-03-22 17:17:26 | [diff] [blame] | 158 | } |
| 159 | |
| 160 | int SOCKSConnectJob::DoSOCKSConnectComplete(int result) { |
| 161 | if (result != OK) { |
| 162 | socket_->Disconnect(); |
| 163 | return result; |
| 164 | } |
| 165 | |
dcheng | c7eeda42 | 2015-12-26 03:56:48 | [diff] [blame] | 166 | SetSocket(std::move(socket_)); |
[email protected] | a796bcec | 2010-03-22 17:17:26 | [diff] [blame] | 167 | return result; |
| 168 | } |
| 169 | |
[email protected] | ad74a59 | 2011-01-21 18:40:55 | [diff] [blame] | 170 | int SOCKSConnectJob::ConnectInternal() { |
[email protected] | ab73904 | 2011-04-07 15:22:28 | [diff] [blame] | 171 | next_state_ = STATE_TRANSPORT_CONNECT; |
[email protected] | ad74a59 | 2011-01-21 18:40:55 | [diff] [blame] | 172 | return DoLoop(OK); |
| 173 | } |
| 174 | |
danakj | 655b66c | 2016-04-16 00:51:38 | [diff] [blame] | 175 | std::unique_ptr<ConnectJob> |
[email protected] | 18ccfdb | 2013-08-15 00:13:44 | [diff] [blame] | 176 | SOCKSClientSocketPool::SOCKSConnectJobFactory::NewConnectJob( |
[email protected] | a796bcec | 2010-03-22 17:17:26 | [diff] [blame] | 177 | const std::string& group_name, |
| 178 | const PoolBase::Request& request, |
[email protected] | 06650c5 | 2010-06-03 00:49:17 | [diff] [blame] | 179 | ConnectJob::Delegate* delegate) const { |
danakj | 655b66c | 2016-04-16 00:51:38 | [diff] [blame] | 180 | return std::unique_ptr<ConnectJob>(new SOCKSConnectJob( |
mmenke | d3641e1 | 2016-01-28 16:06:15 | [diff] [blame] | 181 | group_name, request.priority(), request.respect_limits(), |
| 182 | request.params(), ConnectionTimeout(), transport_pool_, host_resolver_, |
| 183 | delegate, net_log_)); |
[email protected] | a796bcec | 2010-03-22 17:17:26 | [diff] [blame] | 184 | } |
| 185 | |
| 186 | base::TimeDelta |
| 187 | SOCKSClientSocketPool::SOCKSConnectJobFactory::ConnectionTimeout() const { |
[email protected] | ab73904 | 2011-04-07 15:22:28 | [diff] [blame] | 188 | return transport_pool_->ConnectionTimeout() + |
[email protected] | a796bcec | 2010-03-22 17:17:26 | [diff] [blame] | 189 | base::TimeDelta::FromSeconds(kSOCKSConnectJobTimeoutInSeconds); |
| 190 | } |
| 191 | |
| 192 | SOCKSClientSocketPool::SOCKSClientSocketPool( |
| 193 | int max_sockets, |
| 194 | int max_sockets_per_group, |
[email protected] | 73c4532 | 2010-10-01 23:57:54 | [diff] [blame] | 195 | HostResolver* host_resolver, |
[email protected] | ab73904 | 2011-04-07 15:22:28 | [diff] [blame] | 196 | TransportClientSocketPool* transport_pool, |
tbansal | 7b403bcc | 2016-04-13 22:33:21 | [diff] [blame] | 197 | SocketPerformanceWatcherFactory*, |
[email protected] | 06650c5 | 2010-06-03 00:49:17 | [diff] [blame] | 198 | NetLog* net_log) |
[email protected] | ab73904 | 2011-04-07 15:22:28 | [diff] [blame] | 199 | : transport_pool_(transport_pool), |
rkaplow | d90695c | 2015-03-25 22:12:41 | [diff] [blame] | 200 | base_( |
| 201 | this, |
| 202 | max_sockets, |
| 203 | max_sockets_per_group, |
| 204 | ClientSocketPool::unused_idle_socket_timeout(), |
| 205 | ClientSocketPool::used_idle_socket_timeout(), |
| 206 | new SOCKSConnectJobFactory(transport_pool, host_resolver, net_log)) { |
[email protected] | 51fdc7c | 2012-04-10 19:19:48 | [diff] [blame] | 207 | // We should always have a |transport_pool_| except in unit tests. |
| 208 | if (transport_pool_) |
[email protected] | 043b68c8 | 2013-08-22 23:41:52 | [diff] [blame] | 209 | base_.AddLowerLayeredPool(transport_pool_); |
[email protected] | 66761b95 | 2010-06-25 21:30:38 | [diff] [blame] | 210 | } |
[email protected] | a796bcec | 2010-03-22 17:17:26 | [diff] [blame] | 211 | |
[email protected] | 51fdc7c | 2012-04-10 19:19:48 | [diff] [blame] | 212 | SOCKSClientSocketPool::~SOCKSClientSocketPool() { |
[email protected] | 51fdc7c | 2012-04-10 19:19:48 | [diff] [blame] | 213 | } |
[email protected] | a796bcec | 2010-03-22 17:17:26 | [diff] [blame] | 214 | |
mmenke | d3641e1 | 2016-01-28 16:06:15 | [diff] [blame] | 215 | int SOCKSClientSocketPool::RequestSocket(const std::string& group_name, |
| 216 | const void* socket_params, |
| 217 | RequestPriority priority, |
| 218 | RespectLimits respect_limits, |
| 219 | ClientSocketHandle* handle, |
| 220 | const CompletionCallback& callback, |
tfarina | 42834111 | 2016-09-22 13:38:20 | [diff] [blame] | 221 | const NetLogWithSource& net_log) { |
[email protected] | df4b4ef | 2010-07-12 18:25:21 | [diff] [blame] | 222 | const scoped_refptr<SOCKSSocketParams>* casted_socket_params = |
| 223 | static_cast<const scoped_refptr<SOCKSSocketParams>*>(socket_params); |
[email protected] | a796bcec | 2010-03-22 17:17:26 | [diff] [blame] | 224 | |
| 225 | return base_.RequestSocket(group_name, *casted_socket_params, priority, |
mmenke | d3641e1 | 2016-01-28 16:06:15 | [diff] [blame] | 226 | respect_limits, handle, callback, net_log); |
[email protected] | a796bcec | 2010-03-22 17:17:26 | [diff] [blame] | 227 | } |
| 228 | |
tfarina | 42834111 | 2016-09-22 13:38:20 | [diff] [blame] | 229 | void SOCKSClientSocketPool::RequestSockets(const std::string& group_name, |
| 230 | const void* params, |
| 231 | int num_sockets, |
| 232 | const NetLogWithSource& net_log) { |
[email protected] | 2c2bef15 | 2010-10-13 00:55:03 | [diff] [blame] | 233 | const scoped_refptr<SOCKSSocketParams>* casted_params = |
| 234 | static_cast<const scoped_refptr<SOCKSSocketParams>*>(params); |
| 235 | |
| 236 | base_.RequestSockets(group_name, *casted_params, num_sockets, net_log); |
| 237 | } |
| 238 | |
[email protected] | df4b4ef | 2010-07-12 18:25:21 | [diff] [blame] | 239 | void SOCKSClientSocketPool::CancelRequest(const std::string& group_name, |
[email protected] | 05ea9ff | 2010-07-15 19:08:21 | [diff] [blame] | 240 | ClientSocketHandle* handle) { |
[email protected] | a796bcec | 2010-03-22 17:17:26 | [diff] [blame] | 241 | base_.CancelRequest(group_name, handle); |
| 242 | } |
| 243 | |
[email protected] | df4b4ef | 2010-07-12 18:25:21 | [diff] [blame] | 244 | void SOCKSClientSocketPool::ReleaseSocket(const std::string& group_name, |
danakj | 655b66c | 2016-04-16 00:51:38 | [diff] [blame] | 245 | std::unique_ptr<StreamSocket> socket, |
[email protected] | 18ccfdb | 2013-08-15 00:13:44 | [diff] [blame] | 246 | int id) { |
dcheng | c7eeda42 | 2015-12-26 03:56:48 | [diff] [blame] | 247 | base_.ReleaseSocket(group_name, std::move(socket), id); |
[email protected] | a7e3857 | 2010-06-07 18:22:24 | [diff] [blame] | 248 | } |
| 249 | |
[email protected] | 7af985a | 2012-12-14 22:40:42 | [diff] [blame] | 250 | void SOCKSClientSocketPool::FlushWithError(int error) { |
| 251 | base_.FlushWithError(error); |
[email protected] | a796bcec | 2010-03-22 17:17:26 | [diff] [blame] | 252 | } |
| 253 | |
| 254 | void SOCKSClientSocketPool::CloseIdleSockets() { |
| 255 | base_.CloseIdleSockets(); |
| 256 | } |
| 257 | |
[email protected] | 7cf4091 | 2010-12-09 18:25:03 | [diff] [blame] | 258 | int SOCKSClientSocketPool::IdleSocketCount() const { |
| 259 | return base_.idle_socket_count(); |
| 260 | } |
| 261 | |
[email protected] | a796bcec | 2010-03-22 17:17:26 | [diff] [blame] | 262 | int SOCKSClientSocketPool::IdleSocketCountInGroup( |
| 263 | const std::string& group_name) const { |
| 264 | return base_.IdleSocketCountInGroup(group_name); |
| 265 | } |
| 266 | |
| 267 | LoadState SOCKSClientSocketPool::GetLoadState( |
| 268 | const std::string& group_name, const ClientSocketHandle* handle) const { |
| 269 | return base_.GetLoadState(group_name, handle); |
| 270 | } |
| 271 | |
danakj | 655b66c | 2016-04-16 00:51:38 | [diff] [blame] | 272 | std::unique_ptr<base::DictionaryValue> SOCKSClientSocketPool::GetInfoAsValue( |
[email protected] | ba00b49 | 2010-09-08 14:53:38 | [diff] [blame] | 273 | const std::string& name, |
| 274 | const std::string& type, |
| 275 | bool include_nested_pools) const { |
danakj | 655b66c | 2016-04-16 00:51:38 | [diff] [blame] | 276 | std::unique_ptr<base::DictionaryValue> dict(base_.GetInfoAsValue(name, type)); |
[email protected] | ba00b49 | 2010-09-08 14:53:38 | [diff] [blame] | 277 | if (include_nested_pools) { |
danakj | 655b66c | 2016-04-16 00:51:38 | [diff] [blame] | 278 | std::unique_ptr<base::ListValue> list(new base::ListValue()); |
[email protected] | ab73904 | 2011-04-07 15:22:28 | [diff] [blame] | 279 | list->Append(transport_pool_->GetInfoAsValue("transport_socket_pool", |
| 280 | "transport_socket_pool", |
| 281 | false)); |
dcheng | c7eeda42 | 2015-12-26 03:56:48 | [diff] [blame] | 282 | dict->Set("nested_pools", std::move(list)); |
[email protected] | ba00b49 | 2010-09-08 14:53:38 | [diff] [blame] | 283 | } |
dcheng | c7eeda42 | 2015-12-26 03:56:48 | [diff] [blame] | 284 | return dict; |
[email protected] | ba00b49 | 2010-09-08 14:53:38 | [diff] [blame] | 285 | } |
| 286 | |
[email protected] | 7cf4091 | 2010-12-09 18:25:03 | [diff] [blame] | 287 | base::TimeDelta SOCKSClientSocketPool::ConnectionTimeout() const { |
| 288 | return base_.ConnectionTimeout(); |
| 289 | } |
| 290 | |
[email protected] | 043b68c8 | 2013-08-22 23:41:52 | [diff] [blame] | 291 | bool SOCKSClientSocketPool::IsStalled() const { |
| 292 | return base_.IsStalled(); |
| 293 | } |
| 294 | |
| 295 | void SOCKSClientSocketPool::AddHigherLayeredPool( |
| 296 | HigherLayeredPool* higher_pool) { |
| 297 | base_.AddHigherLayeredPool(higher_pool); |
| 298 | } |
| 299 | |
| 300 | void SOCKSClientSocketPool::RemoveHigherLayeredPool( |
| 301 | HigherLayeredPool* higher_pool) { |
| 302 | base_.RemoveHigherLayeredPool(higher_pool); |
| 303 | } |
| 304 | |
[email protected] | 51fdc7c | 2012-04-10 19:19:48 | [diff] [blame] | 305 | bool SOCKSClientSocketPool::CloseOneIdleConnection() { |
| 306 | if (base_.CloseOneIdleSocket()) |
| 307 | return true; |
[email protected] | 043b68c8 | 2013-08-22 23:41:52 | [diff] [blame] | 308 | return base_.CloseOneIdleConnectionInHigherLayeredPool(); |
[email protected] | 51fdc7c | 2012-04-10 19:19:48 | [diff] [blame] | 309 | } |
| 310 | |
[email protected] | a796bcec | 2010-03-22 17:17:26 | [diff] [blame] | 311 | } // namespace net |