diff options
author | rch@chromium.org <rch@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-04-11 18:51:39 +0000 |
---|---|---|
committer | rch@chromium.org <rch@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-04-11 18:51:39 +0000 |
commit | db9bfea233d3a329490b28686d78d2beae5b7c46 (patch) | |
tree | ca7802e9564ed12f4dfdd78955f9b1192ac4a13f | |
parent | 5ff0f8c418cb68c74e1060d3c0a90cad46846028 (diff) | |
download | chromium_src-db9bfea233d3a329490b28686d78d2beae5b7c46.zip chromium_src-db9bfea233d3a329490b28686d78d2beae5b7c46.tar.gz chromium_src-db9bfea233d3a329490b28686d78d2beae5b7c46.tar.bz2 |
Add a new Net.AlternateProtocolUsage for tracking usage of Alternate-Protocol.
BUG=
Review URL: https://codereview.chromium.org/232193002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@263298 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | net/http/http_server_properties.cc | 6 | ||||
-rw-r--r-- | net/http/http_server_properties.h | 20 | ||||
-rw-r--r-- | net/http/http_server_properties_impl.cc | 5 | ||||
-rw-r--r-- | net/http/http_stream_factory_impl.cc | 4 | ||||
-rw-r--r-- | net/http/http_stream_factory_impl_job.cc | 20 | ||||
-rw-r--r-- | net/http/http_stream_factory_impl_job.h | 7 | ||||
-rw-r--r-- | net/http/http_stream_factory_impl_request.cc | 10 | ||||
-rw-r--r-- | tools/metrics/histograms/histograms.xml | 16 |
8 files changed, 83 insertions, 5 deletions
diff --git a/net/http/http_server_properties.cc b/net/http/http_server_properties.cc index a10d506..e714d9f 100644 --- a/net/http/http_server_properties.cc +++ b/net/http/http_server_properties.cc @@ -5,6 +5,7 @@ #include "net/http/http_server_properties.h" #include "base/logging.h" +#include "base/metrics/histogram.h" #include "base/strings/stringprintf.h" namespace net { @@ -31,6 +32,11 @@ COMPILE_ASSERT( } // namespace +void HistogramAlternateProtocolUsage(AlternateProtocolUsage usage) { + UMA_HISTOGRAM_ENUMERATION("Net.AlternateProtocolUsage", usage, + ALTERNATE_PROTOCOL_USAGE_MAX); +} + bool IsAlternateProtocolValid(AlternateProtocol protocol) { return protocol >= ALTERNATE_PROTOCOL_MINIMUM_VALID_VERSION && protocol <= ALTERNATE_PROTOCOL_MAXIMUM_VALID_VERSION; diff --git a/net/http/http_server_properties.h b/net/http/http_server_properties.h index b988e9f..3d12d02 100644 --- a/net/http/http_server_properties.h +++ b/net/http/http_server_properties.h @@ -19,6 +19,26 @@ namespace net { +enum AlternateProtocolUsage { + // Alternate Protocol was used without racing a normal connection. + ALTERNATE_PROTOCOL_USAGE_NO_RACE = 0, + // Alternate Protocol was used by winning a race with a normal connection. + ALTERNATE_PROTOCOL_USAGE_WON_RACE = 1, + // Alternate Protocol was not used by losing a race with a normal connection. + ALTERNATE_PROTOCOL_USAGE_LOST_RACE = 2, + // Alternate Protocol was not used because no Alternate-Protocol information + // was available when the request was issued, but an Alternate-Protocol header + // was present in the response. + ALTERNATE_PROTOCOL_USAGE_MAPPING_MISSING = 3, + // Alternate Protocol was not used because it was marked broken. + ALTERNATE_PROTOCOL_USAGE_BROKEN = 4, + // Maximum value for the enum. + ALTERNATE_PROTOCOL_USAGE_MAX, +}; + +// Log a histogram to reflect |usage|. +NET_EXPORT void HistogramAlternateProtocolUsage(AlternateProtocolUsage usage); + enum AlternateProtocol { DEPRECATED_NPN_SPDY_2 = 0, ALTERNATE_PROTOCOL_MINIMUM_VALID_VERSION = DEPRECATED_NPN_SPDY_2, diff --git a/net/http/http_server_properties_impl.cc b/net/http/http_server_properties_impl.cc index 7fb4205..4550427 100644 --- a/net/http/http_server_properties_impl.cc +++ b/net/http/http_server_properties_impl.cc @@ -258,6 +258,11 @@ void HttpServerPropertiesImpl::SetAlternateProtocol( << ", Protocol: " << alternate_protocol << "]."; } + } else { + // TODO(rch): Consider the case where multiple requests are started + // before the first completes. In this case, only one of the jobs + // would reach this code, whereas all of them should should have. + HistogramAlternateProtocolUsage(ALTERNATE_PROTOCOL_USAGE_MAPPING_MISSING); } alternate_protocol_map_.Put(server, alternate); diff --git a/net/http/http_stream_factory_impl.cc b/net/http/http_stream_factory_impl.cc index 991e469..7500373 100644 --- a/net/http/http_stream_factory_impl.cc +++ b/net/http/http_stream_factory_impl.cc @@ -206,8 +206,10 @@ PortAlternateProtocolPair HttpStreamFactoryImpl::GetAlternateProtocolRequestFor( PortAlternateProtocolPair alternate = http_server_properties.GetAlternateProtocol(origin); - if (alternate.protocol == ALTERNATE_PROTOCOL_BROKEN) + if (alternate.protocol == ALTERNATE_PROTOCOL_BROKEN) { + HistogramAlternateProtocolUsage(ALTERNATE_PROTOCOL_USAGE_BROKEN); return kNoAlternateProtocol; + } if (!IsAlternateProtocolValid(alternate.protocol)) { NOTREACHED(); diff --git a/net/http/http_stream_factory_impl_job.cc b/net/http/http_stream_factory_impl_job.cc index 9feb3b7..7a8a52e 100644 --- a/net/http/http_stream_factory_impl_job.cc +++ b/net/http/http_stream_factory_impl_job.cc @@ -98,6 +98,7 @@ HttpStreamFactoryImpl::Job::Job(HttpStreamFactoryImpl* stream_factory, using_spdy_(false), using_quic_(false), quic_request_(session_->quic_stream_factory()), + using_existing_quic_session_(false), force_spdy_always_(HttpStreamFactory::force_spdy_always()), force_spdy_over_ssl_(HttpStreamFactory::force_spdy_over_ssl()), spdy_certificate_error_(OK), @@ -750,7 +751,9 @@ int HttpStreamFactoryImpl::Job::DoInitConnection() { int rv = quic_request_.Request( destination, secure_quic, request_info_.privacy_mode, request_info_.method, net_log_, io_callback_); - if (rv != OK) { + if (rv == OK) { + using_existing_quic_session_ = true; + } else { // OK, there's no available QUIC session. Let |waiting_job_| resume // if it's paused. if (waiting_job_) { @@ -1447,6 +1450,21 @@ bool HttpStreamFactoryImpl::Job::IsOrphaned() const { return !IsPreconnecting() && !request_; } +void HttpStreamFactoryImpl::Job::ReportJobSuccededForRequest() { + if (using_existing_quic_session_) { + // If an existing session was used, then no TCP connection was + // started. + HistogramAlternateProtocolUsage(ALTERNATE_PROTOCOL_USAGE_NO_RACE); + } else if (original_url_) { + // This job was the alternate protocol job, and hence won the race. + HistogramAlternateProtocolUsage(ALTERNATE_PROTOCOL_USAGE_WON_RACE); + } else { + // This job was the normal job, and hence the alternate protocol job lost + // the race. + HistogramAlternateProtocolUsage(ALTERNATE_PROTOCOL_USAGE_LOST_RACE); + } +} + bool HttpStreamFactoryImpl::Job::IsRequestEligibleForPipelining() { if (IsPreconnecting() || !request_) { return false; diff --git a/net/http/http_stream_factory_impl_job.h b/net/http/http_stream_factory_impl_job.h index 1970b5b..d440647 100644 --- a/net/http/http_stream_factory_impl_job.h +++ b/net/http/http_stream_factory_impl_job.h @@ -92,6 +92,10 @@ class HttpStreamFactoryImpl::Job { // Indicates whether or not this Job has been orphaned by a Request. bool IsOrphaned() const; + // Called to indicate that this job succeeded, and some other jobs + // will be orphaned. + void ReportJobSuccededForRequest(); + private: enum State { STATE_START, @@ -277,6 +281,9 @@ class HttpStreamFactoryImpl::Job { bool using_quic_; QuicStreamRequest quic_request_; + // True if this job used an existing QUIC session. + bool using_existing_quic_session_; + // Force spdy for all connections. bool force_spdy_always_; diff --git a/net/http/http_stream_factory_impl_request.cc b/net/http/http_stream_factory_impl_request.cc index 5f129ac..1eb8e51 100644 --- a/net/http/http_stream_factory_impl_request.cc +++ b/net/http/http_stream_factory_impl_request.cc @@ -380,13 +380,17 @@ void HttpStreamFactoryImpl::Request::OnJobSucceeded(Job* job) { // they complete? Or do we want to prevent connecting a new SpdySession if // we've already got one available for a different hostname where the ip // address matches up? - } else if (!bound_job_.get()) { + return; + } + if (!bound_job_.get()) { + if (jobs_.size() > 1) + job->ReportJobSuccededForRequest(); // We may have other jobs in |jobs_|. For example, if we start multiple jobs // for Alternate-Protocol. OrphanJobsExcept(job); - } else { - DCHECK(jobs_.empty()); + return; } + DCHECK(jobs_.empty()); } } // namespace net diff --git a/tools/metrics/histograms/histograms.xml b/tools/metrics/histograms/histograms.xml index 9bc2786..f0db3dc 100644 --- a/tools/metrics/histograms/histograms.xml +++ b/tools/metrics/histograms/histograms.xml @@ -10466,6 +10466,14 @@ Therefore, the affected-histogram name has to have at least one dot in it. <summary>The scheme of the URL for each main-frame navigation.</summary> </histogram> +<histogram name="Net.AlternateProtocolUsage" enum="AlternateProtocolUsage"> + <owner>rch@chromium.org</owner> + <summary> + Breakdown of how requests which could potentially make use of an alternate + protocol use or don't use the protocol. + </summary> +</histogram> + <histogram name="Net.AsyncResourceHandler_PendingDataCount"> <owner>Please list the metric's owners. Add more owner tags as needed.</owner> <summary> @@ -30097,6 +30105,14 @@ Therefore, the affected-histogram name has to have at least one dot in it. <int value="4" label="Snapped"/> </enum> +<enum name="AlternateProtocolUsage" type="int"> + <int value="0" label="ALTERNATE_PROTOCOL_USAGE_NO_RACE"/> + <int value="1" label="ALTERNATE_PROTOCOL_USAGE_WON_RACE"/> + <int value="2" label="ALTERNATE_PROTOCOL_USAGE_LOST_RACE"/> + <int value="3" label="ALTERNATE_PROTOCOL_USAGE_MAPPING_MISSING"/> + <int value="4" label="ALTERNATE_PROTOCOL_USAGE_BROKEN"/> +</enum> + <enum name="AndroidActivityId" type="int"> <int value="1" label="Unknown"/> <int value="2" label="Main"/> |