| 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 #include <utility> |
| 9 | 10 |
| 10 #include "base/logging.h" | 11 #include "base/logging.h" |
| 11 #include "base/memory/ptr_util.h" | 12 #include "base/memory/ptr_util.h" |
| 12 #include "base/metrics/histogram_macros.h" | 13 #include "base/metrics/histogram_macros.h" |
| 13 #include "base/stl_util.h" | 14 #include "base/stl_util.h" |
| 14 #include "base/strings/string_util.h" | 15 #include "base/strings/string_util.h" |
| 15 #include "base/strings/stringprintf.h" | 16 #include "base/strings/stringprintf.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" |
| (...skipping 19 matching lines...) Expand all Loading... |
| 38 job_factory_(new JobFactory()), | 39 job_factory_(new JobFactory()), |
| 39 for_websockets_(for_websockets), | 40 for_websockets_(for_websockets), |
| 40 last_logged_job_controller_count_(0) {} | 41 last_logged_job_controller_count_(0) {} |
| 41 | 42 |
| 42 HttpStreamFactoryImpl::~HttpStreamFactoryImpl() { | 43 HttpStreamFactoryImpl::~HttpStreamFactoryImpl() { |
| 43 DCHECK(spdy_session_request_map_.empty()); | 44 DCHECK(spdy_session_request_map_.empty()); |
| 44 UMA_HISTOGRAM_COUNTS_1M("Net.JobControllerSet.CountOfJobControllerAtShutDown", | 45 UMA_HISTOGRAM_COUNTS_1M("Net.JobControllerSet.CountOfJobControllerAtShutDown", |
| 45 job_controller_set_.size()); | 46 job_controller_set_.size()); |
| 46 } | 47 } |
| 47 | 48 |
| 48 HttpStreamRequest* HttpStreamFactoryImpl::RequestStream( | 49 std::unique_ptr<HttpStreamRequest> HttpStreamFactoryImpl::RequestStream( |
| 49 const HttpRequestInfo& request_info, | 50 const HttpRequestInfo& request_info, |
| 50 RequestPriority priority, | 51 RequestPriority priority, |
| 51 const SSLConfig& server_ssl_config, | 52 const SSLConfig& server_ssl_config, |
| 52 const SSLConfig& proxy_ssl_config, | 53 const SSLConfig& proxy_ssl_config, |
| 53 HttpStreamRequest::Delegate* delegate, | 54 HttpStreamRequest::Delegate* delegate, |
| 54 bool enable_ip_based_pooling, | 55 bool enable_ip_based_pooling, |
| 55 bool enable_alternative_services, | 56 bool enable_alternative_services, |
| 56 const NetLogWithSource& net_log) { | 57 const NetLogWithSource& net_log) { |
| 57 DCHECK(!for_websockets_); | 58 DCHECK(!for_websockets_); |
| 58 return RequestStreamInternal( | 59 return RequestStreamInternal( |
| 59 request_info, priority, server_ssl_config, proxy_ssl_config, delegate, | 60 request_info, priority, server_ssl_config, proxy_ssl_config, delegate, |
| 60 nullptr, HttpStreamRequest::HTTP_STREAM, enable_ip_based_pooling, | 61 nullptr, HttpStreamRequest::HTTP_STREAM, enable_ip_based_pooling, |
| 61 enable_alternative_services, net_log); | 62 enable_alternative_services, net_log); |
| 62 } | 63 } |
| 63 | 64 |
| 64 HttpStreamRequest* HttpStreamFactoryImpl::RequestWebSocketHandshakeStream( | 65 std::unique_ptr<HttpStreamRequest> |
| 66 HttpStreamFactoryImpl::RequestWebSocketHandshakeStream( |
| 65 const HttpRequestInfo& request_info, | 67 const HttpRequestInfo& request_info, |
| 66 RequestPriority priority, | 68 RequestPriority priority, |
| 67 const SSLConfig& server_ssl_config, | 69 const SSLConfig& server_ssl_config, |
| 68 const SSLConfig& proxy_ssl_config, | 70 const SSLConfig& proxy_ssl_config, |
| 69 HttpStreamRequest::Delegate* delegate, | 71 HttpStreamRequest::Delegate* delegate, |
| 70 WebSocketHandshakeStreamBase::CreateHelper* create_helper, | 72 WebSocketHandshakeStreamBase::CreateHelper* create_helper, |
| 71 bool enable_ip_based_pooling, | 73 bool enable_ip_based_pooling, |
| 72 bool enable_alternative_services, | 74 bool enable_alternative_services, |
| 73 const NetLogWithSource& net_log) { | 75 const NetLogWithSource& net_log) { |
| 74 DCHECK(for_websockets_); | 76 DCHECK(for_websockets_); |
| 75 DCHECK(create_helper); | 77 DCHECK(create_helper); |
| 76 return RequestStreamInternal( | 78 return RequestStreamInternal( |
| 77 request_info, priority, server_ssl_config, proxy_ssl_config, delegate, | 79 request_info, priority, server_ssl_config, proxy_ssl_config, delegate, |
| 78 create_helper, HttpStreamRequest::HTTP_STREAM, enable_ip_based_pooling, | 80 create_helper, HttpStreamRequest::HTTP_STREAM, enable_ip_based_pooling, |
| 79 enable_alternative_services, net_log); | 81 enable_alternative_services, net_log); |
| 80 } | 82 } |
| 81 | 83 |
| 82 HttpStreamRequest* HttpStreamFactoryImpl::RequestBidirectionalStreamImpl( | 84 std::unique_ptr<HttpStreamRequest> |
| 85 HttpStreamFactoryImpl::RequestBidirectionalStreamImpl( |
| 83 const HttpRequestInfo& request_info, | 86 const HttpRequestInfo& request_info, |
| 84 RequestPriority priority, | 87 RequestPriority priority, |
| 85 const SSLConfig& server_ssl_config, | 88 const SSLConfig& server_ssl_config, |
| 86 const SSLConfig& proxy_ssl_config, | 89 const SSLConfig& proxy_ssl_config, |
| 87 HttpStreamRequest::Delegate* delegate, | 90 HttpStreamRequest::Delegate* delegate, |
| 88 bool enable_ip_based_pooling, | 91 bool enable_ip_based_pooling, |
| 89 bool enable_alternative_services, | 92 bool enable_alternative_services, |
| 90 const NetLogWithSource& net_log) { | 93 const NetLogWithSource& net_log) { |
| 91 DCHECK(!for_websockets_); | 94 DCHECK(!for_websockets_); |
| 92 DCHECK(request_info.url.SchemeIs(url::kHttpsScheme)); | 95 DCHECK(request_info.url.SchemeIs(url::kHttpsScheme)); |
| 93 | 96 |
| 94 return RequestStreamInternal( | 97 return RequestStreamInternal( |
| 95 request_info, priority, server_ssl_config, proxy_ssl_config, delegate, | 98 request_info, priority, server_ssl_config, proxy_ssl_config, delegate, |
| 96 nullptr, HttpStreamRequest::BIDIRECTIONAL_STREAM, enable_ip_based_pooling, | 99 nullptr, HttpStreamRequest::BIDIRECTIONAL_STREAM, enable_ip_based_pooling, |
| 97 enable_alternative_services, net_log); | 100 enable_alternative_services, net_log); |
| 98 } | 101 } |
| 99 | 102 |
| 100 HttpStreamRequest* HttpStreamFactoryImpl::RequestStreamInternal( | 103 std::unique_ptr<HttpStreamRequest> HttpStreamFactoryImpl::RequestStreamInternal( |
| 101 const HttpRequestInfo& request_info, | 104 const HttpRequestInfo& request_info, |
| 102 RequestPriority priority, | 105 RequestPriority priority, |
| 103 const SSLConfig& server_ssl_config, | 106 const SSLConfig& server_ssl_config, |
| 104 const SSLConfig& proxy_ssl_config, | 107 const SSLConfig& proxy_ssl_config, |
| 105 HttpStreamRequest::Delegate* delegate, | 108 HttpStreamRequest::Delegate* delegate, |
| 106 WebSocketHandshakeStreamBase::CreateHelper* | 109 WebSocketHandshakeStreamBase::CreateHelper* |
| 107 websocket_handshake_stream_create_helper, | 110 websocket_handshake_stream_create_helper, |
| 108 HttpStreamRequest::StreamType stream_type, | 111 HttpStreamRequest::StreamType stream_type, |
| 109 bool enable_ip_based_pooling, | 112 bool enable_ip_based_pooling, |
| 110 bool enable_alternative_services, | 113 bool enable_alternative_services, |
| 111 const NetLogWithSource& net_log) { | 114 const NetLogWithSource& net_log) { |
| 112 AddJobControllerCountToHistograms(); | 115 AddJobControllerCountToHistograms(); |
| 113 | 116 |
| 114 auto job_controller = base::MakeUnique<JobController>( | 117 auto job_controller = base::MakeUnique<JobController>( |
| 115 this, delegate, session_, job_factory_.get(), request_info, | 118 this, delegate, session_, job_factory_.get(), request_info, |
| 116 /* is_preconnect = */ false, enable_ip_based_pooling, | 119 /* is_preconnect = */ false, enable_ip_based_pooling, |
| 117 enable_alternative_services, server_ssl_config, proxy_ssl_config); | 120 enable_alternative_services, server_ssl_config, proxy_ssl_config); |
| 118 JobController* job_controller_raw_ptr = job_controller.get(); | 121 JobController* job_controller_raw_ptr = job_controller.get(); |
| 119 job_controller_set_.insert(std::move(job_controller)); | 122 job_controller_set_.insert(std::move(job_controller)); |
| 120 Request* request = job_controller_raw_ptr->Start( | 123 return job_controller_raw_ptr->Start(delegate, |
| 121 delegate, websocket_handshake_stream_create_helper, net_log, stream_type, | 124 websocket_handshake_stream_create_helper, |
| 122 priority); | 125 net_log, stream_type, priority); |
| 123 | |
| 124 return request; | |
| 125 } | 126 } |
| 126 | 127 |
| 127 void HttpStreamFactoryImpl::PreconnectStreams( | 128 void HttpStreamFactoryImpl::PreconnectStreams( |
| 128 int num_streams, | 129 int num_streams, |
| 129 const HttpRequestInfo& request_info) { | 130 const HttpRequestInfo& request_info) { |
| 130 DCHECK(request_info.url.is_valid()); | 131 DCHECK(request_info.url.is_valid()); |
| 131 | 132 |
| 132 AddJobControllerCountToHistograms(); | 133 AddJobControllerCountToHistograms(); |
| 133 | 134 |
| 134 SSLConfig server_ssl_config; | 135 SSLConfig server_ssl_config; |
| (...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 385 factory_dump->AddScalar("main_job_count", | 386 factory_dump->AddScalar("main_job_count", |
| 386 base::trace_event::MemoryAllocatorDump::kUnitsObjects, | 387 base::trace_event::MemoryAllocatorDump::kUnitsObjects, |
| 387 main_job_count); | 388 main_job_count); |
| 388 // The number of preconnect controllers. | 389 // The number of preconnect controllers. |
| 389 factory_dump->AddScalar("preconnect_count", | 390 factory_dump->AddScalar("preconnect_count", |
| 390 base::trace_event::MemoryAllocatorDump::kUnitsObjects, | 391 base::trace_event::MemoryAllocatorDump::kUnitsObjects, |
| 391 num_controllers_for_preconnect); | 392 num_controllers_for_preconnect); |
| 392 } | 393 } |
| 393 | 394 |
| 394 } // namespace net | 395 } // namespace net |
| OLD | NEW |