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> |
| 8 #include <string> |
| 9 #include <utility> |
| 10 |
7 #include "base/metrics/histogram_macros.h" | 11 #include "base/metrics/histogram_macros.h" |
8 #include "base/strings/string_number_conversions.h" | 12 #include "base/strings/string_number_conversions.h" |
9 #include "base/strings/string_util.h" | 13 #include "base/strings/string_util.h" |
10 #include "base/values.h" | 14 #include "base/values.h" |
11 #include "net/base/host_mapping_rules.h" | 15 #include "net/base/host_mapping_rules.h" |
12 #include "net/base/proxy_delegate.h" | 16 #include "net/base/proxy_delegate.h" |
13 #include "net/http/bidirectional_stream_impl.h" | 17 #include "net/http/bidirectional_stream_impl.h" |
14 #include "net/http/transport_security_state.h" | 18 #include "net/http/transport_security_state.h" |
15 #include "net/log/net_log_event_type.h" | 19 #include "net/log/net_log_event_type.h" |
16 #include "net/proxy/proxy_server.h" | 20 #include "net/proxy/proxy_server.h" |
17 #include "net/spdy/spdy_session.h" | 21 #include "net/spdy/spdy_session.h" |
| 22 #include "url/url_constants.h" |
18 | 23 |
19 namespace net { | 24 namespace net { |
20 | 25 |
21 // Returns parameters associated with the delay of the HTTP stream job. | 26 // Returns parameters associated with the delay of the HTTP stream job. |
22 std::unique_ptr<base::Value> NetLogHttpStreamJobDelayCallback( | 27 std::unique_ptr<base::Value> NetLogHttpStreamJobDelayCallback( |
23 base::TimeDelta delay, | 28 base::TimeDelta delay, |
24 NetLogCaptureMode /* capture_mode */) { | 29 NetLogCaptureMode /* capture_mode */) { |
25 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); | 30 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); |
26 dict->SetInteger("resume_after_ms", static_cast<int>(delay.InMilliseconds())); | 31 dict->SetInteger("resume_after_ms", static_cast<int>(delay.InMilliseconds())); |
27 return std::move(dict); | 32 return std::move(dict); |
(...skipping 607 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
635 // Create an alternative job if alternative service is set up for this domain. | 640 // Create an alternative job if alternative service is set up for this domain. |
636 const AlternativeService alternative_service = | 641 const AlternativeService alternative_service = |
637 GetAlternativeServiceFor(request_info, delegate, stream_type); | 642 GetAlternativeServiceFor(request_info, delegate, stream_type); |
638 | 643 |
639 if (alternative_service.protocol != UNINITIALIZED_ALTERNATE_PROTOCOL) { | 644 if (alternative_service.protocol != UNINITIALIZED_ALTERNATE_PROTOCOL) { |
640 // Never share connection with other jobs for FTP requests. | 645 // Never share connection with other jobs for FTP requests. |
641 DVLOG(1) << "Selected alternative service (host: " | 646 DVLOG(1) << "Selected alternative service (host: " |
642 << alternative_service.host_port_pair().host() | 647 << alternative_service.host_port_pair().host() |
643 << " port: " << alternative_service.host_port_pair().port() << ")"; | 648 << " port: " << alternative_service.host_port_pair().port() << ")"; |
644 | 649 |
645 DCHECK(!request_info.url.SchemeIs("ftp")); | 650 DCHECK(!request_info.url.SchemeIs(url::kFtpScheme)); |
646 HostPortPair alternative_destination(alternative_service.host_port_pair()); | 651 HostPortPair alternative_destination(alternative_service.host_port_pair()); |
647 ignore_result( | 652 ignore_result( |
648 ApplyHostMappingRules(request_info.url, &alternative_destination)); | 653 ApplyHostMappingRules(request_info.url, &alternative_destination)); |
649 | 654 |
650 alternative_job_.reset(job_factory_->CreateJob( | 655 alternative_job_.reset(job_factory_->CreateJob( |
651 this, ALTERNATIVE, session_, request_info, priority, server_ssl_config, | 656 this, ALTERNATIVE, session_, request_info, priority, server_ssl_config, |
652 proxy_ssl_config, alternative_destination, origin_url, | 657 proxy_ssl_config, alternative_destination, origin_url, |
653 alternative_service, net_log.net_log())); | 658 alternative_service, net_log.net_log())); |
654 AttachJob(alternative_job_.get()); | 659 AttachJob(alternative_job_.get()); |
655 | 660 |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
870 return alternative_service; | 875 return alternative_service; |
871 } | 876 } |
872 | 877 |
873 AlternativeService | 878 AlternativeService |
874 HttpStreamFactoryImpl::JobController::GetAlternativeServiceForInternal( | 879 HttpStreamFactoryImpl::JobController::GetAlternativeServiceForInternal( |
875 const HttpRequestInfo& request_info, | 880 const HttpRequestInfo& request_info, |
876 HttpStreamRequest::Delegate* delegate, | 881 HttpStreamRequest::Delegate* delegate, |
877 HttpStreamRequest::StreamType stream_type) { | 882 HttpStreamRequest::StreamType stream_type) { |
878 GURL original_url = request_info.url; | 883 GURL original_url = request_info.url; |
879 | 884 |
880 if (!original_url.SchemeIs("https")) | 885 if (!original_url.SchemeIs(url::kHttpsScheme)) |
881 return AlternativeService(); | 886 return AlternativeService(); |
882 | 887 |
883 url::SchemeHostPort origin(original_url); | 888 url::SchemeHostPort origin(original_url); |
884 HttpServerProperties& http_server_properties = | 889 HttpServerProperties& http_server_properties = |
885 *session_->http_server_properties(); | 890 *session_->http_server_properties(); |
886 const AlternativeServiceVector alternative_service_vector = | 891 const AlternativeServiceVector alternative_service_vector = |
887 http_server_properties.GetAlternativeServices(origin); | 892 http_server_properties.GetAlternativeServices(origin); |
888 if (alternative_service_vector.empty()) | 893 if (alternative_service_vector.empty()) |
889 return AlternativeService(); | 894 return AlternativeService(); |
890 | 895 |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
948 continue; | 953 continue; |
949 | 954 |
950 if (stream_type == HttpStreamRequest::BIDIRECTIONAL_STREAM && | 955 if (stream_type == HttpStreamRequest::BIDIRECTIONAL_STREAM && |
951 session_->params().quic_disable_bidirectional_streams) { | 956 session_->params().quic_disable_bidirectional_streams) { |
952 continue; | 957 continue; |
953 } | 958 } |
954 | 959 |
955 if (session_->quic_stream_factory()->IsQuicDisabled()) | 960 if (session_->quic_stream_factory()->IsQuicDisabled()) |
956 continue; | 961 continue; |
957 | 962 |
958 if (!original_url.SchemeIs("https")) | 963 if (!original_url.SchemeIs(url::kHttpsScheme)) |
959 continue; | 964 continue; |
960 | 965 |
961 // Check whether there is an existing QUIC session to use for this origin. | 966 // Check whether there is an existing QUIC session to use for this origin. |
962 HostPortPair mapped_origin(origin.host(), origin.port()); | 967 HostPortPair mapped_origin(origin.host(), origin.port()); |
963 ignore_result(ApplyHostMappingRules(original_url, &mapped_origin)); | 968 ignore_result(ApplyHostMappingRules(original_url, &mapped_origin)); |
964 QuicServerId server_id(mapped_origin, request_info.privacy_mode); | 969 QuicServerId server_id(mapped_origin, request_info.privacy_mode); |
965 | 970 |
966 HostPortPair destination(alternative_service.host_port_pair()); | 971 HostPortPair destination(alternative_service.host_port_pair()); |
967 ignore_result(ApplyHostMappingRules(original_url, &destination)); | 972 ignore_result(ApplyHostMappingRules(original_url, &destination)); |
968 | 973 |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1084 } | 1089 } |
1085 | 1090 |
1086 void HttpStreamFactoryImpl::JobController::StartAlternativeProxyServerJob() { | 1091 void HttpStreamFactoryImpl::JobController::StartAlternativeProxyServerJob() { |
1087 if (!alternative_job_ || !request_) | 1092 if (!alternative_job_ || !request_) |
1088 return; | 1093 return; |
1089 DCHECK(alternative_job_->alternative_proxy_server().is_valid()); | 1094 DCHECK(alternative_job_->alternative_proxy_server().is_valid()); |
1090 alternative_job_->Start(request_->stream_type()); | 1095 alternative_job_->Start(request_->stream_type()); |
1091 } | 1096 } |
1092 | 1097 |
1093 } // namespace net | 1098 } // namespace net |
OLD | NEW |