| 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 "net/socket/client_socket_pool_manager.h" | 5 #include "net/socket/client_socket_pool_manager.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 const SSLConfig& ssl_config_for_origin, | 77 const SSLConfig& ssl_config_for_origin, |
| 78 const SSLConfig& ssl_config_for_proxy, | 78 const SSLConfig& ssl_config_for_proxy, |
| 79 bool force_tunnel, | 79 bool force_tunnel, |
| 80 PrivacyMode privacy_mode, | 80 PrivacyMode privacy_mode, |
| 81 const BoundNetLog& net_log, | 81 const BoundNetLog& net_log, |
| 82 int num_preconnect_streams, | 82 int num_preconnect_streams, |
| 83 ClientSocketHandle* socket_handle, | 83 ClientSocketHandle* socket_handle, |
| 84 HttpNetworkSession::SocketPoolType socket_pool_type, | 84 HttpNetworkSession::SocketPoolType socket_pool_type, |
| 85 const OnHostResolutionCallback& resolution_callback, | 85 const OnHostResolutionCallback& resolution_callback, |
| 86 const CompletionCallback& callback) { | 86 const CompletionCallback& callback) { |
| 87 scoped_refptr<TransportSocketParams> tcp_params; | |
| 88 scoped_refptr<HttpProxySocketParams> http_proxy_params; | 87 scoped_refptr<HttpProxySocketParams> http_proxy_params; |
| 89 scoped_refptr<SOCKSSocketParams> socks_params; | 88 scoped_refptr<SOCKSSocketParams> socks_params; |
| 90 scoped_ptr<HostPortPair> proxy_host_port; | 89 scoped_ptr<HostPortPair> proxy_host_port; |
| 91 | 90 |
| 92 bool using_ssl = request_url.SchemeIs("https") || | 91 bool using_ssl = request_url.SchemeIs("https") || |
| 93 request_url.SchemeIs("wss") || force_spdy_over_ssl; | 92 request_url.SchemeIs("wss") || force_spdy_over_ssl; |
| 94 | 93 |
| 95 HostPortPair origin_host_port = | 94 HostPortPair origin_host_port = |
| 96 HostPortPair(request_url.HostNoBrackets(), | 95 HostPortPair(request_url.HostNoBrackets(), |
| 97 request_url.EffectiveIntPort()); | 96 request_url.EffectiveIntPort()); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 break; | 147 break; |
| 149 default: | 148 default: |
| 150 CHECK(false); | 149 CHECK(false); |
| 151 break; | 150 break; |
| 152 } | 151 } |
| 153 } | 152 } |
| 154 connection_group = prefix + connection_group; | 153 connection_group = prefix + connection_group; |
| 155 } | 154 } |
| 156 | 155 |
| 157 bool ignore_limits = (request_load_flags & LOAD_IGNORE_LIMITS) != 0; | 156 bool ignore_limits = (request_load_flags & LOAD_IGNORE_LIMITS) != 0; |
| 158 if (proxy_info.is_direct()) { | 157 if (!proxy_info.is_direct()) { |
| 159 tcp_params = new TransportSocketParams(origin_host_port, | |
| 160 disable_resolver_cache, | |
| 161 ignore_limits, | |
| 162 resolution_callback); | |
| 163 } else { | |
| 164 ProxyServer proxy_server = proxy_info.proxy_server(); | 158 ProxyServer proxy_server = proxy_info.proxy_server(); |
| 165 proxy_host_port.reset(new HostPortPair(proxy_server.host_port_pair())); | 159 proxy_host_port.reset(new HostPortPair(proxy_server.host_port_pair())); |
| 166 scoped_refptr<TransportSocketParams> proxy_tcp_params( | 160 scoped_refptr<TransportSocketParams> proxy_tcp_params( |
| 167 new TransportSocketParams(*proxy_host_port, | 161 new TransportSocketParams(*proxy_host_port, |
| 168 disable_resolver_cache, | 162 disable_resolver_cache, |
| 169 ignore_limits, | 163 ignore_limits, |
| 170 resolution_callback)); | 164 resolution_callback, |
| 165 AUTO_CONNECT_USE_DEFAULT)); |
| 171 | 166 |
| 172 if (proxy_info.is_http() || proxy_info.is_https()) { | 167 if (proxy_info.is_http() || proxy_info.is_https()) { |
| 173 std::string user_agent; | 168 std::string user_agent; |
| 174 request_extra_headers.GetHeader(HttpRequestHeaders::kUserAgent, | 169 request_extra_headers.GetHeader(HttpRequestHeaders::kUserAgent, |
| 175 &user_agent); | 170 &user_agent); |
| 176 scoped_refptr<SSLSocketParams> ssl_params; | 171 scoped_refptr<SSLSocketParams> ssl_params; |
| 177 if (proxy_info.is_https()) { | 172 if (proxy_info.is_https()) { |
| 173 // TODO (jri): Enable a finch trial to use AUTO_CONNECT_ENABLED |
| 174 // for SSL sockets. |
| 175 proxy_tcp_params = |
| 176 new TransportSocketParams(*proxy_host_port, |
| 177 disable_resolver_cache, |
| 178 ignore_limits, |
| 179 resolution_callback, |
| 180 AUTO_CONNECT_USE_DEFAULT); |
| 178 // Set ssl_params, and unset proxy_tcp_params | 181 // Set ssl_params, and unset proxy_tcp_params |
| 179 ssl_params = new SSLSocketParams(proxy_tcp_params, | 182 ssl_params = new SSLSocketParams(proxy_tcp_params, |
| 180 NULL, | 183 NULL, |
| 181 NULL, | 184 NULL, |
| 182 *proxy_host_port.get(), | 185 *proxy_host_port.get(), |
| 183 ssl_config_for_proxy, | 186 ssl_config_for_proxy, |
| 184 PRIVACY_MODE_DISABLED, | 187 PRIVACY_MODE_DISABLED, |
| 185 load_flags, | 188 load_flags, |
| 186 force_spdy_over_ssl, | 189 force_spdy_over_ssl, |
| 187 want_spdy_over_npn); | 190 want_spdy_over_npn); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 213 origin_host_port); | 216 origin_host_port); |
| 214 } | 217 } |
| 215 } | 218 } |
| 216 | 219 |
| 217 // Change group name if privacy mode is enabled. | 220 // Change group name if privacy mode is enabled. |
| 218 if (privacy_mode == PRIVACY_MODE_ENABLED) | 221 if (privacy_mode == PRIVACY_MODE_ENABLED) |
| 219 connection_group = "pm/" + connection_group; | 222 connection_group = "pm/" + connection_group; |
| 220 | 223 |
| 221 // Deal with SSL - which layers on top of any given proxy. | 224 // Deal with SSL - which layers on top of any given proxy. |
| 222 if (using_ssl) { | 225 if (using_ssl) { |
| 226 scoped_refptr<TransportSocketParams> ssl_tcp_params; |
| 227 if (proxy_info.is_direct()) { |
| 228 // Setup TCP params if non-proxied SSL connection. |
| 229 // TODO (jri): Enable a finch trial to use AUTO_CONNECT_ENABLED |
| 230 // for SSL sockets. |
| 231 ssl_tcp_params = new TransportSocketParams(origin_host_port, |
| 232 disable_resolver_cache, |
| 233 ignore_limits, |
| 234 resolution_callback, |
| 235 AUTO_CONNECT_USE_DEFAULT); |
| 236 } |
| 223 scoped_refptr<SSLSocketParams> ssl_params = | 237 scoped_refptr<SSLSocketParams> ssl_params = |
| 224 new SSLSocketParams(tcp_params, | 238 new SSLSocketParams(ssl_tcp_params, |
| 225 socks_params, | 239 socks_params, |
| 226 http_proxy_params, | 240 http_proxy_params, |
| 227 origin_host_port, | 241 origin_host_port, |
| 228 ssl_config_for_origin, | 242 ssl_config_for_origin, |
| 229 privacy_mode, | 243 privacy_mode, |
| 230 load_flags, | 244 load_flags, |
| 231 force_spdy_over_ssl, | 245 force_spdy_over_ssl, |
| 232 want_spdy_over_npn); | 246 want_spdy_over_npn); |
| 233 SSLClientSocketPool* ssl_pool = NULL; | 247 SSLClientSocketPool* ssl_pool = NULL; |
| 234 if (proxy_info.is_direct()) { | 248 if (proxy_info.is_direct()) { |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 273 num_preconnect_streams, net_log); | 287 num_preconnect_streams, net_log); |
| 274 return OK; | 288 return OK; |
| 275 } | 289 } |
| 276 | 290 |
| 277 return socket_handle->Init(connection_group, socks_params, | 291 return socket_handle->Init(connection_group, socks_params, |
| 278 request_priority, callback, pool, | 292 request_priority, callback, pool, |
| 279 net_log); | 293 net_log); |
| 280 } | 294 } |
| 281 | 295 |
| 282 DCHECK(proxy_info.is_direct()); | 296 DCHECK(proxy_info.is_direct()); |
| 283 | 297 scoped_refptr<TransportSocketParams> tcp_params = |
| 298 new TransportSocketParams(origin_host_port, |
| 299 disable_resolver_cache, |
| 300 ignore_limits, |
| 301 resolution_callback, |
| 302 AUTO_CONNECT_USE_DEFAULT); |
| 284 TransportClientSocketPool* pool = | 303 TransportClientSocketPool* pool = |
| 285 session->GetTransportSocketPool(socket_pool_type); | 304 session->GetTransportSocketPool(socket_pool_type); |
| 286 if (num_preconnect_streams) { | 305 if (num_preconnect_streams) { |
| 287 RequestSocketsForPool(pool, connection_group, tcp_params, | 306 RequestSocketsForPool(pool, connection_group, tcp_params, |
| 288 num_preconnect_streams, net_log); | 307 num_preconnect_streams, net_log); |
| 289 return OK; | 308 return OK; |
| 290 } | 309 } |
| 291 | 310 |
| 292 return socket_handle->Init(connection_group, tcp_params, | 311 return socket_handle->Init(connection_group, tcp_params, |
| 293 request_priority, callback, | 312 request_priority, callback, |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 477 int num_preconnect_streams) { | 496 int num_preconnect_streams) { |
| 478 return InitSocketPoolHelper( | 497 return InitSocketPoolHelper( |
| 479 request_url, request_extra_headers, request_load_flags, request_priority, | 498 request_url, request_extra_headers, request_load_flags, request_priority, |
| 480 session, proxy_info, force_spdy_over_ssl, want_spdy_over_npn, | 499 session, proxy_info, force_spdy_over_ssl, want_spdy_over_npn, |
| 481 ssl_config_for_origin, ssl_config_for_proxy, false, privacy_mode, net_log, | 500 ssl_config_for_origin, ssl_config_for_proxy, false, privacy_mode, net_log, |
| 482 num_preconnect_streams, NULL, HttpNetworkSession::NORMAL_SOCKET_POOL, | 501 num_preconnect_streams, NULL, HttpNetworkSession::NORMAL_SOCKET_POOL, |
| 483 OnHostResolutionCallback(), CompletionCallback()); | 502 OnHostResolutionCallback(), CompletionCallback()); |
| 484 } | 503 } |
| 485 | 504 |
| 486 } // namespace net | 505 } // namespace net |
| OLD | NEW |