Bug 1591803 - Part 1: Remove the dead code in NotificationTelemetryService; r=johannh
☠☠ backed out by 6195e2f2a22d ☠ ☠
authorEhsan Akhgari <ehsan@mozilla.com>
Mon, 28 Oct 2019 20:26:23 +0000
changeset 499565 c0b6f37d24d214bfa50adef249c370b581a6675b
parent 499564 ac5c0f03040e60943864da7e1eab39a5ef67e57e
child 499566 7eff50262110d0eab15e7f5ba8fdb5f34073a7d9
push id99050
push usereakhgari@mozilla.com
push dateTue, 29 Oct 2019 01:16:01 +0000
treeherderautoland@7eff50262110 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjohannh
bugs1591803
milestone72.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1591803 - Part 1: Remove the dead code in NotificationTelemetryService; r=johannh Differential Revision: https://phabricator.services.mozilla.com/D50752
dom/notification/Notification.cpp
dom/notification/Notification.h
layout/build/components.conf
toolkit/components/telemetry/Histograms.json
toolkit/components/telemetry/histogram-allowlists.json
--- a/dom/notification/Notification.cpp
+++ b/dom/notification/Notification.cpp
@@ -588,135 +588,16 @@ nsresult NotificationPermissionRequest::
     RefPtr<NotificationPermissionCallback> callback(mCallback);
     callback->Call(mPermission, error);
     rv = error.StealNSResult();
   }
   mPromise->MaybeResolve(mPermission);
   return rv;
 }
 
-NS_IMPL_ISUPPORTS(NotificationTelemetryService, nsIObserver)
-
-NotificationTelemetryService::NotificationTelemetryService()
-    : mDNDRecorded(false) {}
-
-NotificationTelemetryService::~NotificationTelemetryService() {}
-
-/* static */
-already_AddRefed<NotificationTelemetryService>
-NotificationTelemetryService::GetInstance() {
-  nsCOMPtr<nsISupports> telemetrySupports =
-      do_GetService(NOTIFICATIONTELEMETRYSERVICE_CONTRACTID);
-  if (!telemetrySupports) {
-    return nullptr;
-  }
-  RefPtr<NotificationTelemetryService> telemetry =
-      static_cast<NotificationTelemetryService*>(telemetrySupports.get());
-  return telemetry.forget();
-}
-
-nsresult NotificationTelemetryService::Init() {
-  // Only perform permissions telemetry collection in the parent process.
-  if (!XRE_IsParentProcess()) {
-    return NS_OK;
-  }
-
-  RecordPermissions();
-
-  return NS_OK;
-}
-
-void NotificationTelemetryService::RecordPermissions() {
-  MOZ_ASSERT(XRE_IsParentProcess(),
-             "RecordPermissions may only be called in the parent process");
-
-  if (!Telemetry::CanRecordBase() || !Telemetry::CanRecordExtended()) {
-    return;
-  }
-
-  nsCOMPtr<nsIPermissionManager> permissionManager =
-      services::GetPermissionManager();
-  if (!permissionManager) {
-    return;
-  }
-
-  nsCOMPtr<nsISimpleEnumerator> enumerator;
-  nsresult rv = permissionManager->GetEnumerator(getter_AddRefs(enumerator));
-  if (NS_WARN_IF(NS_FAILED(rv))) {
-    return;
-  }
-
-  for (;;) {
-    bool hasMoreElements;
-    nsresult rv = enumerator->HasMoreElements(&hasMoreElements);
-    if (NS_WARN_IF(NS_FAILED(rv))) {
-      return;
-    }
-    if (!hasMoreElements) {
-      break;
-    }
-    nsCOMPtr<nsISupports> supportsPermission;
-    rv = enumerator->GetNext(getter_AddRefs(supportsPermission));
-    if (NS_WARN_IF(NS_FAILED(rv))) {
-      return;
-    }
-    uint32_t capability;
-    if (!GetNotificationPermission(supportsPermission, &capability)) {
-      continue;
-    }
-  }
-}
-
-bool NotificationTelemetryService::GetNotificationPermission(
-    nsISupports* aSupports, uint32_t* aCapability) {
-  nsCOMPtr<nsIPermission> permission = do_QueryInterface(aSupports);
-  if (!permission) {
-    return false;
-  }
-  nsAutoCString type;
-  permission->GetType(type);
-  if (!type.EqualsLiteral("desktop-notification")) {
-    return false;
-  }
-  permission->GetCapability(aCapability);
-  return true;
-}
-
-void NotificationTelemetryService::RecordDNDSupported() {
-  if (mDNDRecorded) {
-    return;
-  }
-
-  nsCOMPtr<nsIAlertsService> alertService = components::Alerts::Service();
-  if (!alertService) {
-    return;
-  }
-
-  nsCOMPtr<nsIAlertsDoNotDisturb> alertServiceDND =
-      do_QueryInterface(alertService);
-  if (!alertServiceDND) {
-    return;
-  }
-
-  mDNDRecorded = true;
-  bool isEnabled;
-  nsresult rv = alertServiceDND->GetManualDoNotDisturb(&isEnabled);
-  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;
@@ -1179,23 +1060,16 @@ NotificationObserver::Observe(nsISupport
       return Notification::OpenSettings(mPrincipal);
     }
     // `ContentParent::RecvOpenNotificationSettings` notifies observers in the
     // parent process.
     ContentChild::GetSingleton()->SendOpenNotificationSettings(
         IPC::Principal(mPrincipal));
     return NS_OK;
   } else if (!strcmp("alertshow", aTopic) || !strcmp("alertfinished", aTopic)) {
-    RefPtr<NotificationTelemetryService> telemetry =
-        NotificationTelemetryService::GetInstance();
-    if (telemetry) {
-      // Record whether "do not disturb" is supported after the first
-      // notification, to account for falling back to XUL alerts.
-      telemetry->RecordDNDSupported();
-    }
     Unused << NS_WARN_IF(NS_FAILED(AdjustPushQuota(aTopic)));
   }
 
   return mObserver->Observe(aSubject, aTopic, aData);
 }
 
 nsresult NotificationObserver::AdjustPushQuota(const char* aTopic) {
   nsCOMPtr<nsIPushQuotaManager> pushQuotaManager =
--- a/dom/notification/Notification.h
+++ b/dom/notification/Notification.h
@@ -14,54 +14,28 @@
 #include "nsIObserver.h"
 #include "nsISupports.h"
 
 #include "nsCycleCollectionParticipant.h"
 #include "nsHashKeys.h"
 #include "nsTHashtable.h"
 #include "nsWeakReference.h"
 
-#define NOTIFICATIONTELEMETRYSERVICE_CONTRACTID \
-  "@mozilla.org/notificationTelemetryService;1"
-
 class nsIPrincipal;
 class nsIVariant;
 
 namespace mozilla {
 namespace dom {
 
 class NotificationRef;
 class WorkerNotificationObserver;
 class Promise;
 class StrongWorkerRef;
 class WorkerPrivate;
 
-// 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 nsIObserver {
- public:
-  NS_DECL_ISUPPORTS
-  NS_DECL_NSIOBSERVER
-
-  NotificationTelemetryService();
-
-  static already_AddRefed<NotificationTelemetryService> GetInstance();
-
-  nsresult Init();
-  void RecordDNDSupported();
-  void RecordPermissions();
-
- private:
-  virtual ~NotificationTelemetryService();
-
-  bool GetNotificationPermission(nsISupports* aSupports, uint32_t* aCapability);
-
-  bool mDNDRecorded;
-};
-
 /*
  * Notifications on workers introduce some lifetime issues. The property we
  * are trying to satisfy is:
  *   Whenever a task is dispatched to the main thread to operate on
  *   a Notification, the Notification should be addrefed on the worker thread
  *   and a feature should be added to observe the worker lifetime. This main
  *   thread owner should ensure it properly releases the reference to the
  *   Notification, additionally removing the feature if necessary.
@@ -115,17 +89,16 @@ class Notification : public DOMEventTarg
   friend class CloseNotificationRunnable;
   friend class NotificationTask;
   friend class NotificationPermissionRequest;
   friend class MainThreadNotificationObserver;
   friend class NotificationStorageCallback;
   friend class ServiceWorkerNotificationObserver;
   friend class WorkerGetRunnable;
   friend class WorkerNotificationObserver;
-  friend class NotificationTelemetryService;
 
  public:
   IMPL_EVENT_HANDLER(click)
   IMPL_EVENT_HANDLER(show)
   IMPL_EVENT_HANDLER(error)
   IMPL_EVENT_HANDLER(close)
 
   NS_DECL_ISUPPORTS_INHERITED
--- a/layout/build/components.conf
+++ b/layout/build/components.conf
@@ -301,23 +301,16 @@ Classes = [
     {
         'cid': '{ac9e3e82-bfbd-4f26-941e-f58c8ee178c1}',
         'contract_ids': ['@mozilla.org/no-data-protocol-content-policy;1'],
         'type': 'nsNoDataProtocolContentPolicy',
         'headers': ['/dom/base/nsNoDataProtocolContentPolicy.h'],
         'categories': {'content-policy': '@mozilla.org/no-data-protocol-content-policy;1'},
     },
     {
-        'cid': '{5995b782-6a0e-4066-aac5-276f0a9ad8cf}',
-        'contract_ids': ['@mozilla.org/notificationTelemetryService;1'],
-        'type': 'mozilla::dom::NotificationTelemetryService',
-        'headers': ['mozilla/dom/Notification.h'],
-        'init_method': 'Init',
-    },
-    {
         'cid': '{bd066e5f-146f-4472-8331-7bfd05b1ed90}',
         'contract_ids': ['@mozilla.org/nullprincipal;1'],
         'type': 'mozilla::NullPrincipal',
         'headers': ['/caps/NullPrincipal.h'],
         'init_method': 'Init',
     },
     {
         'cid': '{2a058404-fb85-44ec-8cfd-e8cbdc988dc1}',
--- a/toolkit/components/telemetry/Histograms.json
+++ b/toolkit/components/telemetry/Histograms.json
@@ -13344,25 +13344,16 @@
     "record_in_processes": ["main", "content"],
     "products": ["firefox", "fennec", "geckoview"],
     "alert_emails": ["firefox-dev@mozilla.org"],
     "bug_numbers": [1219030],
     "expires_in_version": "50",
     "kind": "boolean",
     "description": "XUL-only: whether the user has toggled do not disturb."
   },
-  "ALERTS_SERVICE_DND_SUPPORTED_FLAG": {
-    "record_in_processes": ["main", "content"],
-    "products": ["firefox", "fennec", "geckoview"],
-    "alert_emails": ["firefox-dev@mozilla.org"],
-    "bug_numbers": [1219030],
-    "expires_in_version": "50",
-    "kind": "flag",
-    "description": "Whether the do not disturb option is supported. True if the browser uses XUL alerts."
-  },
   "PLUGIN_DRAWING_MODEL": {
     "record_in_processes": ["main", "content"],
     "products": ["firefox", "fennec", "geckoview"],
     "alert_emails": ["gfx-telemetry-alerts@mozilla.com", "rhunt@mozilla.com"],
     "expires_in_version": "never",
     "kind": "enumerated",
     "bug_numbers": [1229961],
     "n_values": 12,
--- a/toolkit/components/telemetry/histogram-allowlists.json
+++ b/toolkit/components/telemetry/histogram-allowlists.json
@@ -1256,17 +1256,16 @@
     "GEOLOCATION_WIN8_SOURCE_IS_MLS"
   ],
   "kind": [
     "A11Y_IATABLE_USAGE_FLAG",
     "A11Y_INSTANTIATED_FLAG",
     "A11Y_ISIMPLEDOM_USAGE_FLAG",
     "ADDON_FORBIDDEN_CPOW_USAGE",
     "ADDON_MANAGER_UPGRADE_UI_SHOWN",
-    "ALERTS_SERVICE_DND_SUPPORTED_FLAG",
     "AUTO_REJECTED_TRANSLATION_OFFERS",
     "BROWSER_SHIM_USAGE_BLOCKED",
     "CANVAS_WEBGL_ACCL_FAILURE_ID",
     "CANVAS_WEBGL_FAILURE_ID",
     "CHANGES_OF_TARGET_LANGUAGE",
     "COMPONENTS_SHIM_ACCESSED_BY_CONTENT",
     "CONTENT_DOCUMENTS_DESTROYED",
     "CSP_DOCUMENTS_COUNT",