| 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 <string> | 7 #include <string> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| (...skipping 760 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 771 } | 771 } |
| 772 | 772 |
| 773 int HttpStreamFactoryImpl::JobController::DoCreateJobs() { | 773 int HttpStreamFactoryImpl::JobController::DoCreateJobs() { |
| 774 DCHECK(!main_job_); | 774 DCHECK(!main_job_); |
| 775 DCHECK(!alternative_job_); | 775 DCHECK(!alternative_job_); |
| 776 | 776 |
| 777 HostPortPair destination(HostPortPair::FromURL(request_info_.url)); | 777 HostPortPair destination(HostPortPair::FromURL(request_info_.url)); |
| 778 GURL origin_url = ApplyHostMappingRules(request_info_.url, &destination); | 778 GURL origin_url = ApplyHostMappingRules(request_info_.url, &destination); |
| 779 | 779 |
| 780 // Create an alternative job if alternative service is set up for this domain. | 780 // Create an alternative job if alternative service is set up for this domain. |
| 781 const AlternativeService alternative_service = | 781 const AlternativeServiceInfo alternative_service_info = |
| 782 GetAlternativeServiceInfoFor(request_info_, delegate_, stream_type_) | 782 GetAlternativeServiceInfoFor(request_info_, delegate_, stream_type_); |
| 783 .alternative_service; | |
| 784 | 783 |
| 785 if (is_preconnect_) { | 784 if (is_preconnect_) { |
| 786 // Due to how the socket pools handle priorities and idle sockets, only IDLE | 785 // Due to how the socket pools handle priorities and idle sockets, only IDLE |
| 787 // priority currently makes sense for preconnects. The priority for | 786 // priority currently makes sense for preconnects. The priority for |
| 788 // preconnects is currently ignored (see RequestSocketsForPool()), but could | 787 // preconnects is currently ignored (see RequestSocketsForPool()), but could |
| 789 // be used at some point for proxy resolution or something. | 788 // be used at some point for proxy resolution or something. |
| 790 main_job_ = job_factory_->CreateAltSvcJob( | 789 main_job_ = job_factory_->CreateAltSvcJob( |
| 791 this, PRECONNECT, session_, request_info_, IDLE, proxy_info_, | 790 this, PRECONNECT, session_, request_info_, IDLE, proxy_info_, |
| 792 server_ssl_config_, proxy_ssl_config_, destination, origin_url, | 791 server_ssl_config_, proxy_ssl_config_, destination, origin_url, |
| 793 alternative_service, enable_ip_based_pooling_, session_->net_log()); | 792 alternative_service_info, enable_ip_based_pooling_, |
| 793 session_->net_log()); |
| 794 main_job_->Preconnect(num_streams_); | 794 main_job_->Preconnect(num_streams_); |
| 795 return OK; | 795 return OK; |
| 796 } | 796 } |
| 797 main_job_ = job_factory_->CreateMainJob( | 797 main_job_ = job_factory_->CreateMainJob( |
| 798 this, MAIN, session_, request_info_, priority_, proxy_info_, | 798 this, MAIN, session_, request_info_, priority_, proxy_info_, |
| 799 server_ssl_config_, proxy_ssl_config_, destination, origin_url, | 799 server_ssl_config_, proxy_ssl_config_, destination, origin_url, |
| 800 enable_ip_based_pooling_, net_log_.net_log()); | 800 enable_ip_based_pooling_, net_log_.net_log()); |
| 801 // Alternative Service can only be set for HTTPS requests while Alternative | 801 // Alternative Service can only be set for HTTPS requests while Alternative |
| 802 // Proxy is set for HTTP requests. | 802 // Proxy is set for HTTP requests. |
| 803 if (alternative_service.protocol != kProtoUnknown) { | 803 if (alternative_service_info.alternative_service.protocol != kProtoUnknown) { |
| 804 // Never share connection with other jobs for FTP requests. | 804 // Never share connection with other jobs for FTP requests. |
| 805 DVLOG(1) << "Selected alternative service (host: " | 805 DVLOG(1) |
| 806 << alternative_service.host_port_pair().host() | 806 << "Selected alternative service (host: " |
| 807 << " port: " << alternative_service.host_port_pair().port() << ")"; | 807 << alternative_service_info.alternative_service.host_port_pair().host() |
| 808 << " port: " |
| 809 << alternative_service_info.alternative_service.host_port_pair().port() |
| 810 << ")"; |
| 808 | 811 |
| 809 DCHECK(!request_info_.url.SchemeIs(url::kFtpScheme)); | 812 DCHECK(!request_info_.url.SchemeIs(url::kFtpScheme)); |
| 810 HostPortPair alternative_destination(alternative_service.host_port_pair()); | 813 HostPortPair alternative_destination( |
| 814 alternative_service_info.alternative_service.host_port_pair()); |
| 811 ignore_result( | 815 ignore_result( |
| 812 ApplyHostMappingRules(request_info_.url, &alternative_destination)); | 816 ApplyHostMappingRules(request_info_.url, &alternative_destination)); |
| 813 | 817 |
| 814 alternative_job_ = job_factory_->CreateAltSvcJob( | 818 alternative_job_ = job_factory_->CreateAltSvcJob( |
| 815 this, ALTERNATIVE, session_, request_info_, priority_, proxy_info_, | 819 this, ALTERNATIVE, session_, request_info_, priority_, proxy_info_, |
| 816 server_ssl_config_, proxy_ssl_config_, alternative_destination, | 820 server_ssl_config_, proxy_ssl_config_, alternative_destination, |
| 817 origin_url, alternative_service, enable_ip_based_pooling_, | 821 origin_url, alternative_service_info, enable_ip_based_pooling_, |
| 818 net_log_.net_log()); | 822 net_log_.net_log()); |
| 819 | 823 |
| 820 main_job_is_blocked_ = true; | 824 main_job_is_blocked_ = true; |
| 821 alternative_job_->Start(request_->stream_type()); | 825 alternative_job_->Start(request_->stream_type()); |
| 822 } else { | 826 } else { |
| 823 ProxyServer alternative_proxy_server; | 827 ProxyServer alternative_proxy_server; |
| 824 if (ShouldCreateAlternativeProxyServerJob(proxy_info_, request_info_.url, | 828 if (ShouldCreateAlternativeProxyServerJob(proxy_info_, request_info_.url, |
| 825 &alternative_proxy_server)) { | 829 &alternative_proxy_server)) { |
| 826 DCHECK(!main_job_is_blocked_); | 830 DCHECK(!main_job_is_blocked_); |
| 827 ProxyInfo alternative_proxy_info; | 831 ProxyInfo alternative_proxy_info; |
| (...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1281 // If ReconsiderProxyAfterError() failed synchronously, it means | 1285 // If ReconsiderProxyAfterError() failed synchronously, it means |
| 1282 // there was nothing left to fall-back to, so fail the transaction | 1286 // there was nothing left to fall-back to, so fail the transaction |
| 1283 // with the last connection error we got. | 1287 // with the last connection error we got. |
| 1284 // TODO(eroman): This is a confusing contract, make it more obvious. | 1288 // TODO(eroman): This is a confusing contract, make it more obvious. |
| 1285 rv = error; | 1289 rv = error; |
| 1286 } | 1290 } |
| 1287 return rv; | 1291 return rv; |
| 1288 } | 1292 } |
| 1289 | 1293 |
| 1290 } // namespace net | 1294 } // namespace net |
| OLD | NEW |