Chromium Code Reviews| 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/http/http_stream_factory_impl.h" | 5 #include "net/http/http_stream_factory_impl.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 87 alternative_proxy_server, net_log); | 87 alternative_proxy_server, net_log); |
| 88 } | 88 } |
| 89 }; | 89 }; |
| 90 | 90 |
| 91 } // anonymous namespace | 91 } // anonymous namespace |
| 92 | 92 |
| 93 HttpStreamFactoryImpl::HttpStreamFactoryImpl(HttpNetworkSession* session, | 93 HttpStreamFactoryImpl::HttpStreamFactoryImpl(HttpNetworkSession* session, |
| 94 bool for_websockets) | 94 bool for_websockets) |
| 95 : session_(session), | 95 : session_(session), |
| 96 job_factory_(new DefaultJobFactory()), | 96 job_factory_(new DefaultJobFactory()), |
| 97 for_websockets_(for_websockets) {} | 97 for_websockets_(for_websockets), |
| 98 factory_net_log_( | |
| 99 NetLogWithSource::Make(session->net_log(), | |
| 100 NetLogSourceType::HTTP_STREAM_FACTORY)) {} | |
|
mmenke
2017/01/12 16:35:08
This isn't really how sources are currently used -
xunjieli
2017/01/12 18:09:42
My main motivation for creating a long-lived event
| |
| 98 | 101 |
| 99 HttpStreamFactoryImpl::~HttpStreamFactoryImpl() { | 102 HttpStreamFactoryImpl::~HttpStreamFactoryImpl() { |
| 100 DCHECK(request_map_.empty()); | 103 DCHECK(request_map_.empty()); |
| 101 DCHECK(spdy_session_request_map_.empty()); | 104 DCHECK(spdy_session_request_map_.empty()); |
| 102 } | 105 } |
| 103 | 106 |
| 104 HttpStreamRequest* HttpStreamFactoryImpl::RequestStream( | 107 HttpStreamRequest* HttpStreamFactoryImpl::RequestStream( |
| 105 const HttpRequestInfo& request_info, | 108 const HttpRequestInfo& request_info, |
| 106 RequestPriority priority, | 109 RequestPriority priority, |
| 107 const SSLConfig& server_ssl_config, | 110 const SSLConfig& server_ssl_config, |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 148 const HttpRequestInfo& request_info, | 151 const HttpRequestInfo& request_info, |
| 149 RequestPriority priority, | 152 RequestPriority priority, |
| 150 const SSLConfig& server_ssl_config, | 153 const SSLConfig& server_ssl_config, |
| 151 const SSLConfig& proxy_ssl_config, | 154 const SSLConfig& proxy_ssl_config, |
| 152 HttpStreamRequest::Delegate* delegate, | 155 HttpStreamRequest::Delegate* delegate, |
| 153 WebSocketHandshakeStreamBase::CreateHelper* | 156 WebSocketHandshakeStreamBase::CreateHelper* |
| 154 websocket_handshake_stream_create_helper, | 157 websocket_handshake_stream_create_helper, |
| 155 HttpStreamRequest::StreamType stream_type, | 158 HttpStreamRequest::StreamType stream_type, |
| 156 const NetLogWithSource& net_log) { | 159 const NetLogWithSource& net_log) { |
| 157 JobController* job_controller = | 160 JobController* job_controller = |
| 158 new JobController(this, delegate, session_, job_factory_.get()); | 161 new JobController(this, delegate, session_, job_factory_.get(), |
| 162 /*is_preconnect=*/false, net_log); | |
| 159 job_controller_set_.insert(base::WrapUnique(job_controller)); | 163 job_controller_set_.insert(base::WrapUnique(job_controller)); |
| 160 | 164 |
| 161 Request* request = job_controller->Start( | 165 Request* request = job_controller->Start( |
| 162 request_info, delegate, websocket_handshake_stream_create_helper, net_log, | 166 request_info, delegate, websocket_handshake_stream_create_helper, |
| 163 stream_type, priority, server_ssl_config, proxy_ssl_config); | 167 stream_type, priority, server_ssl_config, proxy_ssl_config); |
| 164 | 168 |
| 165 return request; | 169 return request; |
| 166 } | 170 } |
| 167 | 171 |
| 168 void HttpStreamFactoryImpl::PreconnectStreams( | 172 void HttpStreamFactoryImpl::PreconnectStreams( |
| 169 int num_streams, | 173 int num_streams, |
| 170 const HttpRequestInfo& request_info) { | 174 const HttpRequestInfo& request_info) { |
| 171 SSLConfig server_ssl_config; | 175 SSLConfig server_ssl_config; |
| 172 SSLConfig proxy_ssl_config; | 176 SSLConfig proxy_ssl_config; |
| 173 session_->GetSSLConfig(request_info, &server_ssl_config, &proxy_ssl_config); | 177 session_->GetSSLConfig(request_info, &server_ssl_config, &proxy_ssl_config); |
| 174 // All preconnects should perform EV certificate verification. | 178 // All preconnects should perform EV certificate verification. |
| 175 server_ssl_config.verify_ev_cert = true; | 179 server_ssl_config.verify_ev_cert = true; |
| 176 proxy_ssl_config.verify_ev_cert = true; | 180 proxy_ssl_config.verify_ev_cert = true; |
| 177 | 181 |
| 178 DCHECK(!for_websockets_); | 182 DCHECK(!for_websockets_); |
| 179 | 183 |
| 180 JobController* job_controller = | 184 JobController* job_controller = |
| 181 new JobController(this, nullptr, session_, job_factory_.get()); | 185 new JobController(this, nullptr, session_, job_factory_.get(), |
| 186 /*is_preconnect=*/true, factory_net_log_); | |
| 182 job_controller_set_.insert(base::WrapUnique(job_controller)); | 187 job_controller_set_.insert(base::WrapUnique(job_controller)); |
| 183 job_controller->Preconnect(num_streams, request_info, server_ssl_config, | 188 job_controller->Preconnect(num_streams, request_info, server_ssl_config, |
| 184 proxy_ssl_config); | 189 proxy_ssl_config); |
| 185 } | 190 } |
| 186 | 191 |
| 187 const HostMappingRules* HttpStreamFactoryImpl::GetHostMappingRules() const { | 192 const HostMappingRules* HttpStreamFactoryImpl::GetHostMappingRules() const { |
| 188 return session_->params().host_mapping_rules; | 193 return session_->params().host_mapping_rules; |
| 189 } | 194 } |
| 190 | 195 |
| 191 void HttpStreamFactoryImpl::OnNewSpdySessionReady( | 196 void HttpStreamFactoryImpl::OnNewSpdySessionReady( |
| 192 const base::WeakPtr<SpdySession>& spdy_session, | 197 const base::WeakPtr<SpdySession>& spdy_session, |
| 193 bool direct, | 198 bool direct, |
| 194 const SSLConfig& used_ssl_config, | 199 const SSLConfig& used_ssl_config, |
| 195 const ProxyInfo& used_proxy_info, | 200 const ProxyInfo& used_proxy_info, |
| 196 bool was_alpn_negotiated, | 201 bool was_alpn_negotiated, |
| 197 NextProto negotiated_protocol, | 202 NextProto negotiated_protocol, |
| 198 bool using_spdy, | 203 bool using_spdy) { |
| 199 const NetLogWithSource& net_log) { | |
| 200 while (true) { | 204 while (true) { |
| 201 if (!spdy_session) | 205 if (!spdy_session) |
| 202 break; | 206 break; |
| 203 const SpdySessionKey& spdy_session_key = spdy_session->spdy_session_key(); | 207 const SpdySessionKey& spdy_session_key = spdy_session->spdy_session_key(); |
| 204 // Each iteration may empty out the RequestSet for |spdy_session_key| in | 208 // Each iteration may empty out the RequestSet for |spdy_session_key| in |
| 205 // |spdy_session_request_map_|. So each time, check for RequestSet and use | 209 // |spdy_session_request_map_|. So each time, check for RequestSet and use |
| 206 // the first one. | 210 // the first one. |
| 207 // | 211 // |
| 208 // TODO(willchan): If it's important, switch RequestSet out for a FIFO | 212 // TODO(willchan): If it's important, switch RequestSet out for a FIFO |
| 209 // queue (Order by priority first, then FIFO within same priority). Unclear | 213 // queue (Order by priority first, then FIFO within same priority). Unclear |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 296 DCHECK(!host_port_pair.IsEmpty()); | 300 DCHECK(!host_port_pair.IsEmpty()); |
| 297 | 301 |
| 298 url::SchemeHostPort scheme_host_port("https", host_port_pair.host(), | 302 url::SchemeHostPort scheme_host_port("https", host_port_pair.host(), |
| 299 host_port_pair.port()); | 303 host_port_pair.port()); |
| 300 | 304 |
| 301 return session_->http_server_properties()->SupportsRequestPriority( | 305 return session_->http_server_properties()->SupportsRequestPriority( |
| 302 scheme_host_port); | 306 scheme_host_port); |
| 303 } | 307 } |
| 304 | 308 |
| 305 } // namespace net | 309 } // namespace net |
| OLD | NEW |