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); |
} |