Bug 1430635 - Add telemetry to track how often preloaded scripts are used. r=baku, data-review=liuche

This commit is contained in:
Jon Coppeard 2018-01-17 03:10:00 -05:00
parent a38267f276
commit 57f7f09133
2 changed files with 20 additions and 0 deletions

View File

@ -65,6 +65,8 @@
using JS::SourceBufferHolder;
using mozilla::Telemetry::LABELS_DOM_SCRIPT_PRELOAD_RESULT;
namespace mozilla {
namespace dom {
@ -180,6 +182,10 @@ ScriptLoader::~ScriptLoader()
for (uint32_t j = 0; j < mPendingChildLoaders.Length(); ++j) {
mPendingChildLoaders[j]->RemoveParserBlockingScriptExecutionBlocker();
}
for (size_t i = 0; i < mPreloads.Length(); i++) {
AccumulateCategorical(LABELS_DOM_SCRIPT_PRELOAD_RESULT::NotUsed);
}
}
// Collect telemtry data about the cache information, and the kind of source
@ -1323,6 +1329,7 @@ ScriptLoader::ProcessExternalScript(nsIScriptElement* aElement,
// Probably plans have changed; even though the preload was allowed seems
// like the actual load is not; let's cancel the preload request.
request->Cancel();
AccumulateCategorical(LABELS_DOM_SCRIPT_PRELOAD_RESULT::RejectedByPolicy);
return false;
}
@ -1333,6 +1340,8 @@ ScriptLoader::ProcessExternalScript(nsIScriptElement* aElement,
// update them here.
request->SetScriptMode(aElement->GetScriptDeferred(),
aElement->GetScriptAsync());
AccumulateCategorical(LABELS_DOM_SCRIPT_PRELOAD_RESULT::Used);
} else {
// No usable preload found.
@ -1588,6 +1597,7 @@ ScriptLoader::LookupPreloadRequest(nsIScriptElement* aElement,
mDocument->GetReferrerPolicy() != request->mReferrerPolicy ||
aScriptKind != request->mKind) {
// Drop the preload.
AccumulateCategorical(LABELS_DOM_SCRIPT_PRELOAD_RESULT::RequestMismatch);
return nullptr;
}
@ -2964,6 +2974,7 @@ ScriptLoader::HandleLoadError(ScriptLoadRequest *aRequest, nsresult aResult)
mCurrentParserInsertedScript = oldParserInsertedScript;
} else {
mPreloads.RemoveElement(aRequest, PreloadRequestComparator());
AccumulateCategorical(LABELS_DOM_SCRIPT_PRELOAD_RESULT::LoadError);
}
}

View File

@ -12611,6 +12611,15 @@
"bug_numbers": [1362114],
"description": "Number of script tags evaluated per document."
},
"DOM_SCRIPT_PRELOAD_RESULT": {
"record_in_processes": ["main", "content"],
"alert_emails": ["jcoppeard@mozilla.com"],
"expires_in_version": "63",
"kind": "categorical",
"bug_numbers": [1430145],
"labels": ["Used", "RejectedByPolicy", "RequestMismatch", "LoadError", "NotUsed"],
"description": "Whether a preloaded script was used or the reason it was not used."
},
"VIDEO_FASTSEEK_USED": {
"record_in_processes": ["main", "content"],
"alert_emails": ["cpearce@mozilla.com", "tkuo@mozilla.com"],