From 7c1c963ca567abc5558900c5be6bd12c39026080 Mon Sep 17 00:00:00 2001 From: Kan-Ru Chen Date: Fri, 9 Sep 2016 12:06:36 +0800 Subject: [PATCH] Bug 1301346 - Add telemetry to collect how much time was spent in handling beforeunload and unload event. r=bsmedberg,smaug MozReview-Commit-ID: 3jCsBcDncGC --HG-- extra : rebase_source : b382dbf89483b9aee6c1a205bfc7b20cca18af85 --- layout/base/nsDocumentViewer.cpp | 12 +++++++++--- toolkit/components/telemetry/Histograms.json | 18 ++++++++++++++++++ 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/layout/base/nsDocumentViewer.cpp b/layout/base/nsDocumentViewer.cpp index bf2ff30a11a5..7b76b339899b 100644 --- a/layout/base/nsDocumentViewer.cpp +++ b/layout/base/nsDocumentViewer.cpp @@ -1141,8 +1141,11 @@ nsDocumentViewer::PermitUnloadInternal(bool *aShouldPrompt, nsIDocument::PageUnloadingEventTimeStamp timestamp(mDocument); mInPermitUnload = true; - EventDispatcher::DispatchDOMEvent(window, nullptr, event, mPresContext, - nullptr); + { + Telemetry::AutoTimer telemetryTimer; + EventDispatcher::DispatchDOMEvent(window, nullptr, event, mPresContext, + nullptr); + } mInPermitUnload = false; } @@ -1325,7 +1328,10 @@ nsDocumentViewer::PageHide(bool aIsUnload) nsIDocument::PageUnloadingEventTimeStamp timestamp(mDocument); - EventDispatcher::Dispatch(window, mPresContext, &event, nullptr, &status); + { + Telemetry::AutoTimer telemetryTimer; + EventDispatcher::Dispatch(window, mPresContext, &event, nullptr, &status); + } } #ifdef MOZ_XUL diff --git a/toolkit/components/telemetry/Histograms.json b/toolkit/components/telemetry/Histograms.json index 13ddf9186f08..31969719408d 100644 --- a/toolkit/components/telemetry/Histograms.json +++ b/toolkit/components/telemetry/Histograms.json @@ -10374,5 +10374,23 @@ "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." } }