Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(313)

Unified Diff: components/app_modal/javascript_dialog_manager.cc

Issue 1638013002: Add UMA histograms to track very brief or frequent tabs and JS dialogs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Tweak comment, move JS close logic to helper func Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: components/app_modal/javascript_dialog_manager.cc
diff --git a/components/app_modal/javascript_dialog_manager.cc b/components/app_modal/javascript_dialog_manager.cc
index 2b6ec646cebf8d6edc574a13e5f4bb43a38df1c7..049ed271ca430289802a732f6015a34a76a80749 100644
--- a/components/app_modal/javascript_dialog_manager.cc
+++ b/components/app_modal/javascript_dialog_manager.cc
@@ -9,6 +9,7 @@
#include "base/bind.h"
#include "base/i18n/rtl.h"
#include "base/macros.h"
+#include "base/metrics/histogram_macros.h"
#include "base/strings/utf_string_conversions.h"
#include "components/app_modal/app_modal_dialog.h"
#include "components/app_modal/app_modal_dialog_queue.h"
@@ -95,8 +96,33 @@ void JavaScriptDialogManager::RunJavaScriptDialog(
[JavaScriptAppModalDialog::GetSerializedOriginForWebContents(
web_contents)];
+ base::TimeTicks now = base::TimeTicks::Now();
+ if (!last_creation_time_.is_null()) {
+ // A new dialog has been created: log the time since the last one was
+ // created.
+ UMA_HISTOGRAM_FINE_TIMES_100(
+ "JSDialogs.FineTiming.TimeSinceLastDialogCreated",
+ now - last_creation_time_);
+ }
+ last_creation_time_ = now;
+
+ // Also log the time since a dialog was closed, but only if this is the first
+ // dialog that was opened since the closing.
+ if (!last_close_time_.is_null()) {
+ UMA_HISTOGRAM_FINE_TIMES_100(
+ "JSDialogs.FineTiming.TimeSinceLastDialogClosed",
+ now - last_close_time_);
+ last_close_time_ = base::TimeTicks();
+ }
+
if (extra_data->suppress_javascript_messages_) {
*did_suppress_message = true;
+
+ // Record this as a dialog that was immediately cancelled.
+ UMA_HISTOGRAM_FINE_TIMES_100(
+ "JSDialogs.FineTiming.DialogLifetime",
+ base::TimeDelta());
+ last_close_time_ = base::TimeTicks::Now();
return;
}
@@ -249,6 +275,8 @@ void JavaScriptDialogManager::OnDialogClosed(
// their WebContents is destroyed so |web_contents| is still valid here.)
extensions_client_->OnDialogClosed(web_contents);
+ last_close_time_ = base::TimeTicks::Now();
+
callback.Run(success, user_input);
}

Powered by Google App Engine
This is Rietveld 408576698