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 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 100 } // anonymous namespace | 100 } // anonymous namespace |
| 101 | 101 |
| 102 HttpStreamFactoryImpl::HttpStreamFactoryImpl(HttpNetworkSession* session, | 102 HttpStreamFactoryImpl::HttpStreamFactoryImpl(HttpNetworkSession* session, |
| 103 bool for_websockets) | 103 bool for_websockets) |
| 104 : session_(session), | 104 : session_(session), |
| 105 job_factory_(new DefaultJobFactory()), | 105 job_factory_(new DefaultJobFactory()), |
| 106 for_websockets_(for_websockets) {} | 106 for_websockets_(for_websockets) {} |
| 107 | 107 |
| 108 HttpStreamFactoryImpl::~HttpStreamFactoryImpl() { | 108 HttpStreamFactoryImpl::~HttpStreamFactoryImpl() { |
| 109 DCHECK(spdy_session_request_map_.empty()); | 109 DCHECK(spdy_session_request_map_.empty()); |
| 110 int alt_job_count = 0; | 110 AddJobControllerCountToHistograms(); |
| 111 int main_job_count = 0; | |
| 112 int preconnect_controller_count = 0; | |
| 113 for (const auto& it : job_controller_set_) { | |
| 114 DCHECK(it->HasPendingAltJob() || it->HasPendingMainJob()); | |
| 115 // For a preconnect controller, it should have exactly the main job. | |
| 116 if (it->is_preconnect()) { | |
| 117 preconnect_controller_count++; | |
| 118 continue; | |
| 119 } | |
| 120 // For non-preconnects. | |
| 121 if (it->HasPendingAltJob()) | |
| 122 alt_job_count++; | |
| 123 if (it->HasPendingMainJob()) | |
| 124 main_job_count++; | |
| 125 } | |
| 126 UMA_HISTOGRAM_COUNTS_1M("Net.JobControllerSet.CountOfPreconnect", | |
| 127 preconnect_controller_count); | |
| 128 UMA_HISTOGRAM_COUNTS_1M("Net.JobControllerSet.CountOfNonPreconnectAltJob", | |
| 129 alt_job_count); | |
| 130 UMA_HISTOGRAM_COUNTS_1M("Net.JobControllerSet.CountOfNonPreconnectMainJob", | |
| 131 main_job_count); | |
| 132 } | 111 } |
| 133 | 112 |
| 134 HttpStreamRequest* HttpStreamFactoryImpl::RequestStream( | 113 HttpStreamRequest* HttpStreamFactoryImpl::RequestStream( |
| 135 const HttpRequestInfo& request_info, | 114 const HttpRequestInfo& request_info, |
| 136 RequestPriority priority, | 115 RequestPriority priority, |
| 137 const SSLConfig& server_ssl_config, | 116 const SSLConfig& server_ssl_config, |
| 138 const SSLConfig& proxy_ssl_config, | 117 const SSLConfig& proxy_ssl_config, |
| 139 HttpStreamRequest::Delegate* delegate, | 118 HttpStreamRequest::Delegate* delegate, |
| 140 bool enable_ip_based_pooling, | 119 bool enable_ip_based_pooling, |
| 141 bool enable_alternative_services, | 120 bool enable_alternative_services, |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 188 RequestPriority priority, | 167 RequestPriority priority, |
| 189 const SSLConfig& server_ssl_config, | 168 const SSLConfig& server_ssl_config, |
| 190 const SSLConfig& proxy_ssl_config, | 169 const SSLConfig& proxy_ssl_config, |
| 191 HttpStreamRequest::Delegate* delegate, | 170 HttpStreamRequest::Delegate* delegate, |
| 192 WebSocketHandshakeStreamBase::CreateHelper* | 171 WebSocketHandshakeStreamBase::CreateHelper* |
| 193 websocket_handshake_stream_create_helper, | 172 websocket_handshake_stream_create_helper, |
| 194 HttpStreamRequest::StreamType stream_type, | 173 HttpStreamRequest::StreamType stream_type, |
| 195 bool enable_ip_based_pooling, | 174 bool enable_ip_based_pooling, |
| 196 bool enable_alternative_services, | 175 bool enable_alternative_services, |
| 197 const NetLogWithSource& net_log) { | 176 const NetLogWithSource& net_log) { |
| 177 AddJobControllerCountToHistograms(); | |
| 178 | |
| 198 auto job_controller = base::MakeUnique<JobController>( | 179 auto job_controller = base::MakeUnique<JobController>( |
| 199 this, delegate, session_, job_factory_.get(), request_info, | 180 this, delegate, session_, job_factory_.get(), request_info, |
| 200 /* is_preconnect = */ false, enable_ip_based_pooling, | 181 /* is_preconnect = */ false, enable_ip_based_pooling, |
| 201 enable_alternative_services); | 182 enable_alternative_services); |
| 202 JobController* job_controller_raw_ptr = job_controller.get(); | 183 JobController* job_controller_raw_ptr = job_controller.get(); |
| 203 job_controller_set_.insert(std::move(job_controller)); | 184 job_controller_set_.insert(std::move(job_controller)); |
| 204 Request* request = job_controller_raw_ptr->Start( | 185 Request* request = job_controller_raw_ptr->Start( |
| 205 request_info, delegate, websocket_handshake_stream_create_helper, net_log, | 186 request_info, delegate, websocket_handshake_stream_create_helper, net_log, |
| 206 stream_type, priority, server_ssl_config, proxy_ssl_config); | 187 stream_type, priority, server_ssl_config, proxy_ssl_config); |
| 207 | 188 |
| 208 return request; | 189 return request; |
| 209 } | 190 } |
| 210 | 191 |
| 211 void HttpStreamFactoryImpl::PreconnectStreams( | 192 void HttpStreamFactoryImpl::PreconnectStreams( |
| 212 int num_streams, | 193 int num_streams, |
| 213 const HttpRequestInfo& request_info) { | 194 const HttpRequestInfo& request_info) { |
| 195 AddJobControllerCountToHistograms(); | |
| 196 | |
| 214 SSLConfig server_ssl_config; | 197 SSLConfig server_ssl_config; |
| 215 SSLConfig proxy_ssl_config; | 198 SSLConfig proxy_ssl_config; |
| 216 session_->GetSSLConfig(request_info, &server_ssl_config, &proxy_ssl_config); | 199 session_->GetSSLConfig(request_info, &server_ssl_config, &proxy_ssl_config); |
| 217 // All preconnects should perform EV certificate verification. | 200 // All preconnects should perform EV certificate verification. |
| 218 server_ssl_config.verify_ev_cert = true; | 201 server_ssl_config.verify_ev_cert = true; |
| 219 proxy_ssl_config.verify_ev_cert = true; | 202 proxy_ssl_config.verify_ev_cert = true; |
| 220 | 203 |
| 221 DCHECK(!for_websockets_); | 204 DCHECK(!for_websockets_); |
| 222 | 205 |
| 223 auto job_controller = base::MakeUnique<JobController>( | 206 auto job_controller = base::MakeUnique<JobController>( |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 365 HostPortPair host_port_pair = proxy_info.proxy_server().host_port_pair(); | 348 HostPortPair host_port_pair = proxy_info.proxy_server().host_port_pair(); |
| 366 DCHECK(!host_port_pair.IsEmpty()); | 349 DCHECK(!host_port_pair.IsEmpty()); |
| 367 | 350 |
| 368 url::SchemeHostPort scheme_host_port("https", host_port_pair.host(), | 351 url::SchemeHostPort scheme_host_port("https", host_port_pair.host(), |
| 369 host_port_pair.port()); | 352 host_port_pair.port()); |
| 370 | 353 |
| 371 return session_->http_server_properties()->SupportsRequestPriority( | 354 return session_->http_server_properties()->SupportsRequestPriority( |
| 372 scheme_host_port); | 355 scheme_host_port); |
| 373 } | 356 } |
| 374 | 357 |
| 358 void HttpStreamFactoryImpl::AddJobControllerCountToHistograms() const { | |
| 359 int alt_job_count = 0; | |
| 360 int main_job_count = 0; | |
| 361 int preconnect_controller_count = 0; | |
| 362 for (const auto& it : job_controller_set_) { | |
|
Ryan Hamilton
2017/04/07 22:51:05
nit: I think "it" is not an iterator, but rather a
| |
| 363 DCHECK(it->HasPendingAltJob() || it->HasPendingMainJob()); | |
| 364 // For a preconnect controller, it should have exactly the main job. | |
| 365 if (it->is_preconnect()) { | |
| 366 preconnect_controller_count++; | |
| 367 continue; | |
| 368 } | |
| 369 // For non-preconnects. | |
| 370 if (it->HasPendingAltJob()) | |
| 371 alt_job_count++; | |
| 372 if (it->HasPendingMainJob()) | |
| 373 main_job_count++; | |
| 374 } | |
| 375 UMA_HISTOGRAM_COUNTS_1M("Net.JobControllerSet.CountOfPreconnect", | |
| 376 preconnect_controller_count); | |
| 377 UMA_HISTOGRAM_COUNTS_1M("Net.JobControllerSet.CountOfNonPreconnectAltJob", | |
| 378 alt_job_count); | |
| 379 UMA_HISTOGRAM_COUNTS_1M("Net.JobControllerSet.CountOfNonPreconnectMainJob", | |
| 380 main_job_count); | |
|
Ryan Hamilton
2017/04/07 22:51:05
it's a bit of a bummer that we have to compute the
Zhongyi Shi
2017/04/07 23:43:02
Well, if we want to improve: I guess one way we co
| |
| 381 } | |
| 382 | |
| 375 void HttpStreamFactoryImpl::DumpMemoryStats( | 383 void HttpStreamFactoryImpl::DumpMemoryStats( |
| 376 base::trace_event::ProcessMemoryDump* pmd, | 384 base::trace_event::ProcessMemoryDump* pmd, |
| 377 const std::string& parent_absolute_name) const { | 385 const std::string& parent_absolute_name) const { |
| 378 if (job_controller_set_.empty()) | 386 if (job_controller_set_.empty()) |
| 379 return; | 387 return; |
| 380 std::string name = | 388 std::string name = |
| 381 base::StringPrintf("%s/stream_factory", parent_absolute_name.c_str()); | 389 base::StringPrintf("%s/stream_factory", parent_absolute_name.c_str()); |
| 382 base::trace_event::MemoryAllocatorDump* factory_dump = | 390 base::trace_event::MemoryAllocatorDump* factory_dump = |
| 383 pmd->CreateAllocatorDump(name); | 391 pmd->CreateAllocatorDump(name); |
| 384 size_t alt_job_count = 0; | 392 size_t alt_job_count = 0; |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 412 factory_dump->AddScalar("main_job_count", | 420 factory_dump->AddScalar("main_job_count", |
| 413 base::trace_event::MemoryAllocatorDump::kUnitsObjects, | 421 base::trace_event::MemoryAllocatorDump::kUnitsObjects, |
| 414 main_job_count); | 422 main_job_count); |
| 415 // The number of preconnect controllers. | 423 // The number of preconnect controllers. |
| 416 factory_dump->AddScalar("preconnect_count", | 424 factory_dump->AddScalar("preconnect_count", |
| 417 base::trace_event::MemoryAllocatorDump::kUnitsObjects, | 425 base::trace_event::MemoryAllocatorDump::kUnitsObjects, |
| 418 preconnect_controller_count); | 426 preconnect_controller_count); |
| 419 } | 427 } |
| 420 | 428 |
| 421 } // namespace net | 429 } // namespace net |
| OLD | NEW |