Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(66)

Side by Side Diff: net/http/http_stream_factory_impl_job_controller.cc

Issue 2359803003: Job Controller: clean up metrics logging about the job racing result (Closed)
Patch Set: Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "base/metrics/histogram_macros.h" 7 #include "base/metrics/histogram_macros.h"
8 #include "base/strings/string_number_conversions.h" 8 #include "base/strings/string_number_conversions.h"
9 #include "base/strings/string_util.h" 9 #include "base/strings/string_util.h"
10 #include "base/values.h" 10 #include "base/values.h"
(...skipping 723 matching lines...) Expand 10 before | Expand all | Expand 10 after
734 // we've already got one available for a different hostname where the ip 734 // we've already got one available for a different hostname where the ip
735 // address matches up? 735 // address matches up?
736 CancelJobs(); 736 CancelJobs();
737 return; 737 return;
738 } 738 }
739 739
740 if (job->job_type() == MAIN && alternative_job_failed_) 740 if (job->job_type() == MAIN && alternative_job_failed_)
741 ReportBrokenAlternativeService(); 741 ReportBrokenAlternativeService();
742 742
743 if (!bound_job_) { 743 if (!bound_job_) {
744 if (main_job_ && alternative_job_) { 744 if (main_job_ && alternative_job_)
745 job->ReportJobSucceededForRequest(); 745 ReportAlternateProtocolUsage(job);
746 MaybeRecordAlternativeProxyServerUsage(job);
747 }
748 BindJob(job); 746 BindJob(job);
749 return; 747 return;
750 } 748 }
751 DCHECK(bound_job_); 749 DCHECK(bound_job_);
752 } 750 }
753 751
754 void HttpStreamFactoryImpl::JobController::MarkRequestComplete( 752 void HttpStreamFactoryImpl::JobController::MarkRequestComplete(
755 bool was_npn_negotiated, 753 bool was_npn_negotiated,
756 NextProto negotiated_protocol, 754 NextProto negotiated_protocol,
757 bool using_spdy) { 755 bool using_spdy) {
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
894 // First Alt-Svc that is not marked as broken. 892 // First Alt-Svc that is not marked as broken.
895 AlternativeService first_alternative_service; 893 AlternativeService first_alternative_service;
896 894
897 for (const AlternativeService& alternative_service : 895 for (const AlternativeService& alternative_service :
898 alternative_service_vector) { 896 alternative_service_vector) {
899 DCHECK(IsAlternateProtocolValid(alternative_service.protocol)); 897 DCHECK(IsAlternateProtocolValid(alternative_service.protocol));
900 if (!quic_advertised && alternative_service.protocol == QUIC) 898 if (!quic_advertised && alternative_service.protocol == QUIC)
901 quic_advertised = true; 899 quic_advertised = true;
902 if (http_server_properties.IsAlternativeServiceBroken( 900 if (http_server_properties.IsAlternativeServiceBroken(
903 alternative_service)) { 901 alternative_service)) {
904 HistogramAlternateProtocolUsage(ALTERNATE_PROTOCOL_USAGE_BROKEN); 902 HistogramAlternateProtocolUsage(ALTERNATE_PROTOCOL_USAGE_BROKEN, false);
905 continue; 903 continue;
906 } 904 }
907 905
908 906
909 // Some shared unix systems may have user home directories (like 907 // Some shared unix systems may have user home directories (like
910 // http://foo.com/~mike) which allow users to emit headers. This is a bad 908 // http://foo.com/~mike) which allow users to emit headers. This is a bad
911 // idea already, but with Alternate-Protocol, it provides the ability for a 909 // idea already, but with Alternate-Protocol, it provides the ability for a
912 // single user on a multi-user system to hijack the alternate protocol. 910 // single user on a multi-user system to hijack the alternate protocol.
913 // These systems also enforce ports <1024 as restricted ports. So don't 911 // These systems also enforce ports <1024 as restricted ports. So don't
914 // allow protocol upgrades to user-controllable ports. 912 // allow protocol upgrades to user-controllable ports.
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
1043 // Check that QUIC is enabled globally, and it is not disabled. 1041 // Check that QUIC is enabled globally, and it is not disabled.
1044 if (!session_->params().enable_quic || 1042 if (!session_->params().enable_quic ||
1045 session_->quic_stream_factory()->IsQuicDisabled()) { 1043 session_->quic_stream_factory()->IsQuicDisabled()) {
1046 return false; 1044 return false;
1047 } 1045 }
1048 } 1046 }
1049 1047
1050 return true; 1048 return true;
1051 } 1049 }
1052 1050
1053 void HttpStreamFactoryImpl::JobController:: 1051 void HttpStreamFactoryImpl::JobController::ReportAlternateProtocolUsage(
1054 MaybeRecordAlternativeProxyServerUsage(Job* job) const { 1052 Job* job) const {
1055 if (is_preconnect_ || 1053 DCHECK(main_job_ && alternative_job_);
tbansal1 2016/09/22 17:53:02 Curious why use a weaker DCHECK? Is it possible th
Zhongyi Shi 2016/09/22 23:56:53 The new DCHECK was to make sure both jobs are aliv
tbansal1 2016/09/23 00:02:07 Acknowledged.
1056 !alternative_job_->alternative_proxy_server().is_quic()) { 1054 bool proxy_server_used =
1057 return; 1055 alternative_job_->alternative_proxy_server().is_quic();
1056
1057 if (job == alternative_job_.get()) {
1058 if (job->using_existing_quic_session()) {
1059 HistogramAlternateProtocolUsage(ALTERNATE_PROTOCOL_USAGE_NO_RACE,
1060 proxy_server_used);
1061 } else {
1062 HistogramAlternateProtocolUsage(ALTERNATE_PROTOCOL_USAGE_WON_RACE,
1063 proxy_server_used);
1064 }
1065 } else {
1066 DCHECK_EQ(main_job_.get(), job);
1067 HistogramAlternateProtocolUsage(ALTERNATE_PROTOCOL_USAGE_LOST_RACE,
1068 proxy_server_used);
1058 } 1069 }
Ryan Hamilton 2016/09/22 21:46:33 nit: I think we can use some early returns: if (j
Zhongyi Shi 2016/09/22 23:56:53 Done.
1059 DCHECK(main_job_.get() == job || alternative_job_.get() == job);
1060
1061 enum AlternativeProxyUsage {
1062 ALTERNATIVE_PROXY_USAGE_NO_RACE = 0,
1063 ALTERNATIVE_PROXY_USAGE_WON_RACE,
1064 ALTERNATIVE_PROXY_USAGE_LOST_RACE,
1065 ALTERNATIVE_PROXY_USAGE_MAX,
1066 };
1067 AlternativeProxyUsage alternative_proxy_usage = ALTERNATIVE_PROXY_USAGE_MAX;
1068
1069 if (alternative_job_->using_existing_quic_session()) {
1070 // If an existing session was used, then no TCP connection was
1071 // started.
1072 alternative_proxy_usage = ALTERNATIVE_PROXY_USAGE_NO_RACE;
1073 } else if (job->alternative_proxy_server().is_quic()) {
1074 // |job| was the alternative Job, and hence won the race.
1075 alternative_proxy_usage = ALTERNATIVE_PROXY_USAGE_WON_RACE;
1076 } else {
1077 // |job| was the normal Job, and hence the alternative Job lost the race.
1078 alternative_proxy_usage = ALTERNATIVE_PROXY_USAGE_LOST_RACE;
1079 }
1080 DCHECK_NE(ALTERNATIVE_PROXY_USAGE_MAX, alternative_proxy_usage);
1081 UMA_HISTOGRAM_ENUMERATION("Net.QuicAlternativeProxy.Usage",
1082 alternative_proxy_usage,
1083 ALTERNATIVE_PROXY_USAGE_MAX);
1084 } 1070 }
1085 1071
1086 void HttpStreamFactoryImpl::JobController::StartAlternativeProxyServerJob() { 1072 void HttpStreamFactoryImpl::JobController::StartAlternativeProxyServerJob() {
1087 if (!alternative_job_ || !request_) 1073 if (!alternative_job_ || !request_)
1088 return; 1074 return;
1089 DCHECK(alternative_job_->alternative_proxy_server().is_valid()); 1075 DCHECK(alternative_job_->alternative_proxy_server().is_valid());
1090 alternative_job_->Start(request_->stream_type()); 1076 alternative_job_->Start(request_->stream_type());
1091 } 1077 }
1092 1078
1093 } // namespace net 1079 } // namespace net
OLDNEW
« net/http/http_server_properties.cc ('K') | « net/http/http_stream_factory_impl_job_controller.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698