| 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 728 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 739 // we've already got one available for a different hostname where the ip | 739 // we've already got one available for a different hostname where the ip |
| 740 // address matches up? | 740 // address matches up? |
| 741 CancelJobs(); | 741 CancelJobs(); |
| 742 return; | 742 return; |
| 743 } | 743 } |
| 744 | 744 |
| 745 if (job->job_type() == MAIN && alternative_job_failed_) | 745 if (job->job_type() == MAIN && alternative_job_failed_) |
| 746 ReportBrokenAlternativeService(); | 746 ReportBrokenAlternativeService(); |
| 747 | 747 |
| 748 if (!bound_job_) { | 748 if (!bound_job_) { |
| 749 if (main_job_ && alternative_job_) { | 749 if (main_job_ && alternative_job_) |
| 750 job->ReportJobSucceededForRequest(); | 750 ReportAlternateProtocolUsage(job); |
| 751 MaybeRecordAlternativeProxyServerUsage(job); | |
| 752 } | |
| 753 BindJob(job); | 751 BindJob(job); |
| 754 return; | 752 return; |
| 755 } | 753 } |
| 756 DCHECK(bound_job_); | 754 DCHECK(bound_job_); |
| 757 } | 755 } |
| 758 | 756 |
| 759 void HttpStreamFactoryImpl::JobController::MarkRequestComplete( | 757 void HttpStreamFactoryImpl::JobController::MarkRequestComplete( |
| 760 bool was_alpn_negotiated, | 758 bool was_alpn_negotiated, |
| 761 NextProto negotiated_protocol, | 759 NextProto negotiated_protocol, |
| 762 bool using_spdy) { | 760 bool using_spdy) { |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 899 // First Alt-Svc that is not marked as broken. | 897 // First Alt-Svc that is not marked as broken. |
| 900 AlternativeService first_alternative_service; | 898 AlternativeService first_alternative_service; |
| 901 | 899 |
| 902 for (const AlternativeService& alternative_service : | 900 for (const AlternativeService& alternative_service : |
| 903 alternative_service_vector) { | 901 alternative_service_vector) { |
| 904 DCHECK(IsAlternateProtocolValid(alternative_service.protocol)); | 902 DCHECK(IsAlternateProtocolValid(alternative_service.protocol)); |
| 905 if (!quic_advertised && alternative_service.protocol == QUIC) | 903 if (!quic_advertised && alternative_service.protocol == QUIC) |
| 906 quic_advertised = true; | 904 quic_advertised = true; |
| 907 if (http_server_properties.IsAlternativeServiceBroken( | 905 if (http_server_properties.IsAlternativeServiceBroken( |
| 908 alternative_service)) { | 906 alternative_service)) { |
| 909 HistogramAlternateProtocolUsage(ALTERNATE_PROTOCOL_USAGE_BROKEN); | 907 HistogramAlternateProtocolUsage(ALTERNATE_PROTOCOL_USAGE_BROKEN, false); |
| 910 continue; | 908 continue; |
| 911 } | 909 } |
| 912 | 910 |
| 913 | 911 |
| 914 // Some shared unix systems may have user home directories (like | 912 // Some shared unix systems may have user home directories (like |
| 915 // http://foo.com/~mike) which allow users to emit headers. This is a bad | 913 // http://foo.com/~mike) which allow users to emit headers. This is a bad |
| 916 // idea already, but with Alternate-Protocol, it provides the ability for a | 914 // idea already, but with Alternate-Protocol, it provides the ability for a |
| 917 // single user on a multi-user system to hijack the alternate protocol. | 915 // single user on a multi-user system to hijack the alternate protocol. |
| 918 // These systems also enforce ports <1024 as restricted ports. So don't | 916 // These systems also enforce ports <1024 as restricted ports. So don't |
| 919 // allow protocol upgrades to user-controllable ports. | 917 // allow protocol upgrades to user-controllable ports. |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1047 // Check that QUIC is enabled globally, and it is not disabled. | 1045 // Check that QUIC is enabled globally, and it is not disabled. |
| 1048 if (!session_->params().enable_quic || | 1046 if (!session_->params().enable_quic || |
| 1049 session_->quic_stream_factory()->IsQuicDisabled()) { | 1047 session_->quic_stream_factory()->IsQuicDisabled()) { |
| 1050 return false; | 1048 return false; |
| 1051 } | 1049 } |
| 1052 } | 1050 } |
| 1053 | 1051 |
| 1054 return true; | 1052 return true; |
| 1055 } | 1053 } |
| 1056 | 1054 |
| 1057 void HttpStreamFactoryImpl::JobController:: | 1055 void HttpStreamFactoryImpl::JobController::ReportAlternateProtocolUsage( |
| 1058 MaybeRecordAlternativeProxyServerUsage(Job* job) const { | 1056 Job* job) const { |
| 1059 if (is_preconnect_ || | 1057 DCHECK(main_job_ && alternative_job_); |
| 1060 !alternative_job_->alternative_proxy_server().is_quic()) { | 1058 |
| 1059 bool proxy_server_used = |
| 1060 alternative_job_->alternative_proxy_server().is_quic(); |
| 1061 |
| 1062 if (job == main_job_.get()) { |
| 1063 HistogramAlternateProtocolUsage(ALTERNATE_PROTOCOL_USAGE_LOST_RACE, |
| 1064 proxy_server_used); |
| 1061 return; | 1065 return; |
| 1062 } | 1066 } |
| 1063 DCHECK(main_job_.get() == job || alternative_job_.get() == job); | |
| 1064 | 1067 |
| 1065 enum AlternativeProxyUsage { | 1068 DCHECK_EQ(alternative_job_.get(), job); |
| 1066 ALTERNATIVE_PROXY_USAGE_NO_RACE = 0, | 1069 if (job->using_existing_quic_session()) { |
| 1067 ALTERNATIVE_PROXY_USAGE_WON_RACE, | 1070 HistogramAlternateProtocolUsage(ALTERNATE_PROTOCOL_USAGE_NO_RACE, |
| 1068 ALTERNATIVE_PROXY_USAGE_LOST_RACE, | 1071 proxy_server_used); |
| 1069 ALTERNATIVE_PROXY_USAGE_MAX, | 1072 return; |
| 1070 }; | 1073 } |
| 1071 AlternativeProxyUsage alternative_proxy_usage = ALTERNATIVE_PROXY_USAGE_MAX; | |
| 1072 | 1074 |
| 1073 if (alternative_job_->using_existing_quic_session()) { | 1075 HistogramAlternateProtocolUsage(ALTERNATE_PROTOCOL_USAGE_WON_RACE, |
| 1074 // If an existing session was used, then no TCP connection was | 1076 proxy_server_used); |
| 1075 // started. | |
| 1076 alternative_proxy_usage = ALTERNATIVE_PROXY_USAGE_NO_RACE; | |
| 1077 } else if (job->alternative_proxy_server().is_quic()) { | |
| 1078 // |job| was the alternative Job, and hence won the race. | |
| 1079 alternative_proxy_usage = ALTERNATIVE_PROXY_USAGE_WON_RACE; | |
| 1080 } else { | |
| 1081 // |job| was the normal Job, and hence the alternative Job lost the race. | |
| 1082 alternative_proxy_usage = ALTERNATIVE_PROXY_USAGE_LOST_RACE; | |
| 1083 } | |
| 1084 DCHECK_NE(ALTERNATIVE_PROXY_USAGE_MAX, alternative_proxy_usage); | |
| 1085 UMA_HISTOGRAM_ENUMERATION("Net.QuicAlternativeProxy.Usage", | |
| 1086 alternative_proxy_usage, | |
| 1087 ALTERNATIVE_PROXY_USAGE_MAX); | |
| 1088 } | 1077 } |
| 1089 | 1078 |
| 1090 void HttpStreamFactoryImpl::JobController::StartAlternativeProxyServerJob() { | 1079 void HttpStreamFactoryImpl::JobController::StartAlternativeProxyServerJob() { |
| 1091 if (!alternative_job_ || !request_) | 1080 if (!alternative_job_ || !request_) |
| 1092 return; | 1081 return; |
| 1093 DCHECK(alternative_job_->alternative_proxy_server().is_valid()); | 1082 DCHECK(alternative_job_->alternative_proxy_server().is_valid()); |
| 1094 alternative_job_->Start(request_->stream_type()); | 1083 alternative_job_->Start(request_->stream_type()); |
| 1095 } | 1084 } |
| 1096 | 1085 |
| 1097 } // namespace net | 1086 } // namespace net |
| OLD | NEW |