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