From d0eb2b7593cbe1aab7d15bed9920e8468971f540 Mon Sep 17 00:00:00 2001 From: Amy Chung Date: Fri, 15 Dec 2017 10:50:19 -0600 Subject: [PATCH] Bug 1413512 -- Added a telemtry for counting of the HTTP redirection that triggered by top-level document or by subresource. r=schien data=francois --- netwerk/protocol/http/nsHttpHandler.cpp | 30 +++++++++++++++----- toolkit/components/telemetry/Histograms.json | 10 +++++++ 2 files changed, 33 insertions(+), 7 deletions(-) diff --git a/netwerk/protocol/http/nsHttpHandler.cpp b/netwerk/protocol/http/nsHttpHandler.cpp index 29b109697274..7e40068cc3bd 100644 --- a/netwerk/protocol/http/nsHttpHandler.cpp +++ b/netwerk/protocol/http/nsHttpHandler.cpp @@ -119,6 +119,8 @@ //----------------------------------------------------------------------------- +using mozilla::Telemetry::LABELS_NETWORK_HTTP_REDIRECT_TO_SCHEME; + namespace mozilla { namespace net { @@ -828,14 +830,28 @@ nsHttpHandler::AsyncOnChannelRedirect(nsIChannel* oldChan, uint32_t flags, nsIEventTarget* mainThreadEventTarget) { - // TODO E10S This helper has to be initialized on the other process - RefPtr redirectCallbackHelper = - new nsAsyncRedirectVerifyHelper(); + MOZ_ASSERT(NS_IsMainThread() && (oldChan && newChan)); - return redirectCallbackHelper->Init(oldChan, - newChan, - flags, - mainThreadEventTarget); + nsCOMPtr newURI; + newChan->GetURI(getter_AddRefs(newURI)); + MOZ_ASSERT(newURI); + + nsAutoCString scheme; + newURI->GetScheme(scheme); + MOZ_ASSERT(!scheme.IsEmpty()); + + Telemetry::AccumulateCategoricalKeyed( + scheme, + oldChan->IsDocument() + ? LABELS_NETWORK_HTTP_REDIRECT_TO_SCHEME::topLevel + : LABELS_NETWORK_HTTP_REDIRECT_TO_SCHEME::subresource); + + // TODO E10S This helper has to be initialized on the other process + RefPtr redirectCallbackHelper = + new nsAsyncRedirectVerifyHelper(); + + return redirectCallbackHelper->Init( + oldChan, newChan, flags, mainThreadEventTarget); } /* static */ nsresult diff --git a/toolkit/components/telemetry/Histograms.json b/toolkit/components/telemetry/Histograms.json index f7da860b4fb4..1a147da488cf 100644 --- a/toolkit/components/telemetry/Histograms.json +++ b/toolkit/components/telemetry/Histograms.json @@ -2383,6 +2383,16 @@ "labels": ["NotSent", "CachedContentUsed", "CachedContentNotUsed"], "description": "Stats for validation requests when cache won the race." }, + "NETWORK_HTTP_REDIRECT_TO_SCHEME" :{ + "record_in_processes": ["main"], + "alert_emails": ["necko@mozilla.com", "seceng-telemetry@mozilla.com", "jkt@mozilla.com"], + "bug_numbers": [1413512], + "expires_in_version": "64", + "kind": "categorical", + "keyed": true, + "description": "Count of the HTTP redirection that triggered by top-level document or by subresource, keyed by the URL scheme redirected to.", + "labels": ["topLevel", "subresource"] + }, "HTTP_AUTH_DIALOG_STATS_3": { "record_in_processes": ["main", "content"], "expires_in_version": "61",