| OLD | NEW |
| 1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2016 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_job_controller.h" | 5 #include "net/http/http_stream_factory_impl_job_controller.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 job_factory_(job_factory), | 50 job_factory_(job_factory), |
| 51 request_(nullptr), | 51 request_(nullptr), |
| 52 delegate_(delegate), | 52 delegate_(delegate), |
| 53 is_preconnect_(false), | 53 is_preconnect_(false), |
| 54 alternative_job_failed_(false), | 54 alternative_job_failed_(false), |
| 55 job_bound_(false), | 55 job_bound_(false), |
| 56 main_job_is_blocked_(false), | 56 main_job_is_blocked_(false), |
| 57 main_job_is_resumed_(false), | 57 main_job_is_resumed_(false), |
| 58 bound_job_(nullptr), | 58 bound_job_(nullptr), |
| 59 can_start_alternative_proxy_job_(false), | 59 can_start_alternative_proxy_job_(false), |
| 60 privacy_mode_(PRIVACY_MODE_DISABLED), |
| 60 ptr_factory_(this) { | 61 ptr_factory_(this) { |
| 61 DCHECK(factory); | 62 DCHECK(factory); |
| 62 } | 63 } |
| 63 | 64 |
| 64 HttpStreamFactoryImpl::JobController::~JobController() { | 65 HttpStreamFactoryImpl::JobController::~JobController() { |
| 65 main_job_.reset(); | 66 main_job_.reset(); |
| 66 alternative_job_.reset(); | 67 alternative_job_.reset(); |
| 67 bound_job_ = nullptr; | 68 bound_job_ = nullptr; |
| 68 } | 69 } |
| 69 | 70 |
| 70 bool HttpStreamFactoryImpl::JobController::for_websockets() { | 71 bool HttpStreamFactoryImpl::JobController::for_websockets() { |
| 71 return factory_->for_websockets_; | 72 return factory_->for_websockets_; |
| 72 } | 73 } |
| 73 | 74 |
| 74 HttpStreamFactoryImpl::Request* HttpStreamFactoryImpl::JobController::Start( | 75 HttpStreamFactoryImpl::Request* HttpStreamFactoryImpl::JobController::Start( |
| 75 const HttpRequestInfo& request_info, | 76 const HttpRequestInfo& request_info, |
| 76 HttpStreamRequest::Delegate* delegate, | 77 HttpStreamRequest::Delegate* delegate, |
| 77 WebSocketHandshakeStreamBase::CreateHelper* | 78 WebSocketHandshakeStreamBase::CreateHelper* |
| 78 websocket_handshake_stream_create_helper, | 79 websocket_handshake_stream_create_helper, |
| 79 const NetLogWithSource& net_log, | 80 const NetLogWithSource& net_log, |
| 80 HttpStreamRequest::StreamType stream_type, | 81 HttpStreamRequest::StreamType stream_type, |
| 81 RequestPriority priority, | 82 RequestPriority priority, |
| 82 const SSLConfig& server_ssl_config, | 83 const SSLConfig& server_ssl_config, |
| 83 const SSLConfig& proxy_ssl_config) { | 84 const SSLConfig& proxy_ssl_config) { |
| 84 DCHECK(factory_); | 85 DCHECK(factory_); |
| 85 DCHECK(!request_); | 86 DCHECK(!request_); |
| 86 | 87 |
| 88 privacy_mode_ = request_info.privacy_mode; |
| 89 |
| 87 request_ = new Request(request_info.url, this, delegate, | 90 request_ = new Request(request_info.url, this, delegate, |
| 88 websocket_handshake_stream_create_helper, net_log, | 91 websocket_handshake_stream_create_helper, net_log, |
| 89 stream_type); | 92 stream_type); |
| 90 | 93 |
| 91 CreateJobs(request_info, priority, server_ssl_config, proxy_ssl_config, | 94 CreateJobs(request_info, priority, server_ssl_config, proxy_ssl_config, |
| 92 delegate, stream_type, net_log); | 95 delegate, stream_type, net_log); |
| 93 | 96 |
| 94 return request_; | 97 return request_; |
| 95 } | 98 } |
| 96 | 99 |
| 97 void HttpStreamFactoryImpl::JobController::Preconnect( | 100 void HttpStreamFactoryImpl::JobController::Preconnect( |
| 98 int num_streams, | 101 int num_streams, |
| 99 const HttpRequestInfo& request_info, | 102 const HttpRequestInfo& request_info, |
| 100 const SSLConfig& server_ssl_config, | 103 const SSLConfig& server_ssl_config, |
| 101 const SSLConfig& proxy_ssl_config) { | 104 const SSLConfig& proxy_ssl_config) { |
| 102 DCHECK(!main_job_); | 105 DCHECK(!main_job_); |
| 103 DCHECK(!alternative_job_); | 106 DCHECK(!alternative_job_); |
| 104 | 107 |
| 108 privacy_mode_ = request_info.privacy_mode; |
| 109 |
| 105 is_preconnect_ = true; | 110 is_preconnect_ = true; |
| 106 HostPortPair destination(HostPortPair::FromURL(request_info.url)); | 111 HostPortPair destination(HostPortPair::FromURL(request_info.url)); |
| 107 GURL origin_url = ApplyHostMappingRules(request_info.url, &destination); | 112 GURL origin_url = ApplyHostMappingRules(request_info.url, &destination); |
| 108 | 113 |
| 109 const AlternativeService alternative_service = GetAlternativeServiceFor( | 114 const AlternativeService alternative_service = GetAlternativeServiceFor( |
| 110 request_info, nullptr, HttpStreamRequest::HTTP_STREAM); | 115 request_info, nullptr, HttpStreamRequest::HTTP_STREAM); |
| 111 | 116 |
| 112 if (alternative_service.protocol != kProtoUnknown) { | 117 if (alternative_service.protocol != kProtoUnknown) { |
| 113 if (session_->params().quic_disable_preconnect_if_0rtt && | 118 if (session_->params().quic_disable_preconnect_if_0rtt && |
| 114 alternative_service.protocol == kProtoQUIC && | 119 alternative_service.protocol == kProtoQUIC && |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 if (alternative_job_) { | 182 if (alternative_job_) { |
| 178 alternative_job_->SetPriority(priority); | 183 alternative_job_->SetPriority(priority); |
| 179 } | 184 } |
| 180 } | 185 } |
| 181 | 186 |
| 182 void HttpStreamFactoryImpl::JobController::OnStreamReady( | 187 void HttpStreamFactoryImpl::JobController::OnStreamReady( |
| 183 Job* job, | 188 Job* job, |
| 184 const SSLConfig& used_ssl_config) { | 189 const SSLConfig& used_ssl_config) { |
| 185 DCHECK(job); | 190 DCHECK(job); |
| 186 | 191 |
| 187 factory_->OnStreamReady(job->proxy_info()); | 192 factory_->OnStreamReady(job->proxy_info(), privacy_mode_); |
| 188 | 193 |
| 189 if (IsJobOrphaned(job)) { | 194 if (IsJobOrphaned(job)) { |
| 190 // We have bound a job to the associated Request, |job| has been orphaned. | 195 // We have bound a job to the associated Request, |job| has been orphaned. |
| 191 OnOrphanedJobComplete(job); | 196 OnOrphanedJobComplete(job); |
| 192 return; | 197 return; |
| 193 } | 198 } |
| 194 std::unique_ptr<HttpStream> stream = job->ReleaseStream(); | 199 std::unique_ptr<HttpStream> stream = job->ReleaseStream(); |
| 195 DCHECK(stream); | 200 DCHECK(stream); |
| 196 | 201 |
| 197 MarkRequestComplete(job->was_alpn_negotiated(), job->negotiated_protocol(), | 202 MarkRequestComplete(job->was_alpn_negotiated(), job->negotiated_protocol(), |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 373 if (!request_) | 378 if (!request_) |
| 374 return; | 379 return; |
| 375 if (!bound_job_) | 380 if (!bound_job_) |
| 376 BindJob(job); | 381 BindJob(job); |
| 377 request_->OnNeedsProxyAuth(proxy_response, used_ssl_config, used_proxy_info, | 382 request_->OnNeedsProxyAuth(proxy_response, used_ssl_config, used_proxy_info, |
| 378 auth_controller); | 383 auth_controller); |
| 379 } | 384 } |
| 380 | 385 |
| 381 bool HttpStreamFactoryImpl::JobController::OnInitConnection( | 386 bool HttpStreamFactoryImpl::JobController::OnInitConnection( |
| 382 const ProxyInfo& proxy_info) { | 387 const ProxyInfo& proxy_info) { |
| 383 return factory_->OnInitConnection(*this, proxy_info); | 388 return factory_->OnInitConnection(*this, proxy_info, privacy_mode_); |
| 384 } | 389 } |
| 385 | 390 |
| 386 void HttpStreamFactoryImpl::JobController::OnResolveProxyComplete( | 391 void HttpStreamFactoryImpl::JobController::OnResolveProxyComplete( |
| 387 Job* job, | 392 Job* job, |
| 388 const HttpRequestInfo& request_info, | 393 const HttpRequestInfo& request_info, |
| 389 RequestPriority priority, | 394 RequestPriority priority, |
| 390 const SSLConfig& server_ssl_config, | 395 const SSLConfig& server_ssl_config, |
| 391 const SSLConfig& proxy_ssl_config, | 396 const SSLConfig& proxy_ssl_config, |
| 392 HttpStreamRequest::StreamType stream_type) { | 397 HttpStreamRequest::StreamType stream_type) { |
| 393 DCHECK(job); | 398 DCHECK(job); |
| (...skipping 723 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1117 return; | 1122 return; |
| 1118 DCHECK(alternative_job_->alternative_proxy_server().is_valid()); | 1123 DCHECK(alternative_job_->alternative_proxy_server().is_valid()); |
| 1119 alternative_job_->Start(request_->stream_type()); | 1124 alternative_job_->Start(request_->stream_type()); |
| 1120 } | 1125 } |
| 1121 | 1126 |
| 1122 bool HttpStreamFactoryImpl::JobController::IsJobOrphaned(Job* job) const { | 1127 bool HttpStreamFactoryImpl::JobController::IsJobOrphaned(Job* job) const { |
| 1123 return !request_ || (job_bound_ && bound_job_ != job); | 1128 return !request_ || (job_bound_ && bound_job_ != job); |
| 1124 } | 1129 } |
| 1125 | 1130 |
| 1126 } // namespace net | 1131 } // namespace net |
| OLD | NEW |