Bug 1389057 - Inherit NotificationTelemetryService from nsIObserver draft
authorSwapnesh Kumar Sahoo <swapneshks@gmail.com>
Wed, 16 Aug 2017 01:24:31 +0530
changeset 646899 bfa77c06f3ae3095eb1519ec618806d9e09d3744
parent 646498 564e82f0f289af976da01c2d50507017bbc152b5
child 726349 63b40111bfbb66b2787a94f25ecd379f6ea3ef9e
push id74235
push userswapneshks@gmail.com
push dateTue, 15 Aug 2017 19:56:42 +0000
bugs1389057
milestone57.0a1
Bug 1389057 - Inherit NotificationTelemetryService from nsIObserver MozReview-Commit-ID: La4XxSWYljO
dom/notification/Notification.cpp
dom/notification/Notification.h
--- a/dom/notification/Notification.cpp
+++ b/dom/notification/Notification.cpp
@@ -664,17 +664,17 @@ NotificationPermissionRequest::GetTypes(
 {
   nsTArray<nsString> emptyOptions;
   return nsContentPermissionUtils::CreatePermissionArray(NS_LITERAL_CSTRING("desktop-notification"),
                                                          NS_LITERAL_CSTRING("unused"),
                                                          emptyOptions,
                                                          aTypes);
 }
 
-NS_IMPL_ISUPPORTS(NotificationTelemetryService, nsISupports)
+NS_IMPL_ISUPPORTS(NotificationTelemetryService, nsIObserver)
 
 NotificationTelemetryService::NotificationTelemetryService()
   : mDNDRecorded(false)
 {}
 
 NotificationTelemetryService::~NotificationTelemetryService()
 {}
 
@@ -794,16 +794,24 @@ NotificationTelemetryService::RecordDNDS
   if (NS_FAILED(rv)) {
     return;
   }
 
   Telemetry::Accumulate(
     Telemetry::ALERTS_SERVICE_DND_SUPPORTED_FLAG, true);
 }
 
+NS_IMETHODIMP
+NotificationTelemetryService::Observe(nsISupports* aSubject,
+                                      const char* aTopic,
+                                      const char16_t* aData)
+{
+  return NS_OK;
+}
+
 // Observer that the alert service calls to do common tasks and/or dispatch to the
 // specific observer for the context e.g. main thread, worker, or service worker.
 class NotificationObserver final : public nsIObserver
 {
 public:
   nsCOMPtr<nsIObserver> mObserver;
   nsCOMPtr<nsIPrincipal> mPrincipal;
   bool mInPrivateBrowsing;
--- a/dom/notification/Notification.h
+++ b/dom/notification/Notification.h
@@ -47,20 +47,21 @@ public:
   explicit NotificationWorkerHolder(Notification* aNotification);
 
   bool
   Notify(workers::Status aStatus) override;
 };
 
 // Records telemetry probes at application startup, when a notification is
 // shown, and when the notification permission is revoked for a site.
-class NotificationTelemetryService final : public nsISupports
+class NotificationTelemetryService final : public nsIObserver
 {
 public:
   NS_DECL_ISUPPORTS
+  NS_DECL_NSIOBSERVER
 
   NotificationTelemetryService();
 
   static already_AddRefed<NotificationTelemetryService> GetInstance();
 
   nsresult Init();
   void RecordDNDSupported();
   void RecordPermissions();