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

Unified Diff: chrome/browser/notifications/platform_notification_service_impl.cc

Issue 1155483002: Adding UMA for persistent notifications. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 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
« no previous file with comments | « no previous file | tools/metrics/actions/actions.xml » ('j') | tools/metrics/actions/actions.xml » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/notifications/platform_notification_service_impl.cc
diff --git a/chrome/browser/notifications/platform_notification_service_impl.cc b/chrome/browser/notifications/platform_notification_service_impl.cc
index 56908d85b8691880bd8035162cc15555a6b986cf..a60403bfc2d8a016fe3ffbed9b544adbf5ebed3b 100644
--- a/chrome/browser/notifications/platform_notification_service_impl.cc
+++ b/chrome/browser/notifications/platform_notification_service_impl.cc
@@ -21,6 +21,7 @@
#include "content/public/browser/notification_event_dispatcher.h"
#include "content/public/browser/platform_notification_context.h"
#include "content/public/browser/storage_partition.h"
+#include "content/public/browser/user_metrics.h"
#include "content/public/common/platform_notification_data.h"
#include "net/base/net_util.h"
#include "ui/message_center/notifier_settings.h"
@@ -38,9 +39,7 @@
#include "extensions/common/permissions/permissions_data.h"
#endif
-#if defined(OS_ANDROID)
#include "base/strings/string_number_conversions.h"
-#endif
using content::BrowserContext;
using content::BrowserThread;
@@ -52,15 +51,15 @@ namespace {
// Callback to provide when deleting the data associated with persistent Web
// Notifications from the notification database.
void OnPersistentNotificationDataDeleted(bool success) {
- // TODO(peter): Record UMA for notification deletion requests created by the
- // PlatformNotificationService.
+ content::RecordAction(
Peter Beverloo 2015/05/21 11:33:10 I was thinking of using a UMA_HISTOGRAM_BOOLEAN()
Deepak 2015/05/21 14:37:02 Done.
+ base::UserMetricsAction("PersistentNotificationDataDeleted"));
}
// Persistent notifications fired through the delegate do not care about the
// lifetime of the Service Worker responsible for executing the event.
void OnEventDispatchComplete(content::PersistentNotificationStatus status) {
- // TODO(peter): Record UMA statistics about the result status of running
- // events for persistent Web Notifications.
+ content::RecordAction(
+ base::UserMetricsAction("PersistentWebNotificationComplete"));
}
void CancelNotification(const std::string& id, ProfileID profile_id) {
@@ -316,10 +315,19 @@ bool PlatformNotificationServiceImpl::GetDisplayedPersistentNotifications(
if (!profile || profile->AsTestingProfile())
return false; // Tests will not have a message center.
- // TODO(peter): Filter for persistent notifications only.
- *displayed_notifications =
+ std::set<std::string> persistent_notifications;
Peter Beverloo 2015/05/21 11:33:10 Please let this TODO be for now, I'm working on a
+ std::set<std::string> all_notifications =
GetNotificationUIManager()->GetAllIdsByProfile(profile);
-
+ for (std::set<std::string>::iterator itr_notification =
+ all_notifications.begin();
+ itr_notification != all_notifications.end(); itr_notification++) {
+ int64_t id;
+ if (base::StringToInt64(*itr_notification, &id) &&
+ persistent_notifications_.find(id) != persistent_notifications_.end()) {
+ persistent_notifications.insert(*itr_notification);
+ }
+ }
+ *displayed_notifications = persistent_notifications;
return true;
#else
// Android cannot reliably return the notifications that are currently being
« no previous file with comments | « no previous file | tools/metrics/actions/actions.xml » ('j') | tools/metrics/actions/actions.xml » ('J')

Powered by Google App Engine
This is Rietveld 408576698