Bug 1301346 - Add telemetry to collect how much time was spent in handling beforeunload and unload event. r=smaug,bsmedberg
MozReview-Commit-ID: 3jCsBcDncGC
--- a/layout/base/nsDocumentViewer.cpp
+++ b/layout/base/nsDocumentViewer.cpp
@@ -1136,18 +1136,21 @@ nsDocumentViewer::PermitUnloadInternal(b
// Never permit dialogs from the beforeunload handler
nsGlobalWindow* globalWindow = nsGlobalWindow::Cast(window);
dialogsAreEnabled = globalWindow->AreDialogsEnabled();
nsGlobalWindow::TemporarilyDisableDialogs disableDialogs(globalWindow);
nsIDocument::PageUnloadingEventTimeStamp timestamp(mDocument);
mInPermitUnload = true;
- EventDispatcher::DispatchDOMEvent(window, nullptr, event, mPresContext,
- nullptr);
+ {
+ Telemetry::AutoTimer<Telemetry::HANDLE_BEFOREUNLOAD_MS> telemetryTimer;
+ EventDispatcher::DispatchDOMEvent(window, nullptr, event, mPresContext,
+ nullptr);
+ }
mInPermitUnload = false;
}
nsCOMPtr<nsIDocShell> docShell(mContainer);
nsAutoString text;
beforeUnload->GetReturnValue(text);
// NB: we nullcheck mDocument because it might now be dead as a result of
@@ -1320,17 +1323,20 @@ nsDocumentViewer::PageHide(bool aIsUnloa
event.mTarget = mDocument;
// Never permit popups from the unload handler, no matter how we get
// here.
nsAutoPopupStatePusher popupStatePusher(openAbused, true);
nsIDocument::PageUnloadingEventTimeStamp timestamp(mDocument);
- EventDispatcher::Dispatch(window, mPresContext, &event, nullptr, &status);
+ {
+ Telemetry::AutoTimer<Telemetry::HANDLE_UNLOAD_MS> telemetryTimer;
+ EventDispatcher::Dispatch(window, mPresContext, &event, nullptr, &status);
+ }
}
#ifdef MOZ_XUL
// look for open menupopups and close them after the unload event, in case
// the unload event listeners open any new popups
nsContentUtils::HidePopupsInDocument(mDocument);
#endif
--- a/toolkit/components/telemetry/Histograms.json
+++ b/toolkit/components/telemetry/Histograms.json
@@ -10369,10 +10369,28 @@
"alert_emails": ["eisaacson@mozilla.com"],
"bug_numbers": [1308030],
"releaseChannelCollection": "opt-out",
"expires_in_version": "56",
"kind": "linear",
"high": 300000,
"n_buckets": 30,
"description": "Time in MS that content is narrated in 10 second increments up to 5 minutes"
+ },
+ "HANDLE_UNLOAD_MS": {
+ "alert_emails": ["kchen@mozilla.com"],
+ "expires_in_version": "55",
+ "kind": "exponential",
+ "high": 10000,
+ "n_buckets": 50,
+ "bug_numbers": [1301346],
+ "description": "The time spent handling unload event in milliseconds. It measures all documents and subframes separately. If there are multiple handlers for the unload event in a document, this will record a single value across all handlers in the document."
+ },
+ "HANDLE_BEFOREUNLOAD_MS": {
+ "alert_emails": ["kchen@mozilla.com"],
+ "expires_in_version": "55",
+ "kind": "exponential",
+ "high": 10000,
+ "n_buckets": 50,
+ "bug_numbers": [1301346],
+ "description": "The time spent handling beforeunload event in milliseconds. It measures all documents and subframes separately. If there are multiple handlers for the unload event in a document, this will record a single value across all handlers in the document."
}
}