OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/http/http_stream_factory_impl_job.h" | 5 #include "net/http/http_stream_factory_impl_job.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/stl_util.h" | 8 #include "base/stl_util.h" |
9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
10 #include "base/stringprintf.h" | 10 #include "base/stringprintf.h" |
11 #include "base/values.h" | 11 #include "base/values.h" |
12 #include "build/build_config.h" | 12 #include "build/build_config.h" |
13 #include "net/base/connection_type_histograms.h" | 13 #include "net/base/connection_type_histograms.h" |
14 #include "net/base/net_log.h" | 14 #include "net/base/net_log.h" |
15 #include "net/base/net_util.h" | 15 #include "net/base/net_util.h" |
16 #include "net/base/ssl_cert_request_info.h" | 16 #include "net/base/ssl_cert_request_info.h" |
17 #include "net/http/http_basic_stream.h" | 17 #include "net/http/http_basic_stream.h" |
18 #include "net/http/http_network_session.h" | 18 #include "net/http/http_network_session.h" |
19 #include "net/http/http_proxy_client_socket.h" | 19 #include "net/http/http_proxy_client_socket.h" |
20 #include "net/http/http_proxy_client_socket_pool.h" | 20 #include "net/http/http_proxy_client_socket_pool.h" |
21 #include "net/http/http_request_info.h" | 21 #include "net/http/http_request_info.h" |
| 22 #include "net/http/http_server_properties.h" |
22 #include "net/http/http_stream_factory_impl_request.h" | 23 #include "net/http/http_stream_factory_impl_request.h" |
23 #include "net/socket/client_socket_handle.h" | 24 #include "net/socket/client_socket_handle.h" |
24 #include "net/socket/client_socket_pool.h" | 25 #include "net/socket/client_socket_pool.h" |
25 #include "net/socket/socks_client_socket_pool.h" | 26 #include "net/socket/socks_client_socket_pool.h" |
26 #include "net/socket/ssl_client_socket.h" | 27 #include "net/socket/ssl_client_socket.h" |
27 #include "net/socket/ssl_client_socket_pool.h" | 28 #include "net/socket/ssl_client_socket_pool.h" |
28 #include "net/spdy/spdy_http_stream.h" | 29 #include "net/spdy/spdy_http_stream.h" |
29 #include "net/spdy/spdy_session.h" | 30 #include "net/spdy/spdy_session.h" |
30 #include "net/spdy/spdy_session_pool.h" | 31 #include "net/spdy/spdy_session_pool.h" |
31 | 32 |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 } | 113 } |
113 | 114 |
114 void HttpStreamFactoryImpl::Job::Start(Request* request) { | 115 void HttpStreamFactoryImpl::Job::Start(Request* request) { |
115 DCHECK(request); | 116 DCHECK(request); |
116 request_ = request; | 117 request_ = request; |
117 StartInternal(); | 118 StartInternal(); |
118 } | 119 } |
119 | 120 |
120 int HttpStreamFactoryImpl::Job::Preconnect(int num_streams) { | 121 int HttpStreamFactoryImpl::Job::Preconnect(int num_streams) { |
121 DCHECK_GT(num_streams, 0); | 122 DCHECK_GT(num_streams, 0); |
122 num_streams_ = num_streams; | 123 HostPortPair origin_server = |
| 124 HostPortPair(request_info_.url.HostNoBrackets(), |
| 125 request_info_.url.EffectiveIntPort()); |
| 126 HttpServerProperties* http_server_properties = |
| 127 session_->http_server_properties(); |
| 128 if (http_server_properties && |
| 129 http_server_properties->SupportsSpdy(origin_server)) { |
| 130 num_streams_ = 1; |
| 131 } else { |
| 132 num_streams_ = num_streams; |
| 133 } |
123 return StartInternal(); | 134 return StartInternal(); |
124 } | 135 } |
125 | 136 |
126 int HttpStreamFactoryImpl::Job::RestartTunnelWithProxyAuth( | 137 int HttpStreamFactoryImpl::Job::RestartTunnelWithProxyAuth( |
127 const string16& username, const string16& password) { | 138 const string16& username, const string16& password) { |
128 DCHECK(establishing_tunnel_); | 139 DCHECK(establishing_tunnel_); |
129 next_state_ = STATE_RESTART_TUNNEL_AUTH; | 140 next_state_ = STATE_RESTART_TUNNEL_AUTH; |
130 stream_.reset(); | 141 stream_.reset(); |
131 return RunLoop(OK); | 142 return RunLoop(OK); |
132 } | 143 } |
(...skipping 681 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
814 // extension, or just directly using SSL. Either way, |connection_| must | 825 // extension, or just directly using SSL. Either way, |connection_| must |
815 // contain an SSLClientSocket. | 826 // contain an SSLClientSocket. |
816 if (!connection_->socket()) | 827 if (!connection_->socket()) |
817 HACKCrashHereToDebug80095(); | 828 HACKCrashHereToDebug80095(); |
818 | 829 |
819 int error = spdy_pool->GetSpdySessionFromSocket( | 830 int error = spdy_pool->GetSpdySessionFromSocket( |
820 pair, connection_.release(), net_log_, spdy_certificate_error_, | 831 pair, connection_.release(), net_log_, spdy_certificate_error_, |
821 &new_spdy_session_, using_ssl_); | 832 &new_spdy_session_, using_ssl_); |
822 if (error != OK) | 833 if (error != OK) |
823 return error; | 834 return error; |
| 835 const HostPortPair& host_port_pair = pair.first; |
| 836 HttpServerProperties* http_server_properties = |
| 837 session_->http_server_properties(); |
| 838 if (http_server_properties) |
| 839 http_server_properties->SetSupportsSpdy(host_port_pair, true); |
824 spdy_session_direct_ = direct; | 840 spdy_session_direct_ = direct; |
825 return OK; | 841 return OK; |
826 } | 842 } |
827 } | 843 } |
828 | 844 |
829 if (spdy_session->IsClosed()) | 845 if (spdy_session->IsClosed()) |
830 return ERR_CONNECTION_CLOSED; | 846 return ERR_CONNECTION_CLOSED; |
831 | 847 |
832 // TODO(willchan): Delete this code, because eventually, the | 848 // TODO(willchan): Delete this code, because eventually, the |
833 // HttpStreamFactoryImpl will be creating all the SpdyHttpStreams, since it | 849 // HttpStreamFactoryImpl will be creating all the SpdyHttpStreams, since it |
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1123 << (using_spdy ? "true\n" : "false\n"); | 1139 << (using_spdy ? "true\n" : "false\n"); |
1124 } | 1140 } |
1125 } | 1141 } |
1126 | 1142 |
1127 #if defined(OS_WIN) | 1143 #if defined(OS_WIN) |
1128 #pragma optimize( "", on ) | 1144 #pragma optimize( "", on ) |
1129 #pragma warning (default: 4748) | 1145 #pragma warning (default: 4748) |
1130 #endif | 1146 #endif |
1131 | 1147 |
1132 } // namespace net | 1148 } // namespace net |
OLD | NEW |