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 #include <tuple> | 8 #include <tuple> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 25 #include "net/proxy/proxy_info.h" | 25 #include "net/proxy/proxy_info.h" |
| 26 #include "net/quic/core/quic_server_id.h" | 26 #include "net/quic/core/quic_server_id.h" |
| 27 #include "net/spdy/chromium/bidirectional_stream_spdy_impl.h" | 27 #include "net/spdy/chromium/bidirectional_stream_spdy_impl.h" |
| 28 #include "net/spdy/chromium/spdy_http_stream.h" | 28 #include "net/spdy/chromium/spdy_http_stream.h" |
| 29 #include "url/gurl.h" | 29 #include "url/gurl.h" |
| 30 #include "url/scheme_host_port.h" | 30 #include "url/scheme_host_port.h" |
| 31 #include "url/url_constants.h" | 31 #include "url/url_constants.h" |
| 32 | 32 |
| 33 namespace net { | 33 namespace net { |
| 34 | 34 |
| 35 namespace { | |
| 36 // Default JobFactory for creating HttpStreamFactoryImpl::Jobs. | |
| 37 class DefaultJobFactory : public HttpStreamFactoryImpl::JobFactory { | |
| 38 public: | |
| 39 DefaultJobFactory() {} | |
| 40 | |
| 41 ~DefaultJobFactory() override {} | |
| 42 | |
| 43 HttpStreamFactoryImpl::Job* CreateJob( | |
| 44 HttpStreamFactoryImpl::Job::Delegate* delegate, | |
| 45 HttpStreamFactoryImpl::JobType job_type, | |
| 46 HttpNetworkSession* session, | |
| 47 const HttpRequestInfo& request_info, | |
| 48 RequestPriority priority, | |
| 49 const SSLConfig& server_ssl_config, | |
| 50 const SSLConfig& proxy_ssl_config, | |
| 51 HostPortPair destination, | |
| 52 GURL origin_url, | |
| 53 bool enable_ip_based_pooling, | |
| 54 NetLog* net_log) override { | |
| 55 return new HttpStreamFactoryImpl::Job( | |
| 56 delegate, job_type, session, request_info, priority, server_ssl_config, | |
| 57 proxy_ssl_config, destination, origin_url, enable_ip_based_pooling, | |
| 58 net_log); | |
| 59 } | |
| 60 | |
| 61 HttpStreamFactoryImpl::Job* CreateJob( | |
| 62 HttpStreamFactoryImpl::Job::Delegate* delegate, | |
| 63 HttpStreamFactoryImpl::JobType job_type, | |
| 64 HttpNetworkSession* session, | |
| 65 const HttpRequestInfo& request_info, | |
| 66 RequestPriority priority, | |
| 67 const SSLConfig& server_ssl_config, | |
| 68 const SSLConfig& proxy_ssl_config, | |
| 69 HostPortPair destination, | |
| 70 GURL origin_url, | |
| 71 AlternativeService alternative_service, | |
| 72 bool enable_ip_based_pooling, | |
| 73 NetLog* net_log) override { | |
| 74 return new HttpStreamFactoryImpl::Job( | |
| 75 delegate, job_type, session, request_info, priority, server_ssl_config, | |
| 76 proxy_ssl_config, destination, origin_url, alternative_service, | |
| 77 ProxyServer(), enable_ip_based_pooling, net_log); | |
| 78 } | |
| 79 | |
| 80 HttpStreamFactoryImpl::Job* CreateJob( | |
| 81 HttpStreamFactoryImpl::Job::Delegate* delegate, | |
| 82 HttpStreamFactoryImpl::JobType job_type, | |
| 83 HttpNetworkSession* session, | |
| 84 const HttpRequestInfo& request_info, | |
| 85 RequestPriority priority, | |
| 86 const SSLConfig& server_ssl_config, | |
| 87 const SSLConfig& proxy_ssl_config, | |
| 88 HostPortPair destination, | |
| 89 GURL origin_url, | |
| 90 const ProxyServer& alternative_proxy_server, | |
| 91 bool enable_ip_based_pooling, | |
| 92 NetLog* net_log) override { | |
| 93 return new HttpStreamFactoryImpl::Job( | |
| 94 delegate, job_type, session, request_info, priority, server_ssl_config, | |
| 95 proxy_ssl_config, destination, origin_url, AlternativeService(), | |
| 96 alternative_proxy_server, enable_ip_based_pooling, net_log); | |
| 97 } | |
| 98 }; | |
| 99 | |
| 100 } // anonymous namespace | |
| 101 | |
| 102 HttpStreamFactoryImpl::HttpStreamFactoryImpl(HttpNetworkSession* session, | 35 HttpStreamFactoryImpl::HttpStreamFactoryImpl(HttpNetworkSession* session, |
| 103 bool for_websockets) | 36 bool for_websockets) |
| 104 : session_(session), | 37 : session_(session), |
| 105 job_factory_(new DefaultJobFactory()), | 38 job_factory_(new JobFactory()), |
|
Ryan Hamilton
2017/05/09 19:22:06
Well that's a nice cleanup! I wonder what DefaultJ
Zhongyi Shi
2017/05/09 20:59:30
Ah, JobFactory used to be an interface, and produc
xunjieli
2017/05/10 00:26:23
Cherie is right. The interface seems to be created
| |
| 106 for_websockets_(for_websockets), | 39 for_websockets_(for_websockets), |
| 107 last_logged_job_controller_count_(0) {} | 40 last_logged_job_controller_count_(0) {} |
| 108 | 41 |
| 109 HttpStreamFactoryImpl::~HttpStreamFactoryImpl() { | 42 HttpStreamFactoryImpl::~HttpStreamFactoryImpl() { |
| 110 DCHECK(spdy_session_request_map_.empty()); | 43 DCHECK(spdy_session_request_map_.empty()); |
| 111 UMA_HISTOGRAM_COUNTS_1M("Net.JobControllerSet.CountOfJobControllerAtShutDown", | 44 UMA_HISTOGRAM_COUNTS_1M("Net.JobControllerSet.CountOfJobControllerAtShutDown", |
| 112 job_controller_set_.size()); | 45 job_controller_set_.size()); |
| 113 } | 46 } |
| 114 | 47 |
| 115 HttpStreamRequest* HttpStreamFactoryImpl::RequestStream( | 48 HttpStreamRequest* HttpStreamFactoryImpl::RequestStream( |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 174 websocket_handshake_stream_create_helper, | 107 websocket_handshake_stream_create_helper, |
| 175 HttpStreamRequest::StreamType stream_type, | 108 HttpStreamRequest::StreamType stream_type, |
| 176 bool enable_ip_based_pooling, | 109 bool enable_ip_based_pooling, |
| 177 bool enable_alternative_services, | 110 bool enable_alternative_services, |
| 178 const NetLogWithSource& net_log) { | 111 const NetLogWithSource& net_log) { |
| 179 AddJobControllerCountToHistograms(); | 112 AddJobControllerCountToHistograms(); |
| 180 | 113 |
| 181 auto job_controller = base::MakeUnique<JobController>( | 114 auto job_controller = base::MakeUnique<JobController>( |
| 182 this, delegate, session_, job_factory_.get(), request_info, | 115 this, delegate, session_, job_factory_.get(), request_info, |
| 183 /* is_preconnect = */ false, enable_ip_based_pooling, | 116 /* is_preconnect = */ false, enable_ip_based_pooling, |
| 184 enable_alternative_services); | 117 enable_alternative_services, server_ssl_config, proxy_ssl_config); |
| 185 JobController* job_controller_raw_ptr = job_controller.get(); | 118 JobController* job_controller_raw_ptr = job_controller.get(); |
| 186 job_controller_set_.insert(std::move(job_controller)); | 119 job_controller_set_.insert(std::move(job_controller)); |
| 187 Request* request = job_controller_raw_ptr->Start( | 120 Request* request = job_controller_raw_ptr->Start( |
| 188 request_info, delegate, websocket_handshake_stream_create_helper, net_log, | 121 delegate, websocket_handshake_stream_create_helper, net_log, stream_type, |
| 189 stream_type, priority, server_ssl_config, proxy_ssl_config); | 122 priority); |
| 190 | 123 |
| 191 return request; | 124 return request; |
| 192 } | 125 } |
| 193 | 126 |
| 194 void HttpStreamFactoryImpl::PreconnectStreams( | 127 void HttpStreamFactoryImpl::PreconnectStreams( |
| 195 int num_streams, | 128 int num_streams, |
| 196 const HttpRequestInfo& request_info) { | 129 const HttpRequestInfo& request_info) { |
| 197 AddJobControllerCountToHistograms(); | 130 AddJobControllerCountToHistograms(); |
| 198 | 131 |
| 199 SSLConfig server_ssl_config; | 132 SSLConfig server_ssl_config; |
| 200 SSLConfig proxy_ssl_config; | 133 SSLConfig proxy_ssl_config; |
| 201 session_->GetSSLConfig(request_info, &server_ssl_config, &proxy_ssl_config); | 134 session_->GetSSLConfig(request_info, &server_ssl_config, &proxy_ssl_config); |
| 202 // All preconnects should perform EV certificate verification. | 135 // All preconnects should perform EV certificate verification. |
| 203 server_ssl_config.verify_ev_cert = true; | 136 server_ssl_config.verify_ev_cert = true; |
| 204 proxy_ssl_config.verify_ev_cert = true; | 137 proxy_ssl_config.verify_ev_cert = true; |
| 205 | 138 |
| 206 DCHECK(!for_websockets_); | 139 DCHECK(!for_websockets_); |
| 207 | 140 |
| 208 auto job_controller = base::MakeUnique<JobController>( | 141 auto job_controller = base::MakeUnique<JobController>( |
| 209 this, nullptr, session_, job_factory_.get(), request_info, | 142 this, nullptr, session_, job_factory_.get(), request_info, |
| 210 /* is_preconnect = */ true, | 143 /* is_preconnect = */ true, |
| 211 /* enable_ip_based_pooling = */ true, | 144 /* enable_ip_based_pooling = */ true, |
| 212 /* enable_alternative_services = */ true); | 145 /* enable_alternative_services = */ true, server_ssl_config, |
| 146 proxy_ssl_config); | |
| 213 JobController* job_controller_raw_ptr = job_controller.get(); | 147 JobController* job_controller_raw_ptr = job_controller.get(); |
| 214 job_controller_set_.insert(std::move(job_controller)); | 148 job_controller_set_.insert(std::move(job_controller)); |
| 215 job_controller_raw_ptr->Preconnect(num_streams, request_info, | 149 job_controller_raw_ptr->Preconnect(num_streams); |
| 216 server_ssl_config, proxy_ssl_config); | |
| 217 } | 150 } |
| 218 | 151 |
| 219 const HostMappingRules* HttpStreamFactoryImpl::GetHostMappingRules() const { | 152 const HostMappingRules* HttpStreamFactoryImpl::GetHostMappingRules() const { |
| 220 return session_->params().host_mapping_rules; | 153 return session_->params().host_mapping_rules; |
| 221 } | 154 } |
| 222 | 155 |
| 223 void HttpStreamFactoryImpl::OnNewSpdySessionReady( | 156 void HttpStreamFactoryImpl::OnNewSpdySessionReady( |
| 224 const base::WeakPtr<SpdySession>& spdy_session, | 157 const base::WeakPtr<SpdySession>& spdy_session, |
| 225 bool direct, | 158 bool direct, |
| 226 const SSLConfig& used_ssl_config, | 159 const SSLConfig& used_ssl_config, |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 452 factory_dump->AddScalar("main_job_count", | 385 factory_dump->AddScalar("main_job_count", |
| 453 base::trace_event::MemoryAllocatorDump::kUnitsObjects, | 386 base::trace_event::MemoryAllocatorDump::kUnitsObjects, |
| 454 main_job_count); | 387 main_job_count); |
| 455 // The number of preconnect controllers. | 388 // The number of preconnect controllers. |
| 456 factory_dump->AddScalar("preconnect_count", | 389 factory_dump->AddScalar("preconnect_count", |
| 457 base::trace_event::MemoryAllocatorDump::kUnitsObjects, | 390 base::trace_event::MemoryAllocatorDump::kUnitsObjects, |
| 458 num_controllers_for_preconnect); | 391 num_controllers_for_preconnect); |
| 459 } | 392 } |
| 460 | 393 |
| 461 } // namespace net | 394 } // namespace net |
| OLD | NEW |