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( |
168 disable_resolver_cache, | 162 *proxy_host_port, |
169 ignore_limits, | 163 disable_resolver_cache, |
170 resolution_callback)); | 164 ignore_limits, |
| 165 resolution_callback, |
| 166 TransportSocketParams::COMBINE_CONNECT_AND_WRITE_DEFAULT)); |
171 | 167 |
172 if (proxy_info.is_http() || proxy_info.is_https()) { | 168 if (proxy_info.is_http() || proxy_info.is_https()) { |
173 std::string user_agent; | 169 std::string user_agent; |
174 request_extra_headers.GetHeader(HttpRequestHeaders::kUserAgent, | 170 request_extra_headers.GetHeader(HttpRequestHeaders::kUserAgent, |
175 &user_agent); | 171 &user_agent); |
176 scoped_refptr<SSLSocketParams> ssl_params; | 172 scoped_refptr<SSLSocketParams> ssl_params; |
177 if (proxy_info.is_https()) { | 173 if (proxy_info.is_https()) { |
| 174 // TODO (jri): Enable a finch trial to use |
| 175 // COMBINE_CONNECT_AND_WRITE_DESIRED for SSL sockets. |
| 176 proxy_tcp_params = |
| 177 new TransportSocketParams( |
| 178 *proxy_host_port, |
| 179 disable_resolver_cache, |
| 180 ignore_limits, |
| 181 resolution_callback, |
| 182 TransportSocketParams::COMBINE_CONNECT_AND_WRITE_DEFAULT); |
178 // Set ssl_params, and unset proxy_tcp_params | 183 // Set ssl_params, and unset proxy_tcp_params |
179 ssl_params = new SSLSocketParams(proxy_tcp_params, | 184 ssl_params = new SSLSocketParams(proxy_tcp_params, |
180 NULL, | 185 NULL, |
181 NULL, | 186 NULL, |
182 *proxy_host_port.get(), | 187 *proxy_host_port.get(), |
183 ssl_config_for_proxy, | 188 ssl_config_for_proxy, |
184 PRIVACY_MODE_DISABLED, | 189 PRIVACY_MODE_DISABLED, |
185 load_flags, | 190 load_flags, |
186 force_spdy_over_ssl, | 191 force_spdy_over_ssl, |
187 want_spdy_over_npn); | 192 want_spdy_over_npn); |
(...skipping 26 matching lines...) Expand all Loading... |
214 origin_host_port); | 219 origin_host_port); |
215 } | 220 } |
216 } | 221 } |
217 | 222 |
218 // Change group name if privacy mode is enabled. | 223 // Change group name if privacy mode is enabled. |
219 if (privacy_mode == PRIVACY_MODE_ENABLED) | 224 if (privacy_mode == PRIVACY_MODE_ENABLED) |
220 connection_group = "pm/" + connection_group; | 225 connection_group = "pm/" + connection_group; |
221 | 226 |
222 // Deal with SSL - which layers on top of any given proxy. | 227 // Deal with SSL - which layers on top of any given proxy. |
223 if (using_ssl) { | 228 if (using_ssl) { |
| 229 scoped_refptr<TransportSocketParams> ssl_tcp_params; |
| 230 if (proxy_info.is_direct()) { |
| 231 // Setup TCP params if non-proxied SSL connection. |
| 232 // TODO (jri): Enable a finch trial to use |
| 233 // COMBINE_CONNECT_AND_WRITE_DESIRED for SSL sockets. |
| 234 ssl_tcp_params = |
| 235 new TransportSocketParams( |
| 236 origin_host_port, |
| 237 disable_resolver_cache, |
| 238 ignore_limits, |
| 239 resolution_callback, |
| 240 TransportSocketParams::COMBINE_CONNECT_AND_WRITE_DEFAULT); |
| 241 } |
224 scoped_refptr<SSLSocketParams> ssl_params = | 242 scoped_refptr<SSLSocketParams> ssl_params = |
225 new SSLSocketParams(tcp_params, | 243 new SSLSocketParams(ssl_tcp_params, |
226 socks_params, | 244 socks_params, |
227 http_proxy_params, | 245 http_proxy_params, |
228 origin_host_port, | 246 origin_host_port, |
229 ssl_config_for_origin, | 247 ssl_config_for_origin, |
230 privacy_mode, | 248 privacy_mode, |
231 load_flags, | 249 load_flags, |
232 force_spdy_over_ssl, | 250 force_spdy_over_ssl, |
233 want_spdy_over_npn); | 251 want_spdy_over_npn); |
234 SSLClientSocketPool* ssl_pool = NULL; | 252 SSLClientSocketPool* ssl_pool = NULL; |
235 if (proxy_info.is_direct()) { | 253 if (proxy_info.is_direct()) { |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
274 num_preconnect_streams, net_log); | 292 num_preconnect_streams, net_log); |
275 return OK; | 293 return OK; |
276 } | 294 } |
277 | 295 |
278 return socket_handle->Init(connection_group, socks_params, | 296 return socket_handle->Init(connection_group, socks_params, |
279 request_priority, callback, pool, | 297 request_priority, callback, pool, |
280 net_log); | 298 net_log); |
281 } | 299 } |
282 | 300 |
283 DCHECK(proxy_info.is_direct()); | 301 DCHECK(proxy_info.is_direct()); |
284 | 302 scoped_refptr<TransportSocketParams> tcp_params = |
| 303 new TransportSocketParams( |
| 304 origin_host_port, |
| 305 disable_resolver_cache, |
| 306 ignore_limits, |
| 307 resolution_callback, |
| 308 TransportSocketParams::COMBINE_CONNECT_AND_WRITE_DEFAULT); |
285 TransportClientSocketPool* pool = | 309 TransportClientSocketPool* pool = |
286 session->GetTransportSocketPool(socket_pool_type); | 310 session->GetTransportSocketPool(socket_pool_type); |
287 if (num_preconnect_streams) { | 311 if (num_preconnect_streams) { |
288 RequestSocketsForPool(pool, connection_group, tcp_params, | 312 RequestSocketsForPool(pool, connection_group, tcp_params, |
289 num_preconnect_streams, net_log); | 313 num_preconnect_streams, net_log); |
290 return OK; | 314 return OK; |
291 } | 315 } |
292 | 316 |
293 return socket_handle->Init(connection_group, tcp_params, | 317 return socket_handle->Init(connection_group, tcp_params, |
294 request_priority, callback, | 318 request_priority, callback, |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
478 int num_preconnect_streams) { | 502 int num_preconnect_streams) { |
479 return InitSocketPoolHelper( | 503 return InitSocketPoolHelper( |
480 request_url, request_extra_headers, request_load_flags, request_priority, | 504 request_url, request_extra_headers, request_load_flags, request_priority, |
481 session, proxy_info, force_spdy_over_ssl, want_spdy_over_npn, | 505 session, proxy_info, force_spdy_over_ssl, want_spdy_over_npn, |
482 ssl_config_for_origin, ssl_config_for_proxy, false, privacy_mode, net_log, | 506 ssl_config_for_origin, ssl_config_for_proxy, false, privacy_mode, net_log, |
483 num_preconnect_streams, NULL, HttpNetworkSession::NORMAL_SOCKET_POOL, | 507 num_preconnect_streams, NULL, HttpNetworkSession::NORMAL_SOCKET_POOL, |
484 OnHostResolutionCallback(), CompletionCallback()); | 508 OnHostResolutionCallback(), CompletionCallback()); |
485 } | 509 } |
486 | 510 |
487 } // namespace net | 511 } // namespace net |
OLD | NEW |