diff --git a/dom/base/Document.cpp b/dom/base/Document.cpp index 499f2ae50b26..c8f8b9c84f3d 100644 --- a/dom/base/Document.cpp +++ b/dom/base/Document.cpp @@ -2041,6 +2041,23 @@ void Document::RecordPageLoadEventTelemetry( break; } + nsCOMPtr tldService = + do_GetService(NS_EFFECTIVETLDSERVICE_CONTRACTID); + if (tldService && mReferrerInfo && + (docshell->GetLoadType() & nsIDocShell::LOAD_CMD_NORMAL)) { + nsAutoCString currentBaseDomain, referrerBaseDomain; + nsCOMPtr referrerURI = mReferrerInfo->GetComputedReferrer(); + if (referrerURI) { + auto result = NS_SUCCEEDED( + tldService->GetBaseDomain(referrerURI, 0, referrerBaseDomain)); + if (result) { + bool sameOrigin = false; + NodePrincipal()->IsSameOrigin(referrerURI, &sameOrigin); + aEventTelemetryData.sameOriginNav = mozilla::Some(sameOrigin); + } + } + } + aEventTelemetryData.loadType = mozilla::Some(loadTypeStr); // Sending a glean ping must be done on the parent process. @@ -2071,6 +2088,22 @@ void Document::AccumulatePageLoadTelemetry( TimeStamp responseStart; timedChannel->GetResponseStart(&responseStart); + TimeStamp redirectStart, redirectEnd; + timedChannel->GetRedirectStart(&redirectStart); + timedChannel->GetRedirectEnd(&redirectEnd); + + uint8_t redirectCount; + timedChannel->GetRedirectCount(&redirectCount); + if (redirectCount) { + aEventTelemetryDataOut.redirectCount = + mozilla::Some(static_cast(redirectCount)); + } + + if (!redirectStart.IsNull() && !redirectEnd.IsNull()) { + aEventTelemetryDataOut.redirectTime = mozilla::Some( + static_cast((redirectEnd - redirectStart).ToMilliseconds())); + } + TimeStamp navigationStart = GetNavigationTiming()->GetNavigationStartTimeStamp(); @@ -2090,6 +2123,7 @@ void Document::AccumulatePageLoadTelemetry( RefPtr dnsServiceChild = net::ChildDNSService::GetSingleton(); dnsServiceChild->GetTRRDomain(dnsKey); + aEventTelemetryDataOut.trrDomain = mozilla::Some(dnsKey); } uint32_t major; @@ -2116,6 +2150,8 @@ void Document::AccumulatePageLoadTelemetry( http3Key = "supports_http3"_ns; } } + + aEventTelemetryDataOut.httpVer = mozilla::Some(major); } } diff --git a/dom/ipc/PageLoadEventUtils.h b/dom/ipc/PageLoadEventUtils.h index 5dd3ca49e980..18fb7ff96cbb 100644 --- a/dom/ipc/PageLoadEventUtils.h +++ b/dom/ipc/PageLoadEventUtils.h @@ -22,6 +22,11 @@ struct ParamTraits { WriteParam(aWriter, aParam.loadTime); WriteParam(aWriter, aParam.loadType); WriteParam(aWriter, aParam.responseTime); + WriteParam(aWriter, aParam.httpVer); + WriteParam(aWriter, aParam.redirectCount); + WriteParam(aWriter, aParam.redirectTime); + WriteParam(aWriter, aParam.sameOriginNav); + WriteParam(aWriter, aParam.trrDomain); } static bool Read(MessageReader* aReader, paramType* aResult) { @@ -29,7 +34,12 @@ struct ParamTraits { ReadParam(aReader, &aResult->jsExecTime) && ReadParam(aReader, &aResult->loadTime) && ReadParam(aReader, &aResult->loadType) && - ReadParam(aReader, &aResult->responseTime); + ReadParam(aReader, &aResult->responseTime) && + ReadParam(aReader, &aResult->httpVer) && + ReadParam(aReader, &aResult->redirectCount) && + ReadParam(aReader, &aResult->redirectTime) && + ReadParam(aReader, &aResult->sameOriginNav) && + ReadParam(aReader, &aResult->trrDomain); } }; diff --git a/dom/metrics.yaml b/dom/metrics.yaml index c7d3ccdab755..4bf30e811d3c 100644 --- a/dom/metrics.yaml +++ b/dom/metrics.yaml @@ -17,8 +17,10 @@ perf: Recorded when a top level content document has been loaded. bugs: - https://bugzilla.mozilla.org/show_bug.cgi?id=1759744 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1799727 data_reviews: - https://bugzilla.mozilla.org/show_bug.cgi?id=1759744#c5 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1799727#c4 notification_emails: - perf-telemetry-alerts@mozilla.com - dpalmeiro@mozilla.com @@ -44,9 +46,32 @@ perf: "Time spent executing JS during page load, in ms." type: quantity unit: ms + redirect_time: + type: quantity + description: + "Time spent in redirections for the top level document." + unit: ms + redirect_count: + description: + "Number of redirections for the top level document." + type: quantity + unit: integer load_type: description: "One of normal,reload,stop,link,history,error or other." type: string + same_origin_nav: + description: + "If true, a normal navigation was performed on the same origin." + type: boolean + http_ver: + description: + "Version of HTTP protocol used." + type: quantity + unit: integer + trr_domain: + description: + "TRR domain used." + type: string send_in_pings: - pageload