| 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 session_(session), | 45 session_(session), |
| 46 job_factory_(job_factory), | 46 job_factory_(job_factory), |
| 47 request_(nullptr), | 47 request_(nullptr), |
| 48 delegate_(delegate), | 48 delegate_(delegate), |
| 49 is_preconnect_(false), | 49 is_preconnect_(false), |
| 50 alternative_job_failed_(false), | 50 alternative_job_failed_(false), |
| 51 job_bound_(false), | 51 job_bound_(false), |
| 52 main_job_is_blocked_(false), | 52 main_job_is_blocked_(false), |
| 53 bound_job_(nullptr), | 53 bound_job_(nullptr), |
| 54 can_start_alternative_proxy_job_(false), | 54 can_start_alternative_proxy_job_(false), |
| 55 privacy_mode_(PRIVACY_MODE_DISABLED), |
| 55 ptr_factory_(this) { | 56 ptr_factory_(this) { |
| 56 DCHECK(factory); | 57 DCHECK(factory); |
| 57 } | 58 } |
| 58 | 59 |
| 59 HttpStreamFactoryImpl::JobController::~JobController() { | 60 HttpStreamFactoryImpl::JobController::~JobController() { |
| 60 main_job_.reset(); | 61 main_job_.reset(); |
| 61 alternative_job_.reset(); | 62 alternative_job_.reset(); |
| 62 bound_job_ = nullptr; | 63 bound_job_ = nullptr; |
| 63 } | 64 } |
| 64 | 65 |
| 65 bool HttpStreamFactoryImpl::JobController::for_websockets() { | 66 bool HttpStreamFactoryImpl::JobController::for_websockets() { |
| 66 return factory_->for_websockets_; | 67 return factory_->for_websockets_; |
| 67 } | 68 } |
| 68 | 69 |
| 69 HttpStreamFactoryImpl::Request* HttpStreamFactoryImpl::JobController::Start( | 70 HttpStreamFactoryImpl::Request* HttpStreamFactoryImpl::JobController::Start( |
| 70 const HttpRequestInfo& request_info, | 71 const HttpRequestInfo& request_info, |
| 71 HttpStreamRequest::Delegate* delegate, | 72 HttpStreamRequest::Delegate* delegate, |
| 72 WebSocketHandshakeStreamBase::CreateHelper* | 73 WebSocketHandshakeStreamBase::CreateHelper* |
| 73 websocket_handshake_stream_create_helper, | 74 websocket_handshake_stream_create_helper, |
| 74 const NetLogWithSource& net_log, | 75 const NetLogWithSource& net_log, |
| 75 HttpStreamRequest::StreamType stream_type, | 76 HttpStreamRequest::StreamType stream_type, |
| 76 RequestPriority priority, | 77 RequestPriority priority, |
| 77 const SSLConfig& server_ssl_config, | 78 const SSLConfig& server_ssl_config, |
| 78 const SSLConfig& proxy_ssl_config) { | 79 const SSLConfig& proxy_ssl_config) { |
| 79 DCHECK(factory_); | 80 DCHECK(factory_); |
| 80 DCHECK(!request_); | 81 DCHECK(!request_); |
| 81 | 82 |
| 83 privacy_mode_ = request_info.privacy_mode; |
| 84 |
| 82 request_ = new Request(request_info.url, this, delegate, | 85 request_ = new Request(request_info.url, this, delegate, |
| 83 websocket_handshake_stream_create_helper, net_log, | 86 websocket_handshake_stream_create_helper, net_log, |
| 84 stream_type); | 87 stream_type); |
| 85 | 88 |
| 86 CreateJobs(request_info, priority, server_ssl_config, proxy_ssl_config, | 89 CreateJobs(request_info, priority, server_ssl_config, proxy_ssl_config, |
| 87 delegate, stream_type, net_log); | 90 delegate, stream_type, net_log); |
| 88 | 91 |
| 89 return request_; | 92 return request_; |
| 90 } | 93 } |
| 91 | 94 |
| 92 void HttpStreamFactoryImpl::JobController::Preconnect( | 95 void HttpStreamFactoryImpl::JobController::Preconnect( |
| 93 int num_streams, | 96 int num_streams, |
| 94 const HttpRequestInfo& request_info, | 97 const HttpRequestInfo& request_info, |
| 95 const SSLConfig& server_ssl_config, | 98 const SSLConfig& server_ssl_config, |
| 96 const SSLConfig& proxy_ssl_config) { | 99 const SSLConfig& proxy_ssl_config) { |
| 97 DCHECK(!main_job_); | 100 DCHECK(!main_job_); |
| 98 DCHECK(!alternative_job_); | 101 DCHECK(!alternative_job_); |
| 99 | 102 |
| 103 privacy_mode_ = request_info.privacy_mode; |
| 104 |
| 100 is_preconnect_ = true; | 105 is_preconnect_ = true; |
| 101 HostPortPair destination(HostPortPair::FromURL(request_info.url)); | 106 HostPortPair destination(HostPortPair::FromURL(request_info.url)); |
| 102 GURL origin_url = ApplyHostMappingRules(request_info.url, &destination); | 107 GURL origin_url = ApplyHostMappingRules(request_info.url, &destination); |
| 103 | 108 |
| 104 const AlternativeService alternative_service = GetAlternativeServiceFor( | 109 const AlternativeService alternative_service = GetAlternativeServiceFor( |
| 105 request_info, nullptr, HttpStreamRequest::HTTP_STREAM); | 110 request_info, nullptr, HttpStreamRequest::HTTP_STREAM); |
| 106 | 111 |
| 107 if (alternative_service.protocol != kProtoUnknown) { | 112 if (alternative_service.protocol != kProtoUnknown) { |
| 108 if (session_->params().quic_disable_preconnect_if_0rtt && | 113 if (session_->params().quic_disable_preconnect_if_0rtt && |
| 109 alternative_service.protocol == kProtoQUIC && | 114 alternative_service.protocol == kProtoQUIC && |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 if (alternative_job_) { | 184 if (alternative_job_) { |
| 180 alternative_job_->SetPriority(priority); | 185 alternative_job_->SetPriority(priority); |
| 181 } | 186 } |
| 182 } | 187 } |
| 183 | 188 |
| 184 void HttpStreamFactoryImpl::JobController::OnStreamReady( | 189 void HttpStreamFactoryImpl::JobController::OnStreamReady( |
| 185 Job* job, | 190 Job* job, |
| 186 const SSLConfig& used_ssl_config) { | 191 const SSLConfig& used_ssl_config) { |
| 187 DCHECK(job); | 192 DCHECK(job); |
| 188 | 193 |
| 189 factory_->OnStreamReady(job->proxy_info()); | 194 factory_->OnStreamReady(job->proxy_info(), privacy_mode_); |
| 190 | 195 |
| 191 if (IsJobOrphaned(job)) { | 196 if (IsJobOrphaned(job)) { |
| 192 // We have bound a job to the associated Request, |job| has been orphaned. | 197 // We have bound a job to the associated Request, |job| has been orphaned. |
| 193 OnOrphanedJobComplete(job); | 198 OnOrphanedJobComplete(job); |
| 194 return; | 199 return; |
| 195 } | 200 } |
| 196 std::unique_ptr<HttpStream> stream = job->ReleaseStream(); | 201 std::unique_ptr<HttpStream> stream = job->ReleaseStream(); |
| 197 DCHECK(stream); | 202 DCHECK(stream); |
| 198 | 203 |
| 199 MarkRequestComplete(job->was_alpn_negotiated(), job->negotiated_protocol(), | 204 MarkRequestComplete(job->was_alpn_negotiated(), job->negotiated_protocol(), |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 375 if (!request_) | 380 if (!request_) |
| 376 return; | 381 return; |
| 377 if (!bound_job_) | 382 if (!bound_job_) |
| 378 BindJob(job); | 383 BindJob(job); |
| 379 request_->OnNeedsProxyAuth(proxy_response, used_ssl_config, used_proxy_info, | 384 request_->OnNeedsProxyAuth(proxy_response, used_ssl_config, used_proxy_info, |
| 380 auth_controller); | 385 auth_controller); |
| 381 } | 386 } |
| 382 | 387 |
| 383 bool HttpStreamFactoryImpl::JobController::OnInitConnection( | 388 bool HttpStreamFactoryImpl::JobController::OnInitConnection( |
| 384 const ProxyInfo& proxy_info) { | 389 const ProxyInfo& proxy_info) { |
| 385 return factory_->OnInitConnection(*this, proxy_info); | 390 return factory_->OnInitConnection(*this, proxy_info, privacy_mode_); |
| 386 } | 391 } |
| 387 | 392 |
| 388 void HttpStreamFactoryImpl::JobController::OnResolveProxyComplete( | 393 void HttpStreamFactoryImpl::JobController::OnResolveProxyComplete( |
| 389 Job* job, | 394 Job* job, |
| 390 const HttpRequestInfo& request_info, | 395 const HttpRequestInfo& request_info, |
| 391 RequestPriority priority, | 396 RequestPriority priority, |
| 392 const SSLConfig& server_ssl_config, | 397 const SSLConfig& server_ssl_config, |
| 393 const SSLConfig& proxy_ssl_config, | 398 const SSLConfig& proxy_ssl_config, |
| 394 HttpStreamRequest::StreamType stream_type) { | 399 HttpStreamRequest::StreamType stream_type) { |
| 395 DCHECK(job); | 400 DCHECK(job); |
| (...skipping 698 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1094 return; | 1099 return; |
| 1095 DCHECK(alternative_job_->alternative_proxy_server().is_valid()); | 1100 DCHECK(alternative_job_->alternative_proxy_server().is_valid()); |
| 1096 alternative_job_->Start(request_->stream_type()); | 1101 alternative_job_->Start(request_->stream_type()); |
| 1097 } | 1102 } |
| 1098 | 1103 |
| 1099 bool HttpStreamFactoryImpl::JobController::IsJobOrphaned(Job* job) const { | 1104 bool HttpStreamFactoryImpl::JobController::IsJobOrphaned(Job* job) const { |
| 1100 return !request_ || (job_bound_ && bound_job_ != job); | 1105 return !request_ || (job_bound_ && bound_job_ != job); |
| 1101 } | 1106 } |
| 1102 | 1107 |
| 1103 } // namespace net | 1108 } // namespace net |
| OLD | NEW |