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 756 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
767 | 767 |
768 // Create an alternative job if alternative service is set up for this domain. | 768 // Create an alternative job if alternative service is set up for this domain. |
769 const AlternativeService alternative_service = | 769 const AlternativeService alternative_service = |
770 GetAlternativeServiceFor(request_info_, delegate_, stream_type_); | 770 GetAlternativeServiceFor(request_info_, delegate_, stream_type_); |
771 | 771 |
772 if (is_preconnect_) { | 772 if (is_preconnect_) { |
773 // Due to how the socket pools handle priorities and idle sockets, only IDLE | 773 // Due to how the socket pools handle priorities and idle sockets, only IDLE |
774 // priority currently makes sense for preconnects. The priority for | 774 // priority currently makes sense for preconnects. The priority for |
775 // preconnects is currently ignored (see RequestSocketsForPool()), but could | 775 // preconnects is currently ignored (see RequestSocketsForPool()), but could |
776 // be used at some point for proxy resolution or something. | 776 // be used at some point for proxy resolution or something. |
777 main_job_.reset(job_factory_->CreateAltSvcJob( | 777 main_job_ = job_factory_->CreateAltSvcJob( |
778 this, PRECONNECT, session_, request_info_, IDLE, proxy_info_, | 778 this, PRECONNECT, session_, request_info_, IDLE, proxy_info_, |
779 server_ssl_config_, proxy_ssl_config_, destination, origin_url, | 779 server_ssl_config_, proxy_ssl_config_, destination, origin_url, |
780 alternative_service, enable_ip_based_pooling_, session_->net_log())); | 780 alternative_service, enable_ip_based_pooling_, session_->net_log()); |
781 main_job_->Preconnect(num_streams_); | 781 main_job_->Preconnect(num_streams_); |
782 return OK; | 782 return OK; |
783 } | 783 } |
784 main_job_.reset(job_factory_->CreateMainJob( | 784 main_job_ = job_factory_->CreateMainJob( |
785 this, MAIN, session_, request_info_, priority_, proxy_info_, | 785 this, MAIN, session_, request_info_, priority_, proxy_info_, |
786 server_ssl_config_, proxy_ssl_config_, destination, origin_url, | 786 server_ssl_config_, proxy_ssl_config_, destination, origin_url, |
787 enable_ip_based_pooling_, net_log_.net_log())); | 787 enable_ip_based_pooling_, net_log_.net_log()); |
788 // Alternative Service can only be set for HTTPS requests while Alternative | 788 // Alternative Service can only be set for HTTPS requests while Alternative |
789 // Proxy is set for HTTP requests. | 789 // Proxy is set for HTTP requests. |
790 if (alternative_service.protocol != kProtoUnknown) { | 790 if (alternative_service.protocol != kProtoUnknown) { |
791 // Never share connection with other jobs for FTP requests. | 791 // Never share connection with other jobs for FTP requests. |
792 DVLOG(1) << "Selected alternative service (host: " | 792 DVLOG(1) << "Selected alternative service (host: " |
793 << alternative_service.host_port_pair().host() | 793 << alternative_service.host_port_pair().host() |
794 << " port: " << alternative_service.host_port_pair().port() << ")"; | 794 << " port: " << alternative_service.host_port_pair().port() << ")"; |
795 | 795 |
796 DCHECK(!request_info_.url.SchemeIs(url::kFtpScheme)); | 796 DCHECK(!request_info_.url.SchemeIs(url::kFtpScheme)); |
797 HostPortPair alternative_destination(alternative_service.host_port_pair()); | 797 HostPortPair alternative_destination(alternative_service.host_port_pair()); |
798 ignore_result( | 798 ignore_result( |
799 ApplyHostMappingRules(request_info_.url, &alternative_destination)); | 799 ApplyHostMappingRules(request_info_.url, &alternative_destination)); |
800 | 800 |
801 alternative_job_.reset(job_factory_->CreateAltSvcJob( | 801 alternative_job_ = job_factory_->CreateAltSvcJob( |
802 this, ALTERNATIVE, session_, request_info_, priority_, proxy_info_, | 802 this, ALTERNATIVE, session_, request_info_, priority_, proxy_info_, |
803 server_ssl_config_, proxy_ssl_config_, alternative_destination, | 803 server_ssl_config_, proxy_ssl_config_, alternative_destination, |
804 origin_url, alternative_service, enable_ip_based_pooling_, | 804 origin_url, alternative_service, enable_ip_based_pooling_, |
805 net_log_.net_log())); | 805 net_log_.net_log()); |
806 | 806 |
807 main_job_is_blocked_ = true; | 807 main_job_is_blocked_ = true; |
808 alternative_job_->Start(request_->stream_type()); | 808 alternative_job_->Start(request_->stream_type()); |
809 } else { | 809 } else { |
810 ProxyServer alternative_proxy_server; | 810 ProxyServer alternative_proxy_server; |
811 if (ShouldCreateAlternativeProxyServerJob(proxy_info_, request_info_.url, | 811 if (ShouldCreateAlternativeProxyServerJob(proxy_info_, request_info_.url, |
812 &alternative_proxy_server)) { | 812 &alternative_proxy_server)) { |
813 DCHECK(!main_job_is_blocked_); | 813 DCHECK(!main_job_is_blocked_); |
814 ProxyInfo alternative_proxy_info; | 814 ProxyInfo alternative_proxy_info; |
815 alternative_proxy_info.UseProxyServer(alternative_proxy_server); | 815 alternative_proxy_info.UseProxyServer(alternative_proxy_server); |
816 | 816 |
817 alternative_job_.reset(job_factory_->CreateAltProxyJob( | 817 alternative_job_ = job_factory_->CreateAltProxyJob( |
818 this, ALTERNATIVE, session_, request_info_, priority_, | 818 this, ALTERNATIVE, session_, request_info_, priority_, |
819 alternative_proxy_info, server_ssl_config_, proxy_ssl_config_, | 819 alternative_proxy_info, server_ssl_config_, proxy_ssl_config_, |
820 destination, origin_url, alternative_proxy_server, | 820 destination, origin_url, alternative_proxy_server, |
821 enable_ip_based_pooling_, net_log_.net_log())); | 821 enable_ip_based_pooling_, net_log_.net_log()); |
822 | 822 |
823 can_start_alternative_proxy_job_ = false; | 823 can_start_alternative_proxy_job_ = false; |
824 main_job_is_blocked_ = true; | 824 main_job_is_blocked_ = true; |
825 alternative_job_->Start(request_->stream_type()); | 825 alternative_job_->Start(request_->stream_type()); |
826 } | 826 } |
827 } | 827 } |
828 // Even if |alternative_job| has already finished, it will not have notified | 828 // Even if |alternative_job| has already finished, it will not have notified |
829 // the request yet, since we defer that to the next iteration of the | 829 // the request yet, since we defer that to the next iteration of the |
830 // MessageLoop, so starting |main_job_| is always safe. | 830 // MessageLoop, so starting |main_job_| is always safe. |
831 main_job_->Start(request_->stream_type()); | 831 main_job_->Start(request_->stream_type()); |
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1256 // If ReconsiderProxyAfterError() failed synchronously, it means | 1256 // If ReconsiderProxyAfterError() failed synchronously, it means |
1257 // there was nothing left to fall-back to, so fail the transaction | 1257 // there was nothing left to fall-back to, so fail the transaction |
1258 // with the last connection error we got. | 1258 // with the last connection error we got. |
1259 // TODO(eroman): This is a confusing contract, make it more obvious. | 1259 // TODO(eroman): This is a confusing contract, make it more obvious. |
1260 rv = error; | 1260 rv = error; |
1261 } | 1261 } |
1262 return rv; | 1262 return rv; |
1263 } | 1263 } |
1264 | 1264 |
1265 } // namespace net | 1265 } // namespace net |
OLD | NEW |