Commit 68ceaf52 authored by sczs's avatar sczs Committed by Commit Bot

[ios] Records how long does it take to accept a confirm Infobar

- Creates Mobile.Messages.Confirm.Accept.Time histogram.
- Records the new created Histogram for Restore Infobars and Block
popups.

Bug: 1028951
Change-Id: Ifc33e345b9a78989a1584776e8e141ad14a7be16
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1939976
Commit-Queue: Sergio Collazos <sczs@chromium.org>
Reviewed-by: default avatarMark Cogan <marq@chromium.org>
Reviewed-by: default avatarAlexei Svitkine <asvitkine@chromium.org>
Cr-Commit-Position: refs/heads/master@{#719940}
parent 21b03c97
......@@ -120,6 +120,9 @@ class SessionCrashedInfoBarDelegate : public ConfirmInfoBarDelegate {
void InfoBarDismissed() override;
int GetIconId() const override;
// TimeInterval when the delegate was created.
NSTimeInterval delegate_creation_time_;
// The CrashRestoreHelper to restore sessions.
CrashRestoreHelper* crash_restore_helper_;
......@@ -128,7 +131,9 @@ class SessionCrashedInfoBarDelegate : public ConfirmInfoBarDelegate {
SessionCrashedInfoBarDelegate::SessionCrashedInfoBarDelegate(
CrashRestoreHelper* crash_restore_helper)
: crash_restore_helper_(crash_restore_helper) {}
: crash_restore_helper_(crash_restore_helper) {
delegate_creation_time_ = [NSDate timeIntervalSinceReferenceDate];
}
SessionCrashedInfoBarDelegate::~SessionCrashedInfoBarDelegate() {}
......@@ -172,6 +177,11 @@ base::string16 SessionCrashedInfoBarDelegate::GetButtonLabel(
}
bool SessionCrashedInfoBarDelegate::Accept() {
NSTimeInterval duration =
[NSDate timeIntervalSinceReferenceDate] - delegate_creation_time_;
[ConfirmInfobarMetricsRecorder
recordConfirmAcceptTime:duration
forInfobarConfirmType:InfobarConfirmType::kInfobarConfirmTypeRestore];
[ConfirmInfobarMetricsRecorder
recordConfirmInfobarEvent:MobileMessagesConfirmInfobarEvents::Accepted
forInfobarConfirmType:InfobarConfirmType::kInfobarConfirmTypeRestore];
......
......@@ -38,6 +38,11 @@ enum class MobileMessagesConfirmInfobarEvents {
+ (void)recordConfirmInfobarEvent:(MobileMessagesConfirmInfobarEvents)event
forInfobarConfirmType:(InfobarConfirmType)infobarConfirmType;
// Records the |duration| since the Infobar delegate was created until it was
// accepted for ConfirmInfobar of type |infobarConfirmType|.
+ (void)recordConfirmAcceptTime:(NSTimeInterval)duration
forInfobarConfirmType:(InfobarConfirmType)infobarConfirmType;
@end
#endif // IOS_CHROME_BROWSER_INFOBARS_CONFIRM_INFOBAR_METRICS_RECORDER_H_
......@@ -12,9 +12,13 @@
const char kInfobarTypeRestoreEventHistogram[] =
"Mobile.Messages.Confirm.Event.ConfirmInfobarTypeRestore";
const char kInfobarTypeRestoreAcceptTimeHistogram[] =
"Mobile.Messages.Confirm.Accept.Time.ConfirmInfobarTypeRestore";
const char kInfobarTypeBlockPopupsEventHistogram[] =
"Mobile.Messages.Confirm.Event.ConfirmInfobarTypeBlockPopups";
const char kInfobarTypeBlockPopupsAcceptTimeHistogram[] =
"Mobile.Messages.Confirm.Accept.Time.ConfirmInfobarTypeBlockPopups";
@implementation ConfirmInfobarMetricsRecorder
......@@ -30,4 +34,19 @@ const char kInfobarTypeBlockPopupsEventHistogram[] =
}
}
+ (void)recordConfirmAcceptTime:(NSTimeInterval)duration
forInfobarConfirmType:(InfobarConfirmType)infobarConfirmType {
base::TimeDelta timeDelta = base::TimeDelta::FromSecondsD(duration);
switch (infobarConfirmType) {
case InfobarConfirmType::kInfobarConfirmTypeRestore:
UMA_HISTOGRAM_MEDIUM_TIMES(kInfobarTypeRestoreAcceptTimeHistogram,
timeDelta);
break;
case InfobarConfirmType::kInfobarConfirmTypeBlockPopups:
UMA_HISTOGRAM_MEDIUM_TIMES(kInfobarTypeBlockPopupsAcceptTimeHistogram,
timeDelta);
break;
}
}
@end
......@@ -39,7 +39,9 @@ class BlockPopupInfoBarDelegate : public ConfirmInfoBarDelegate {
ios::ChromeBrowserState* browser_state,
web::WebState* web_state,
const std::vector<BlockedPopupTabHelper::Popup>& popups)
: browser_state_(browser_state), web_state_(web_state), popups_(popups) {}
: browser_state_(browser_state), web_state_(web_state), popups_(popups) {
delegate_creation_time_ = [NSDate timeIntervalSinceReferenceDate];
}
~BlockPopupInfoBarDelegate() override {}
......@@ -66,6 +68,12 @@ class BlockPopupInfoBarDelegate : public ConfirmInfoBarDelegate {
}
bool Accept() override {
NSTimeInterval duration =
[NSDate timeIntervalSinceReferenceDate] - delegate_creation_time_;
[ConfirmInfobarMetricsRecorder
recordConfirmAcceptTime:duration
forInfobarConfirmType:InfobarConfirmType::
kInfobarConfirmTypeBlockPopups];
[ConfirmInfobarMetricsRecorder
recordConfirmInfobarEvent:MobileMessagesConfirmInfobarEvents::Accepted
forInfobarConfirmType:InfobarConfirmType::
......@@ -101,6 +109,8 @@ class BlockPopupInfoBarDelegate : public ConfirmInfoBarDelegate {
std::vector<BlockedPopupTabHelper::Popup> popups_;
// The icon to display.
mutable gfx::Image icon_;
// TimeInterval when the delegate was created.
NSTimeInterval delegate_creation_time_;
};
} // namespace
......
......@@ -73687,6 +73687,18 @@ uploading your change for review.
</summary>
</histogram>
<histogram base="true" name="Mobile.Messages.Confirm.Accept.Time" units="ms"
expires_after="2020-06-01">
<!-- Name completed by histogram_suffixes name="Mobile.Messages.Confirm.Type" -->
<owner>sczs@chromium.org</owner>
<owner>thegreenfrog@chromium.org</owner>
<summary>
Records the time between the Infobar Delegate is created, and the user
accepts a Confirm Infobar action.
</summary>
</histogram>
<histogram base="true" name="Mobile.Messages.Confirm.Event"
enum="MobileMessagesConfirmInfobarEvents" expires_after="2020-05-01">
<!-- Name completed by histogram_suffixes name="Mobile.Messages.Confirm.Type" -->
......@@ -177816,6 +177828,7 @@ regressions. -->
label="Recorded for Block Popups Confirm Messages."/>
<suffix name="ConfirmInfobarTypeRestore"
label="Recorded for Restore Tabs Confirm Messages."/>
<affected-histogram name="Mobile.Messages.Confirm.Accept.Time"/>
<affected-histogram name="Mobile.Messages.Confirm.Event"/>
</histogram_suffixes>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment