From 5335681cd2ab05ad47e81be7722c9eee19d54065 Mon Sep 17 00:00:00 2001 From: adeshkp Date: Sat, 12 Jan 2019 06:20:31 -0500 Subject: Telemetry: Remove stubs and related code --- dom/notification/Notification.cpp | 169 -------------------------------------- dom/notification/Notification.h | 34 -------- 2 files changed, 203 deletions(-) (limited to 'dom/notification') diff --git a/dom/notification/Notification.cpp b/dom/notification/Notification.cpp index 71c4916b9..a5aa48b00 100644 --- a/dom/notification/Notification.cpp +++ b/dom/notification/Notification.cpp @@ -11,7 +11,6 @@ #include "mozilla/OwningNonNull.h" #include "mozilla/Preferences.h" #include "mozilla/Services.h" -#include "mozilla/Telemetry.h" #include "mozilla/Unused.h" #include "mozilla/dom/AppNotificationServiceOptionsBinding.h" @@ -656,172 +655,6 @@ NotificationPermissionRequest::GetTypes(nsIArray** aTypes) aTypes); } -NS_IMPL_ISUPPORTS(NotificationTelemetryService, nsIObserver) - -NotificationTelemetryService::NotificationTelemetryService() - : mDNDRecorded(false) -{} - -NotificationTelemetryService::~NotificationTelemetryService() -{ - Unused << NS_WARN_IF(NS_FAILED(RemovePermissionChangeObserver())); -} - -/* static */ already_AddRefed -NotificationTelemetryService::GetInstance() -{ - nsCOMPtr telemetrySupports = - do_GetService(NOTIFICATIONTELEMETRYSERVICE_CONTRACTID); - if (!telemetrySupports) { - return nullptr; - } - RefPtr telemetry = - static_cast(telemetrySupports.get()); - return telemetry.forget(); -} - -nsresult -NotificationTelemetryService::Init() -{ - nsresult rv = AddPermissionChangeObserver(); - NS_ENSURE_SUCCESS(rv, rv); - - RecordPermissions(); - - return NS_OK; -} - -nsresult -NotificationTelemetryService::RemovePermissionChangeObserver() -{ - nsCOMPtr obs = mozilla::services::GetObserverService(); - if (!obs) { - return NS_ERROR_OUT_OF_MEMORY; - } - return obs->RemoveObserver(this, "perm-changed"); -} - -nsresult -NotificationTelemetryService::AddPermissionChangeObserver() -{ - nsCOMPtr obs = mozilla::services::GetObserverService(); - if (!obs) { - return NS_ERROR_OUT_OF_MEMORY; - } - return obs->AddObserver(this, "perm-changed", false); -} - -void -NotificationTelemetryService::RecordPermissions() -{ - if (!Telemetry::CanRecordBase() || !Telemetry::CanRecordExtended()) { - return; - } - - nsCOMPtr permissionManager = - services::GetPermissionManager(); - if (!permissionManager) { - return; - } - - nsCOMPtr 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 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 permission = do_QueryInterface(aSupports); - if (!permission) { - return false; - } - nsAutoCString type; - permission->GetType(type); - if (!type.Equals("desktop-notification")) { - return false; - } - permission->GetCapability(aCapability); - return true; -} - -void -NotificationTelemetryService::RecordDNDSupported() -{ - if (mDNDRecorded) { - return; - } - - nsCOMPtr alertService = - do_GetService(NS_ALERTSERVICE_CONTRACTID); - if (!alertService) { - return; - } - - nsCOMPtr alertServiceDND = - do_QueryInterface(alertService); - if (!alertServiceDND) { - return; - } - - mDNDRecorded = true; - bool isEnabled; - nsresult rv = alertServiceDND->GetManualDoNotDisturb(&isEnabled); - if (NS_FAILED(rv)) { - return; - } -} - -nsresult -NotificationTelemetryService::RecordSender(nsIPrincipal* aPrincipal) -{ - if (!Telemetry::CanRecordBase() || !Telemetry::CanRecordExtended() || - !nsAlertsUtils::IsActionablePrincipal(aPrincipal)) { - return NS_OK; - } - nsAutoString origin; - nsresult rv = Notification::GetOrigin(aPrincipal, origin); - if (NS_FAILED(rv)) { - return rv; - } - if (!mOrigins.Contains(origin)) { - mOrigins.PutEntry(origin); - } - return NS_OK; -} - -NS_IMETHODIMP -NotificationTelemetryService::Observe(nsISupports* aSubject, - const char* aTopic, - const char16_t* aData) -{ - /* STUB */ - 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 @@ -1402,8 +1235,6 @@ NotificationObserver::Observe(nsISupports* aSubject, const char* aTopic, return NS_OK; } else if (!strcmp("alertshow", aTopic) || !strcmp("alertfinished", aTopic)) { - RefPtr telemetry = - NotificationTelemetryService::GetInstance(); Unused << NS_WARN_IF(NS_FAILED(AdjustPushQuota(aTopic))); } diff --git a/dom/notification/Notification.h b/dom/notification/Notification.h index a2c4b5c68..11958f6ad 100644 --- a/dom/notification/Notification.h +++ b/dom/notification/Notification.h @@ -18,9 +18,6 @@ #include "nsTHashtable.h" #include "nsWeakReference.h" -#define NOTIFICATIONTELEMETRYSERVICE_CONTRACTID \ - "@mozilla.org/notificationTelemetryService;1" - class nsIPrincipal; class nsIVariant; @@ -49,36 +46,6 @@ public: 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 nsIObserver -{ -public: - NS_DECL_ISUPPORTS - NS_DECL_NSIOBSERVER - - NotificationTelemetryService(); - - static already_AddRefed GetInstance(); - - nsresult Init(); - void RecordDNDSupported(); - void RecordPermissions(); - nsresult RecordSender(nsIPrincipal* aPrincipal); - -private: - virtual ~NotificationTelemetryService(); - - nsresult AddPermissionChangeObserver(); - nsresult RemovePermissionChangeObserver(); - - bool GetNotificationPermission(nsISupports* aSupports, - uint32_t* aCapability); - - bool mDNDRecorded; - nsTHashtable mOrigins; -}; - /* * Notifications on workers introduce some lifetime issues. The property we * are trying to satisfy is: @@ -143,7 +110,6 @@ class Notification : public DOMEventTargetHelper friend class ServiceWorkerNotificationObserver; friend class WorkerGetRunnable; friend class WorkerNotificationObserver; - friend class NotificationTelemetryService; public: IMPL_EVENT_HANDLER(click) -- cgit v1.2.3