Bug 1356097 - Improve correctness of HTTP_PAGE_* telemetry r=mcmanus

When the last request is removed from the load group, we report telemetry for the default load request. This was done without checking if the request was successful, which may cause us to report telemetry for failed requests as well.
Also, the NullHttpChannel had its timingEnabled attribute set to true, which could lead us to report invalid telemetry

MozReview-Commit-ID: 5w7rd2V17Xd

--HG--
extra : rebase_source : 60785ebc38da8880aa6ded668fed8af81c3d60e9
This commit is contained in:
Valentin Gosu 2017-05-29 22:15:37 +02:00
parent a1c45c3558
commit 7b6dbd12fb
2 changed files with 9 additions and 2 deletions

View File

@ -825,7 +825,13 @@ nsLoadGroup::SetUserAgentOverrideCache(const nsACString & aUserAgentOverrideCach
void
nsLoadGroup::TelemetryReport()
{
if (mDefaultLoadIsTimed) {
nsresult defaultStatus = NS_ERROR_INVALID_ARG;
// We should only report HTTP_PAGE_* telemetry if the defaultRequest was
// actually successful.
if (mDefaultLoadRequest) {
mDefaultLoadRequest->GetStatus(&defaultStatus);
}
if (mDefaultLoadIsTimed && NS_SUCCEEDED(defaultStatus)) {
Telemetry::Accumulate(Telemetry::HTTP_REQUEST_PER_PAGE, mTimedRequests);
if (mTimedRequests) {
Telemetry::Accumulate(Telemetry::HTTP_REQUEST_PER_PAGE_FROM_CACHE,

View File

@ -552,7 +552,8 @@ NullHttpChannel::GetIsDocument(bool *aIsDocument)
NS_IMETHODIMP
NullHttpChannel::GetTimingEnabled(bool *aTimingEnabled)
{
*aTimingEnabled = true;
// We don't want to report timing for null channels.
*aTimingEnabled = false;
return NS_OK;
}