Commit 9fa3adab authored by Richard Knoll's avatar Richard Knoll Committed by Commit Bot

Log UMA for notification trigger display delay.

This adds UMA to track the actual display delay of notifications with
show triggers.

Bug: 891339
Change-Id: I8263b9b50df06eabb38079641069863d74d26327
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1801758Reviewed-by: default avatarSteven Holte <holte@chromium.org>
Reviewed-by: default avatarPeter Beverloo <peter@chromium.org>
Commit-Queue: Richard Knoll <knollr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#699084}
parent 6bb87bdc
...@@ -438,6 +438,11 @@ void PlatformNotificationContextImpl::DoTriggerNotification( ...@@ -438,6 +438,11 @@ void PlatformNotificationContextImpl::DoTriggerNotification(
return; return;
} }
base::Time timestamp =
database_data.notification_data.show_trigger_timestamp.value();
UMA_HISTOGRAM_LONG_TIMES("Notifications.Triggers.DisplayDelay",
base::Time::Now() - timestamp);
// Remove resources from DB as we don't need them anymore. // Remove resources from DB as we don't need them anymore.
database_->DeleteNotificationResources(write_database_data.notification_id, database_->DeleteNotificationResources(write_database_data.notification_id,
write_database_data.origin); write_database_data.origin);
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include "base/bind.h" #include "base/bind.h"
#include "base/run_loop.h" #include "base/run_loop.h"
#include "base/test/bind_test_util.h" #include "base/test/bind_test_util.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/scoped_feature_list.h" #include "base/test/scoped_feature_list.h"
#include "base/time/time.h" #include "base/time/time.h"
#include "content/browser/notifications/notification_trigger_constants.h" #include "content/browser/notifications/notification_trigger_constants.h"
...@@ -277,4 +278,22 @@ TEST_F(PlatformNotificationContextTriggerTest, EnforcesLimitOnUpdate) { ...@@ -277,4 +278,22 @@ TEST_F(PlatformNotificationContextTriggerTest, EnforcesLimitOnUpdate) {
TimeDelta::FromSeconds(kMaximumScheduledNotificationsPerOrigin + 1))); TimeDelta::FromSeconds(kMaximumScheduledNotificationsPerOrigin + 1)));
} }
TEST_F(PlatformNotificationContextTriggerTest, RecordDisplayDelay) {
base::HistogramTester histogram_tester;
base::TimeDelta trigger_delay = TimeDelta::FromSeconds(10);
base::TimeDelta display_delay = TimeDelta::FromSeconds(8);
WriteNotificationData("1", Time::Now() + trigger_delay);
ASSERT_EQ(0u, GetDisplayedNotifications().size());
// Forward time until after the expected trigger time.
task_environment_.FastForwardBy(trigger_delay + display_delay);
// Trigger notification |display_delay| after it should have been displayed.
TriggerNotifications();
histogram_tester.ExpectUniqueSample("Notifications.Triggers.DisplayDelay",
display_delay.InMilliseconds(), 1);
}
} // namespace content } // namespace content
...@@ -89628,6 +89628,16 @@ uploading your change for review. ...@@ -89628,6 +89628,16 @@ uploading your change for review.
</summary> </summary>
</histogram> </histogram>
<histogram name="Notifications.Triggers.DisplayDelay" units="ms"
expires_after="M82">
<owner>knollr@chromium.org</owner>
<owner>peter@chromium.org</owner>
<summary>
Delay between the expected and actual display time of a notification.
Recorded just before displaying a notification with a show trigger.
</summary>
</histogram>
<histogram name="Notifications.Triggers.HasShowTrigger" enum="Boolean" <histogram name="Notifications.Triggers.HasShowTrigger" enum="Boolean"
expires_after="M80"> expires_after="M80">
<owner>knollr@chromium.org</owner> <owner>knollr@chromium.org</owner>
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