| 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" |
| 11 #include "base/memory/ptr_util.h" | 11 #include "base/memory/ptr_util.h" |
| 12 #include "base/metrics/histogram_macros.h" | 12 #include "base/metrics/histogram_macros.h" |
| 13 #include "base/stl_util.h" | 13 #include "base/stl_util.h" |
| 14 #include "base/strings/string_util.h" | 14 #include "base/strings/string_util.h" |
| 15 #include "base/strings/stringprintf.h" | 15 #include "base/strings/stringprintf.h" |
| 16 #include "base/threading/thread_checker.h" |
| 16 #include "base/trace_event/memory_allocator_dump.h" | 17 #include "base/trace_event/memory_allocator_dump.h" |
| 17 #include "base/trace_event/memory_usage_estimator.h" | 18 #include "base/trace_event/memory_usage_estimator.h" |
| 18 #include "base/trace_event/process_memory_dump.h" | 19 #include "base/trace_event/process_memory_dump.h" |
| 19 #include "net/http/http_network_session.h" | 20 #include "net/http/http_network_session.h" |
| 20 #include "net/http/http_server_properties.h" | 21 #include "net/http/http_server_properties.h" |
| 21 #include "net/http/http_stream_factory_impl_job.h" | 22 #include "net/http/http_stream_factory_impl_job.h" |
| 22 #include "net/http/http_stream_factory_impl_job_controller.h" | 23 #include "net/http/http_stream_factory_impl_job_controller.h" |
| 23 #include "net/http/http_stream_factory_impl_request.h" | 24 #include "net/http/http_stream_factory_impl_request.h" |
| 24 #include "net/http/transport_security_state.h" | 25 #include "net/http/transport_security_state.h" |
| 25 #include "net/proxy/proxy_info.h" | 26 #include "net/proxy/proxy_info.h" |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 alternative_proxy_server, enable_ip_based_pooling, net_log); | 97 alternative_proxy_server, enable_ip_based_pooling, net_log); |
| 97 } | 98 } |
| 98 }; | 99 }; |
| 99 | 100 |
| 100 } // anonymous namespace | 101 } // anonymous namespace |
| 101 | 102 |
| 102 HttpStreamFactoryImpl::HttpStreamFactoryImpl(HttpNetworkSession* session, | 103 HttpStreamFactoryImpl::HttpStreamFactoryImpl(HttpNetworkSession* session, |
| 103 bool for_websockets) | 104 bool for_websockets) |
| 104 : session_(session), | 105 : session_(session), |
| 105 job_factory_(new DefaultJobFactory()), | 106 job_factory_(new DefaultJobFactory()), |
| 106 for_websockets_(for_websockets) {} | 107 for_websockets_(for_websockets) { |
| 108 DCHECK(thread_checker_.CalledOnValidThread()); |
| 109 NetworkChangeNotifier::AddMetricsObserver(this); |
| 110 } |
| 107 | 111 |
| 108 HttpStreamFactoryImpl::~HttpStreamFactoryImpl() { | 112 HttpStreamFactoryImpl::~HttpStreamFactoryImpl() { |
| 109 DCHECK(spdy_session_request_map_.empty()); | 113 DCHECK(spdy_session_request_map_.empty()); |
| 110 int alt_job_count = 0; | |
| 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 } | 114 } |
| 133 | 115 |
| 134 HttpStreamRequest* HttpStreamFactoryImpl::RequestStream( | 116 HttpStreamRequest* HttpStreamFactoryImpl::RequestStream( |
| 135 const HttpRequestInfo& request_info, | 117 const HttpRequestInfo& request_info, |
| 136 RequestPriority priority, | 118 RequestPriority priority, |
| 137 const SSLConfig& server_ssl_config, | 119 const SSLConfig& server_ssl_config, |
| 138 const SSLConfig& proxy_ssl_config, | 120 const SSLConfig& proxy_ssl_config, |
| 139 HttpStreamRequest::Delegate* delegate, | 121 HttpStreamRequest::Delegate* delegate, |
| 140 bool enable_ip_based_pooling, | 122 bool enable_ip_based_pooling, |
| 141 bool enable_alternative_services, | 123 bool enable_alternative_services, |
| (...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 411 // The number of non-preconnect controllers with a pending main job. | 393 // The number of non-preconnect controllers with a pending main job. |
| 412 factory_dump->AddScalar("main_job_count", | 394 factory_dump->AddScalar("main_job_count", |
| 413 base::trace_event::MemoryAllocatorDump::kUnitsObjects, | 395 base::trace_event::MemoryAllocatorDump::kUnitsObjects, |
| 414 main_job_count); | 396 main_job_count); |
| 415 // The number of preconnect controllers. | 397 // The number of preconnect controllers. |
| 416 factory_dump->AddScalar("preconnect_count", | 398 factory_dump->AddScalar("preconnect_count", |
| 417 base::trace_event::MemoryAllocatorDump::kUnitsObjects, | 399 base::trace_event::MemoryAllocatorDump::kUnitsObjects, |
| 418 preconnect_controller_count); | 400 preconnect_controller_count); |
| 419 } | 401 } |
| 420 | 402 |
| 403 void HttpStreamFactoryImpl::OnMetricsFinalize() { |
| 404 DCHECK(thread_checker_.CalledOnValidThread()); |
| 405 int alt_job_count = 0; |
| 406 int main_job_count = 0; |
| 407 int preconnect_controller_count = 0; |
| 408 for (const auto& it : job_controller_set_) { |
| 409 DCHECK(it->HasPendingAltJob() || it->HasPendingMainJob()); |
| 410 // For a preconnect controller, it should have exactly the main job. |
| 411 if (it->is_preconnect()) { |
| 412 preconnect_controller_count++; |
| 413 continue; |
| 414 } |
| 415 // For non-preconnects. |
| 416 if (it->HasPendingAltJob()) |
| 417 alt_job_count++; |
| 418 if (it->HasPendingMainJob()) |
| 419 main_job_count++; |
| 420 } |
| 421 UMA_HISTOGRAM_COUNTS_1M("Net.JobControllerSet.CountOfPreconnect", |
| 422 preconnect_controller_count); |
| 423 UMA_HISTOGRAM_COUNTS_1M("Net.JobControllerSet.CountOfNonPreconnectAltJob", |
| 424 alt_job_count); |
| 425 UMA_HISTOGRAM_COUNTS_1M("Net.JobControllerSet.CountOfNonPreconnectMainJob", |
| 426 main_job_count); |
| 427 } |
| 428 |
| 421 } // namespace net | 429 } // namespace net |
| OLD | NEW |