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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 HttpStreamFactoryImpl::Job* CreateJob( | 43 HttpStreamFactoryImpl::Job* CreateJob( |
44 HttpStreamFactoryImpl::Job::Delegate* delegate, | 44 HttpStreamFactoryImpl::Job::Delegate* delegate, |
45 HttpStreamFactoryImpl::JobType job_type, | 45 HttpStreamFactoryImpl::JobType job_type, |
46 HttpNetworkSession* session, | 46 HttpNetworkSession* session, |
47 const HttpRequestInfo& request_info, | 47 const HttpRequestInfo& request_info, |
48 RequestPriority priority, | 48 RequestPriority priority, |
49 const SSLConfig& server_ssl_config, | 49 const SSLConfig& server_ssl_config, |
50 const SSLConfig& proxy_ssl_config, | 50 const SSLConfig& proxy_ssl_config, |
51 HostPortPair destination, | 51 HostPortPair destination, |
52 GURL origin_url, | 52 GURL origin_url, |
| 53 bool enable_ip_based_pooling, |
53 NetLog* net_log) override { | 54 NetLog* net_log) override { |
54 return new HttpStreamFactoryImpl::Job( | 55 return new HttpStreamFactoryImpl::Job( |
55 delegate, job_type, session, request_info, priority, server_ssl_config, | 56 delegate, job_type, session, request_info, priority, server_ssl_config, |
56 proxy_ssl_config, destination, origin_url, net_log); | 57 proxy_ssl_config, destination, origin_url, enable_ip_based_pooling, |
| 58 net_log); |
57 } | 59 } |
58 | 60 |
59 HttpStreamFactoryImpl::Job* CreateJob( | 61 HttpStreamFactoryImpl::Job* CreateJob( |
60 HttpStreamFactoryImpl::Job::Delegate* delegate, | 62 HttpStreamFactoryImpl::Job::Delegate* delegate, |
61 HttpStreamFactoryImpl::JobType job_type, | 63 HttpStreamFactoryImpl::JobType job_type, |
62 HttpNetworkSession* session, | 64 HttpNetworkSession* session, |
63 const HttpRequestInfo& request_info, | 65 const HttpRequestInfo& request_info, |
64 RequestPriority priority, | 66 RequestPriority priority, |
65 const SSLConfig& server_ssl_config, | 67 const SSLConfig& server_ssl_config, |
66 const SSLConfig& proxy_ssl_config, | 68 const SSLConfig& proxy_ssl_config, |
67 HostPortPair destination, | 69 HostPortPair destination, |
68 GURL origin_url, | 70 GURL origin_url, |
69 AlternativeService alternative_service, | 71 AlternativeService alternative_service, |
| 72 bool enable_ip_based_pooling, |
70 NetLog* net_log) override { | 73 NetLog* net_log) override { |
71 return new HttpStreamFactoryImpl::Job( | 74 return new HttpStreamFactoryImpl::Job( |
72 delegate, job_type, session, request_info, priority, server_ssl_config, | 75 delegate, job_type, session, request_info, priority, server_ssl_config, |
73 proxy_ssl_config, destination, origin_url, alternative_service, | 76 proxy_ssl_config, destination, origin_url, alternative_service, |
74 ProxyServer(), net_log); | 77 ProxyServer(), enable_ip_based_pooling, net_log); |
75 } | 78 } |
76 | 79 |
77 HttpStreamFactoryImpl::Job* CreateJob( | 80 HttpStreamFactoryImpl::Job* CreateJob( |
78 HttpStreamFactoryImpl::Job::Delegate* delegate, | 81 HttpStreamFactoryImpl::Job::Delegate* delegate, |
79 HttpStreamFactoryImpl::JobType job_type, | 82 HttpStreamFactoryImpl::JobType job_type, |
80 HttpNetworkSession* session, | 83 HttpNetworkSession* session, |
81 const HttpRequestInfo& request_info, | 84 const HttpRequestInfo& request_info, |
82 RequestPriority priority, | 85 RequestPriority priority, |
83 const SSLConfig& server_ssl_config, | 86 const SSLConfig& server_ssl_config, |
84 const SSLConfig& proxy_ssl_config, | 87 const SSLConfig& proxy_ssl_config, |
85 HostPortPair destination, | 88 HostPortPair destination, |
86 GURL origin_url, | 89 GURL origin_url, |
87 const ProxyServer& alternative_proxy_server, | 90 const ProxyServer& alternative_proxy_server, |
| 91 bool enable_ip_based_pooling, |
88 NetLog* net_log) override { | 92 NetLog* net_log) override { |
89 return new HttpStreamFactoryImpl::Job( | 93 return new HttpStreamFactoryImpl::Job( |
90 delegate, job_type, session, request_info, priority, server_ssl_config, | 94 delegate, job_type, session, request_info, priority, server_ssl_config, |
91 proxy_ssl_config, destination, origin_url, AlternativeService(), | 95 proxy_ssl_config, destination, origin_url, AlternativeService(), |
92 alternative_proxy_server, net_log); | 96 alternative_proxy_server, enable_ip_based_pooling, net_log); |
93 } | 97 } |
94 }; | 98 }; |
95 | 99 |
96 } // anonymous namespace | 100 } // anonymous namespace |
97 | 101 |
98 HttpStreamFactoryImpl::HttpStreamFactoryImpl(HttpNetworkSession* session, | 102 HttpStreamFactoryImpl::HttpStreamFactoryImpl(HttpNetworkSession* session, |
99 bool for_websockets) | 103 bool for_websockets) |
100 : session_(session), | 104 : session_(session), |
101 job_factory_(new DefaultJobFactory()), | 105 job_factory_(new DefaultJobFactory()), |
102 for_websockets_(for_websockets) {} | 106 for_websockets_(for_websockets) {} |
(...skipping 24 matching lines...) Expand all Loading... |
127 UMA_HISTOGRAM_COUNTS_1M("Net.JobControllerSet.CountOfNonPreconnectMainJob", | 131 UMA_HISTOGRAM_COUNTS_1M("Net.JobControllerSet.CountOfNonPreconnectMainJob", |
128 main_job_count); | 132 main_job_count); |
129 } | 133 } |
130 | 134 |
131 HttpStreamRequest* HttpStreamFactoryImpl::RequestStream( | 135 HttpStreamRequest* HttpStreamFactoryImpl::RequestStream( |
132 const HttpRequestInfo& request_info, | 136 const HttpRequestInfo& request_info, |
133 RequestPriority priority, | 137 RequestPriority priority, |
134 const SSLConfig& server_ssl_config, | 138 const SSLConfig& server_ssl_config, |
135 const SSLConfig& proxy_ssl_config, | 139 const SSLConfig& proxy_ssl_config, |
136 HttpStreamRequest::Delegate* delegate, | 140 HttpStreamRequest::Delegate* delegate, |
| 141 bool enable_ip_based_pooling, |
137 const NetLogWithSource& net_log) { | 142 const NetLogWithSource& net_log) { |
138 DCHECK(!for_websockets_); | 143 DCHECK(!for_websockets_); |
139 return RequestStreamInternal(request_info, priority, server_ssl_config, | 144 return RequestStreamInternal(request_info, priority, server_ssl_config, |
140 proxy_ssl_config, delegate, nullptr, | 145 proxy_ssl_config, delegate, nullptr, |
141 HttpStreamRequest::HTTP_STREAM, net_log); | 146 HttpStreamRequest::HTTP_STREAM, |
| 147 enable_ip_based_pooling, net_log); |
142 } | 148 } |
143 | 149 |
144 HttpStreamRequest* HttpStreamFactoryImpl::RequestWebSocketHandshakeStream( | 150 HttpStreamRequest* HttpStreamFactoryImpl::RequestWebSocketHandshakeStream( |
145 const HttpRequestInfo& request_info, | 151 const HttpRequestInfo& request_info, |
146 RequestPriority priority, | 152 RequestPriority priority, |
147 const SSLConfig& server_ssl_config, | 153 const SSLConfig& server_ssl_config, |
148 const SSLConfig& proxy_ssl_config, | 154 const SSLConfig& proxy_ssl_config, |
149 HttpStreamRequest::Delegate* delegate, | 155 HttpStreamRequest::Delegate* delegate, |
150 WebSocketHandshakeStreamBase::CreateHelper* create_helper, | 156 WebSocketHandshakeStreamBase::CreateHelper* create_helper, |
| 157 bool enable_ip_based_pooling, |
151 const NetLogWithSource& net_log) { | 158 const NetLogWithSource& net_log) { |
152 DCHECK(for_websockets_); | 159 DCHECK(for_websockets_); |
153 DCHECK(create_helper); | 160 DCHECK(create_helper); |
154 return RequestStreamInternal(request_info, priority, server_ssl_config, | 161 return RequestStreamInternal(request_info, priority, server_ssl_config, |
155 proxy_ssl_config, delegate, create_helper, | 162 proxy_ssl_config, delegate, create_helper, |
156 HttpStreamRequest::HTTP_STREAM, net_log); | 163 HttpStreamRequest::HTTP_STREAM, |
| 164 enable_ip_based_pooling, net_log); |
157 } | 165 } |
158 | 166 |
159 HttpStreamRequest* HttpStreamFactoryImpl::RequestBidirectionalStreamImpl( | 167 HttpStreamRequest* HttpStreamFactoryImpl::RequestBidirectionalStreamImpl( |
160 const HttpRequestInfo& request_info, | 168 const HttpRequestInfo& request_info, |
161 RequestPriority priority, | 169 RequestPriority priority, |
162 const SSLConfig& server_ssl_config, | 170 const SSLConfig& server_ssl_config, |
163 const SSLConfig& proxy_ssl_config, | 171 const SSLConfig& proxy_ssl_config, |
164 HttpStreamRequest::Delegate* delegate, | 172 HttpStreamRequest::Delegate* delegate, |
| 173 bool enable_ip_based_pooling, |
165 const NetLogWithSource& net_log) { | 174 const NetLogWithSource& net_log) { |
166 DCHECK(!for_websockets_); | 175 DCHECK(!for_websockets_); |
167 DCHECK(request_info.url.SchemeIs(url::kHttpsScheme)); | 176 DCHECK(request_info.url.SchemeIs(url::kHttpsScheme)); |
168 | 177 |
169 return RequestStreamInternal( | 178 return RequestStreamInternal(request_info, priority, server_ssl_config, |
170 request_info, priority, server_ssl_config, proxy_ssl_config, delegate, | 179 proxy_ssl_config, delegate, nullptr, |
171 nullptr, HttpStreamRequest::BIDIRECTIONAL_STREAM, net_log); | 180 HttpStreamRequest::BIDIRECTIONAL_STREAM, |
| 181 enable_ip_based_pooling, net_log); |
172 } | 182 } |
173 | 183 |
174 HttpStreamRequest* HttpStreamFactoryImpl::RequestStreamInternal( | 184 HttpStreamRequest* HttpStreamFactoryImpl::RequestStreamInternal( |
175 const HttpRequestInfo& request_info, | 185 const HttpRequestInfo& request_info, |
176 RequestPriority priority, | 186 RequestPriority priority, |
177 const SSLConfig& server_ssl_config, | 187 const SSLConfig& server_ssl_config, |
178 const SSLConfig& proxy_ssl_config, | 188 const SSLConfig& proxy_ssl_config, |
179 HttpStreamRequest::Delegate* delegate, | 189 HttpStreamRequest::Delegate* delegate, |
180 WebSocketHandshakeStreamBase::CreateHelper* | 190 WebSocketHandshakeStreamBase::CreateHelper* |
181 websocket_handshake_stream_create_helper, | 191 websocket_handshake_stream_create_helper, |
182 HttpStreamRequest::StreamType stream_type, | 192 HttpStreamRequest::StreamType stream_type, |
| 193 bool enable_ip_based_pooling, |
183 const NetLogWithSource& net_log) { | 194 const NetLogWithSource& net_log) { |
184 auto job_controller = base::MakeUnique<JobController>( | 195 auto job_controller = base::MakeUnique<JobController>( |
185 this, delegate, session_, job_factory_.get(), request_info, | 196 this, delegate, session_, job_factory_.get(), request_info, |
186 /*is_preconnect=*/false); | 197 /* is_preconnect = */ false, enable_ip_based_pooling); |
187 JobController* job_controller_raw_ptr = job_controller.get(); | 198 JobController* job_controller_raw_ptr = job_controller.get(); |
188 job_controller_set_.insert(std::move(job_controller)); | 199 job_controller_set_.insert(std::move(job_controller)); |
189 Request* request = job_controller_raw_ptr->Start( | 200 Request* request = job_controller_raw_ptr->Start( |
190 request_info, delegate, websocket_handshake_stream_create_helper, net_log, | 201 request_info, delegate, websocket_handshake_stream_create_helper, net_log, |
191 stream_type, priority, server_ssl_config, proxy_ssl_config); | 202 stream_type, priority, server_ssl_config, proxy_ssl_config); |
192 | 203 |
193 return request; | 204 return request; |
194 } | 205 } |
195 | 206 |
196 void HttpStreamFactoryImpl::PreconnectStreams( | 207 void HttpStreamFactoryImpl::PreconnectStreams( |
197 int num_streams, | 208 int num_streams, |
198 const HttpRequestInfo& request_info) { | 209 const HttpRequestInfo& request_info) { |
199 SSLConfig server_ssl_config; | 210 SSLConfig server_ssl_config; |
200 SSLConfig proxy_ssl_config; | 211 SSLConfig proxy_ssl_config; |
201 session_->GetSSLConfig(request_info, &server_ssl_config, &proxy_ssl_config); | 212 session_->GetSSLConfig(request_info, &server_ssl_config, &proxy_ssl_config); |
202 // All preconnects should perform EV certificate verification. | 213 // All preconnects should perform EV certificate verification. |
203 server_ssl_config.verify_ev_cert = true; | 214 server_ssl_config.verify_ev_cert = true; |
204 proxy_ssl_config.verify_ev_cert = true; | 215 proxy_ssl_config.verify_ev_cert = true; |
205 | 216 |
206 DCHECK(!for_websockets_); | 217 DCHECK(!for_websockets_); |
207 | 218 |
208 auto job_controller = base::MakeUnique<JobController>( | 219 auto job_controller = base::MakeUnique<JobController>( |
209 this, nullptr, session_, job_factory_.get(), request_info, | 220 this, nullptr, session_, job_factory_.get(), request_info, |
210 /*is_preconnect=*/true); | 221 /* is_preconnect = */ true, |
| 222 /* enable_ip_based_pooling = */ true); |
211 JobController* job_controller_raw_ptr = job_controller.get(); | 223 JobController* job_controller_raw_ptr = job_controller.get(); |
212 job_controller_set_.insert(std::move(job_controller)); | 224 job_controller_set_.insert(std::move(job_controller)); |
213 job_controller_raw_ptr->Preconnect(num_streams, request_info, | 225 job_controller_raw_ptr->Preconnect(num_streams, request_info, |
214 server_ssl_config, proxy_ssl_config); | 226 server_ssl_config, proxy_ssl_config); |
215 } | 227 } |
216 | 228 |
217 const HostMappingRules* HttpStreamFactoryImpl::GetHostMappingRules() const { | 229 const HostMappingRules* HttpStreamFactoryImpl::GetHostMappingRules() const { |
218 return session_->params().host_mapping_rules; | 230 return session_->params().host_mapping_rules; |
219 } | 231 } |
220 | 232 |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
395 factory_dump->AddScalar("main_job_count", | 407 factory_dump->AddScalar("main_job_count", |
396 base::trace_event::MemoryAllocatorDump::kUnitsObjects, | 408 base::trace_event::MemoryAllocatorDump::kUnitsObjects, |
397 main_job_count); | 409 main_job_count); |
398 // The number of preconnect controllers. | 410 // The number of preconnect controllers. |
399 factory_dump->AddScalar("preconnect_count", | 411 factory_dump->AddScalar("preconnect_count", |
400 base::trace_event::MemoryAllocatorDump::kUnitsObjects, | 412 base::trace_event::MemoryAllocatorDump::kUnitsObjects, |
401 preconnect_controller_count); | 413 preconnect_controller_count); |
402 } | 414 } |
403 | 415 |
404 } // namespace net | 416 } // namespace net |
OLD | NEW |