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)); |
171 | 165 |
172 if (proxy_info.is_http() || proxy_info.is_https()) { | 166 if (proxy_info.is_http() || proxy_info.is_https()) { |
173 std::string user_agent; | 167 std::string user_agent; |
174 request_extra_headers.GetHeader(HttpRequestHeaders::kUserAgent, | 168 request_extra_headers.GetHeader(HttpRequestHeaders::kUserAgent, |
175 &user_agent); | 169 &user_agent); |
176 scoped_refptr<SSLSocketParams> ssl_params; | 170 scoped_refptr<SSLSocketParams> ssl_params; |
177 if (proxy_info.is_https()) { | 171 if (proxy_info.is_https()) { |
178 // Set ssl_params, and unset proxy_tcp_params | 172 // Enable TCP FastOpen for SSL sockets. |
179 ssl_params = new SSLSocketParams(proxy_tcp_params, | 173 // TODO (jri): Finch trial this. |
180 NULL, | 174 proxy_tcp_params = |
181 NULL, | 175 new TransportSocketParams(*proxy_host_port, |
182 *proxy_host_port.get(), | 176 disable_resolver_cache, |
183 ssl_config_for_proxy, | 177 ignore_limits, |
184 PRIVACY_MODE_DISABLED, | 178 resolution_callback, |
185 load_flags, | 179 /*use_tcp_fast_open_if_supported=*/true); |
186 force_spdy_over_ssl, | 180 // Set ssl_params, and unset proxy_tcp_params |
187 want_spdy_over_npn); | 181 ssl_params = new SSLSocketParams(proxy_tcp_params, |
188 proxy_tcp_params = NULL; | 182 NULL, |
| 183 NULL, |
| 184 *proxy_host_port.get(), |
| 185 ssl_config_for_proxy, |
| 186 PRIVACY_MODE_DISABLED, |
| 187 load_flags, |
| 188 force_spdy_over_ssl, |
| 189 want_spdy_over_npn); |
| 190 proxy_tcp_params = NULL; |
189 } | 191 } |
190 | 192 |
191 http_proxy_params = | 193 http_proxy_params = |
192 new HttpProxySocketParams(proxy_tcp_params, | 194 new HttpProxySocketParams(proxy_tcp_params, |
193 ssl_params, | 195 ssl_params, |
194 request_url, | 196 request_url, |
195 user_agent, | 197 user_agent, |
196 origin_host_port, | 198 origin_host_port, |
197 session->http_auth_cache(), | 199 session->http_auth_cache(), |
198 session->http_auth_handler_factory(), | 200 session->http_auth_handler_factory(), |
(...skipping 14 matching lines...) Expand all Loading... |
213 origin_host_port); | 215 origin_host_port); |
214 } | 216 } |
215 } | 217 } |
216 | 218 |
217 // Change group name if privacy mode is enabled. | 219 // Change group name if privacy mode is enabled. |
218 if (privacy_mode == PRIVACY_MODE_ENABLED) | 220 if (privacy_mode == PRIVACY_MODE_ENABLED) |
219 connection_group = "pm/" + connection_group; | 221 connection_group = "pm/" + connection_group; |
220 | 222 |
221 // Deal with SSL - which layers on top of any given proxy. | 223 // Deal with SSL - which layers on top of any given proxy. |
222 if (using_ssl) { | 224 if (using_ssl) { |
| 225 // Enable TCP FastOpen for SSL socket. |
| 226 // TODO (jri): Finch trial this. |
| 227 scoped_refptr<TransportSocketParams> ssl_tcp_params = |
| 228 new TransportSocketParams(origin_host_port, |
| 229 disable_resolver_cache, |
| 230 ignore_limits, |
| 231 resolution_callback, |
| 232 /*use_tcp_fast_open_if_supported=*/true); |
223 scoped_refptr<SSLSocketParams> ssl_params = | 233 scoped_refptr<SSLSocketParams> ssl_params = |
224 new SSLSocketParams(tcp_params, | 234 new SSLSocketParams(ssl_tcp_params, |
225 socks_params, | 235 socks_params, |
226 http_proxy_params, | 236 http_proxy_params, |
227 origin_host_port, | 237 origin_host_port, |
228 ssl_config_for_origin, | 238 ssl_config_for_origin, |
229 privacy_mode, | 239 privacy_mode, |
230 load_flags, | 240 load_flags, |
231 force_spdy_over_ssl, | 241 force_spdy_over_ssl, |
232 want_spdy_over_npn); | 242 want_spdy_over_npn); |
233 SSLClientSocketPool* ssl_pool = NULL; | 243 SSLClientSocketPool* ssl_pool = NULL; |
234 if (proxy_info.is_direct()) { | 244 if (proxy_info.is_direct()) { |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
273 num_preconnect_streams, net_log); | 283 num_preconnect_streams, net_log); |
274 return OK; | 284 return OK; |
275 } | 285 } |
276 | 286 |
277 return socket_handle->Init(connection_group, socks_params, | 287 return socket_handle->Init(connection_group, socks_params, |
278 request_priority, callback, pool, | 288 request_priority, callback, pool, |
279 net_log); | 289 net_log); |
280 } | 290 } |
281 | 291 |
282 DCHECK(proxy_info.is_direct()); | 292 DCHECK(proxy_info.is_direct()); |
283 | 293 scoped_refptr<TransportSocketParams> tcp_params = |
| 294 new TransportSocketParams(origin_host_port, |
| 295 disable_resolver_cache, |
| 296 ignore_limits, |
| 297 resolution_callback); |
284 TransportClientSocketPool* pool = | 298 TransportClientSocketPool* pool = |
285 session->GetTransportSocketPool(socket_pool_type); | 299 session->GetTransportSocketPool(socket_pool_type); |
286 if (num_preconnect_streams) { | 300 if (num_preconnect_streams) { |
287 RequestSocketsForPool(pool, connection_group, tcp_params, | 301 RequestSocketsForPool(pool, connection_group, tcp_params, |
288 num_preconnect_streams, net_log); | 302 num_preconnect_streams, net_log); |
289 return OK; | 303 return OK; |
290 } | 304 } |
291 | 305 |
292 return socket_handle->Init(connection_group, tcp_params, | 306 return socket_handle->Init(connection_group, tcp_params, |
293 request_priority, callback, | 307 request_priority, callback, |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
477 int num_preconnect_streams) { | 491 int num_preconnect_streams) { |
478 return InitSocketPoolHelper( | 492 return InitSocketPoolHelper( |
479 request_url, request_extra_headers, request_load_flags, request_priority, | 493 request_url, request_extra_headers, request_load_flags, request_priority, |
480 session, proxy_info, force_spdy_over_ssl, want_spdy_over_npn, | 494 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, | 495 ssl_config_for_origin, ssl_config_for_proxy, false, privacy_mode, net_log, |
482 num_preconnect_streams, NULL, HttpNetworkSession::NORMAL_SOCKET_POOL, | 496 num_preconnect_streams, NULL, HttpNetworkSession::NORMAL_SOCKET_POOL, |
483 OnHostResolutionCallback(), CompletionCallback()); | 497 OnHostResolutionCallback(), CompletionCallback()); |
484 } | 498 } |
485 | 499 |
486 } // namespace net | 500 } // namespace net |
OLD | NEW |