Chromium Code Reviews| Index: net/http/http_proxy_client_socket_pool.cc |
| diff --git a/net/http/http_proxy_client_socket_pool.cc b/net/http/http_proxy_client_socket_pool.cc |
| index 7375920d8a2daa0b4e83ed0a2447d5243913c7a5..42c99083e2ae102b936602d8dd9c3f6cbb7aa9bf 100644 |
| --- a/net/http/http_proxy_client_socket_pool.cc |
| +++ b/net/http/http_proxy_client_socket_pool.cc |
| @@ -32,6 +32,39 @@ |
| namespace net { |
| +namespace { |
| + |
| +// HttpProxyConnectJobs will time out after this many seconds. Note this is on |
| +// top of the timeout for the transport socket. |
| +// TODO(kundaji): Proxy connect timeout should be independent of platform and be |
| +// based on proxy. Bug http://crbug.com/407446. |
| +#if defined(OS_ANDROID) || defined(OS_IOS) |
| +static const int kHttpProxyConnectJobTimeoutInSeconds = 10; |
| +#else |
| +static const int kHttpProxyConnectJobTimeoutInSeconds = 30; |
| +#endif |
| + |
| +// Returns the default proxy connection timeout. |
| +base::TimeDelta GetDefaultProxyConnectionTimeout( |
| + TransportClientSocketPool* transport_pool, |
| + SSLClientSocketPool* ssl_pool) { |
| + base::TimeDelta max_pool_timeout = base::TimeDelta(); |
| + |
| +#if (!defined(OS_ANDROID) && !defined(OS_IOS)) |
| + if (transport_pool) |
| + max_pool_timeout = transport_pool->ConnectionTimeout(); |
| + if (ssl_pool) { |
| + max_pool_timeout = |
| + std::max(max_pool_timeout, ssl_pool->ConnectionTimeout()); |
| + } |
| +#endif // !defined(OS_ANDROID) && !defined(OS_IOS) |
| + |
| + return max_pool_timeout + |
| + base::TimeDelta::FromSeconds(kHttpProxyConnectJobTimeoutInSeconds); |
| +} |
| + |
| +} // namespace |
| + |
| HttpProxySocketParams::HttpProxySocketParams( |
| const scoped_refptr<TransportSocketParams>& transport_params, |
| const scoped_refptr<SSLSocketParams>& ssl_params, |
| @@ -65,16 +98,6 @@ const HostResolver::RequestInfo& HttpProxySocketParams::destination() const { |
| HttpProxySocketParams::~HttpProxySocketParams() {} |
| -// HttpProxyConnectJobs will time out after this many seconds. Note this is on |
| -// top of the timeout for the transport socket. |
| -// TODO(kundaji): Proxy connect timeout should be independent of platform and be |
| -// based on proxy. Bug http://crbug.com/407446. |
| -#if defined(OS_ANDROID) || defined(OS_IOS) |
| -static const int kHttpProxyConnectJobTimeoutInSeconds = 10; |
| -#else |
| -static const int kHttpProxyConnectJobTimeoutInSeconds = 30; |
| -#endif |
| - |
| HttpProxyConnectJob::HttpProxyConnectJob( |
| const std::string& group_name, |
| RequestPriority priority, |
| @@ -149,29 +172,15 @@ int HttpProxyConnectJob::HandleConnectResult(int result) { |
| return result; |
| } |
| -HttpProxyClientSocketPool:: |
| -HttpProxyConnectJobFactory::HttpProxyConnectJobFactory( |
| - TransportClientSocketPool* transport_pool, |
| - SSLClientSocketPool* ssl_pool, |
| - NetLog* net_log) |
| +HttpProxyClientSocketPool::HttpProxyConnectJobFactory:: |
| + HttpProxyConnectJobFactory(TransportClientSocketPool* transport_pool, |
| + SSLClientSocketPool* ssl_pool, |
| + NetworkQualityProvider* network_quality_provider, |
| + NetLog* net_log) |
| : transport_pool_(transport_pool), |
| ssl_pool_(ssl_pool), |
| - net_log_(net_log) { |
| - base::TimeDelta max_pool_timeout = base::TimeDelta(); |
| - |
| -// TODO(kundaji): Proxy connect timeout should be independent of platform and be |
| -// based on proxy. Bug http://crbug.com/407446. |
| -#if (defined(OS_ANDROID) || defined(OS_IOS)) |
| -#else |
| - if (transport_pool_) |
| - max_pool_timeout = transport_pool_->ConnectionTimeout(); |
| - if (ssl_pool_) |
| - max_pool_timeout = std::max(max_pool_timeout, |
| - ssl_pool_->ConnectionTimeout()); |
| -#endif |
| - timeout_ = max_pool_timeout + |
| - base::TimeDelta::FromSeconds(kHttpProxyConnectJobTimeoutInSeconds); |
| -} |
| + network_quality_provider_(network_quality_provider), |
| + net_log_(net_log) {} |
| std::unique_ptr<ConnectJob> |
| HttpProxyClientSocketPool::HttpProxyConnectJobFactory::NewConnectJob( |
| @@ -187,7 +196,11 @@ HttpProxyClientSocketPool::HttpProxyConnectJobFactory::NewConnectJob( |
| base::TimeDelta |
| HttpProxyClientSocketPool::HttpProxyConnectJobFactory::ConnectionTimeout( |
| ) const { |
| - return timeout_; |
| + // TODO(tbansal): https://crbug.com/704339. Use |network_quality_provider_| |
| + // and field trial to determine the connection timeout. |
| + // Silence unused variable warning. |
|
mmenke
2017/06/08 17:53:02
Could we just pass it in to GetDefaultProxyConnect
tbansal1
2017/06/08 19:59:14
Ok, then I am keeping everything here, and removin
mmenke
2017/06/08 20:02:10
SGTM.
|
| + (void)network_quality_provider_; |
| + return GetDefaultProxyConnectionTimeout(transport_pool_, ssl_pool_); |
| } |
| HttpProxyClientSocketPool::HttpProxyClientSocketPool( |
| @@ -195,6 +208,7 @@ HttpProxyClientSocketPool::HttpProxyClientSocketPool( |
| int max_sockets_per_group, |
| TransportClientSocketPool* transport_pool, |
| SSLClientSocketPool* ssl_pool, |
| + NetworkQualityProvider* network_quality_provider, |
| NetLog* net_log) |
| : transport_pool_(transport_pool), |
| ssl_pool_(ssl_pool), |
| @@ -203,7 +217,10 @@ HttpProxyClientSocketPool::HttpProxyClientSocketPool( |
| max_sockets_per_group, |
| ClientSocketPool::unused_idle_socket_timeout(), |
| ClientSocketPool::used_idle_socket_timeout(), |
| - new HttpProxyConnectJobFactory(transport_pool, ssl_pool, net_log)) { |
| + new HttpProxyConnectJobFactory(transport_pool, |
| + ssl_pool, |
| + network_quality_provider, |
| + net_log)) { |
| // We should always have a |transport_pool_| except in unit tests. |
| if (transport_pool_) |
| base_.AddLowerLayeredPool(transport_pool_); |