| 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 UMA_HISTOGRAM_COUNTS_1M("Net.JobControllerSet.CountOfJobControllerAtShutDown", |
| 111 int main_job_count = 0; | 111 job_controller_set_.size()); |
| 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 } | 112 } |
| 133 | 113 |
| 134 HttpStreamRequest* HttpStreamFactoryImpl::RequestStream( | 114 HttpStreamRequest* HttpStreamFactoryImpl::RequestStream( |
| 135 const HttpRequestInfo& request_info, | 115 const HttpRequestInfo& request_info, |
| 136 RequestPriority priority, | 116 RequestPriority priority, |
| 137 const SSLConfig& server_ssl_config, | 117 const SSLConfig& server_ssl_config, |
| 138 const SSLConfig& proxy_ssl_config, | 118 const SSLConfig& proxy_ssl_config, |
| 139 HttpStreamRequest::Delegate* delegate, | 119 HttpStreamRequest::Delegate* delegate, |
| 140 bool enable_ip_based_pooling, | 120 bool enable_ip_based_pooling, |
| 141 bool enable_alternative_services, | 121 bool enable_alternative_services, |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 RequestPriority priority, | 168 RequestPriority priority, |
| 189 const SSLConfig& server_ssl_config, | 169 const SSLConfig& server_ssl_config, |
| 190 const SSLConfig& proxy_ssl_config, | 170 const SSLConfig& proxy_ssl_config, |
| 191 HttpStreamRequest::Delegate* delegate, | 171 HttpStreamRequest::Delegate* delegate, |
| 192 WebSocketHandshakeStreamBase::CreateHelper* | 172 WebSocketHandshakeStreamBase::CreateHelper* |
| 193 websocket_handshake_stream_create_helper, | 173 websocket_handshake_stream_create_helper, |
| 194 HttpStreamRequest::StreamType stream_type, | 174 HttpStreamRequest::StreamType stream_type, |
| 195 bool enable_ip_based_pooling, | 175 bool enable_ip_based_pooling, |
| 196 bool enable_alternative_services, | 176 bool enable_alternative_services, |
| 197 const NetLogWithSource& net_log) { | 177 const NetLogWithSource& net_log) { |
| 178 AddJobControllerCountToHistograms(); |
| 179 |
| 198 auto job_controller = base::MakeUnique<JobController>( | 180 auto job_controller = base::MakeUnique<JobController>( |
| 199 this, delegate, session_, job_factory_.get(), request_info, | 181 this, delegate, session_, job_factory_.get(), request_info, |
| 200 /* is_preconnect = */ false, enable_ip_based_pooling, | 182 /* is_preconnect = */ false, enable_ip_based_pooling, |
| 201 enable_alternative_services); | 183 enable_alternative_services); |
| 202 JobController* job_controller_raw_ptr = job_controller.get(); | 184 JobController* job_controller_raw_ptr = job_controller.get(); |
| 203 job_controller_set_.insert(std::move(job_controller)); | 185 job_controller_set_.insert(std::move(job_controller)); |
| 204 Request* request = job_controller_raw_ptr->Start( | 186 Request* request = job_controller_raw_ptr->Start( |
| 205 request_info, delegate, websocket_handshake_stream_create_helper, net_log, | 187 request_info, delegate, websocket_handshake_stream_create_helper, net_log, |
| 206 stream_type, priority, server_ssl_config, proxy_ssl_config); | 188 stream_type, priority, server_ssl_config, proxy_ssl_config); |
| 207 | 189 |
| 208 return request; | 190 return request; |
| 209 } | 191 } |
| 210 | 192 |
| 211 void HttpStreamFactoryImpl::PreconnectStreams( | 193 void HttpStreamFactoryImpl::PreconnectStreams( |
| 212 int num_streams, | 194 int num_streams, |
| 213 const HttpRequestInfo& request_info) { | 195 const HttpRequestInfo& request_info) { |
| 196 AddJobControllerCountToHistograms(); |
| 197 |
| 214 SSLConfig server_ssl_config; | 198 SSLConfig server_ssl_config; |
| 215 SSLConfig proxy_ssl_config; | 199 SSLConfig proxy_ssl_config; |
| 216 session_->GetSSLConfig(request_info, &server_ssl_config, &proxy_ssl_config); | 200 session_->GetSSLConfig(request_info, &server_ssl_config, &proxy_ssl_config); |
| 217 // All preconnects should perform EV certificate verification. | 201 // All preconnects should perform EV certificate verification. |
| 218 server_ssl_config.verify_ev_cert = true; | 202 server_ssl_config.verify_ev_cert = true; |
| 219 proxy_ssl_config.verify_ev_cert = true; | 203 proxy_ssl_config.verify_ev_cert = true; |
| 220 | 204 |
| 221 DCHECK(!for_websockets_); | 205 DCHECK(!for_websockets_); |
| 222 | 206 |
| 223 auto job_controller = base::MakeUnique<JobController>( | 207 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(); | 349 HostPortPair host_port_pair = proxy_info.proxy_server().host_port_pair(); |
| 366 DCHECK(!host_port_pair.IsEmpty()); | 350 DCHECK(!host_port_pair.IsEmpty()); |
| 367 | 351 |
| 368 url::SchemeHostPort scheme_host_port("https", host_port_pair.host(), | 352 url::SchemeHostPort scheme_host_port("https", host_port_pair.host(), |
| 369 host_port_pair.port()); | 353 host_port_pair.port()); |
| 370 | 354 |
| 371 return session_->http_server_properties()->SupportsRequestPriority( | 355 return session_->http_server_properties()->SupportsRequestPriority( |
| 372 scheme_host_port); | 356 scheme_host_port); |
| 373 } | 357 } |
| 374 | 358 |
| 359 void HttpStreamFactoryImpl::AddJobControllerCountToHistograms() const { |
| 360 // Only log the count of JobControllers when the count is hitting one of the |
| 361 // boundaries which is a multiple of 100: 100, 200, 300, etc. |
| 362 if (job_controller_set_.size() < 100 || job_controller_set_.size() % 100 != 0) |
| 363 return; |
| 364 |
| 365 UMA_HISTOGRAM_COUNTS_1M("Net.JobControllerSet.CountOfJobController", |
| 366 job_controller_set_.size()); |
| 367 |
| 368 int alt_job_count = 0; |
| 369 int main_job_count = 0; |
| 370 int preconnect_controller_count = 0; |
| 371 for (const auto& job_controller : job_controller_set_) { |
| 372 DCHECK(job_controller->HasPendingAltJob() || |
| 373 job_controller->HasPendingMainJob()); |
| 374 // For a preconnect controller, it should have exactly the main job. |
| 375 if (job_controller->is_preconnect()) { |
| 376 preconnect_controller_count++; |
| 377 continue; |
| 378 } |
| 379 // For non-preconnects. |
| 380 if (job_controller->HasPendingAltJob()) |
| 381 alt_job_count++; |
| 382 if (job_controller->HasPendingMainJob()) |
| 383 main_job_count++; |
| 384 } |
| 385 UMA_HISTOGRAM_COUNTS_1M("Net.JobControllerSet.CountOfPreconnect", |
| 386 preconnect_controller_count); |
| 387 UMA_HISTOGRAM_COUNTS_1M("Net.JobControllerSet.CountOfNonPreconnectAltJob", |
| 388 alt_job_count); |
| 389 UMA_HISTOGRAM_COUNTS_1M("Net.JobControllerSet.CountOfNonPreconnectMainJob", |
| 390 main_job_count); |
| 391 } |
| 392 |
| 375 void HttpStreamFactoryImpl::DumpMemoryStats( | 393 void HttpStreamFactoryImpl::DumpMemoryStats( |
| 376 base::trace_event::ProcessMemoryDump* pmd, | 394 base::trace_event::ProcessMemoryDump* pmd, |
| 377 const std::string& parent_absolute_name) const { | 395 const std::string& parent_absolute_name) const { |
| 378 if (job_controller_set_.empty()) | 396 if (job_controller_set_.empty()) |
| 379 return; | 397 return; |
| 380 std::string name = | 398 std::string name = |
| 381 base::StringPrintf("%s/stream_factory", parent_absolute_name.c_str()); | 399 base::StringPrintf("%s/stream_factory", parent_absolute_name.c_str()); |
| 382 base::trace_event::MemoryAllocatorDump* factory_dump = | 400 base::trace_event::MemoryAllocatorDump* factory_dump = |
| 383 pmd->CreateAllocatorDump(name); | 401 pmd->CreateAllocatorDump(name); |
| 384 size_t alt_job_count = 0; | 402 size_t alt_job_count = 0; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 412 factory_dump->AddScalar("main_job_count", | 430 factory_dump->AddScalar("main_job_count", |
| 413 base::trace_event::MemoryAllocatorDump::kUnitsObjects, | 431 base::trace_event::MemoryAllocatorDump::kUnitsObjects, |
| 414 main_job_count); | 432 main_job_count); |
| 415 // The number of preconnect controllers. | 433 // The number of preconnect controllers. |
| 416 factory_dump->AddScalar("preconnect_count", | 434 factory_dump->AddScalar("preconnect_count", |
| 417 base::trace_event::MemoryAllocatorDump::kUnitsObjects, | 435 base::trace_event::MemoryAllocatorDump::kUnitsObjects, |
| 418 preconnect_controller_count); | 436 preconnect_controller_count); |
| 419 } | 437 } |
| 420 | 438 |
| 421 } // namespace net | 439 } // namespace net |
| OLD | NEW |