зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1591803 - Part 1: Remove the dead code in NotificationTelemetryService; r=johannh
Differential Revision: https://phabricator.services.mozilla.com/D50752 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
05b288d47f
Коммит
6b1d1d6821
|
@ -593,125 +593,6 @@ nsresult NotificationPermissionRequest::ResolvePromise() {
|
|||
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.
|
||||
|
@ -1184,13 +1065,6 @@ NotificationObserver::Observe(nsISupports* aSubject, const char* aTopic,
|
|||
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)));
|
||||
}
|
||||
|
||||
|
|
|
@ -19,9 +19,6 @@
|
|||
#include "nsTHashtable.h"
|
||||
#include "nsWeakReference.h"
|
||||
|
||||
#define NOTIFICATIONTELEMETRYSERVICE_CONTRACTID \
|
||||
"@mozilla.org/notificationTelemetryService;1"
|
||||
|
||||
class nsIPrincipal;
|
||||
class nsIVariant;
|
||||
|
||||
|
@ -34,29 +31,6 @@ 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:
|
||||
|
@ -120,7 +94,6 @@ class Notification : public DOMEventTargetHelper,
|
|||
friend class ServiceWorkerNotificationObserver;
|
||||
friend class WorkerGetRunnable;
|
||||
friend class WorkerNotificationObserver;
|
||||
friend class NotificationTelemetryService;
|
||||
|
||||
public:
|
||||
IMPL_EVENT_HANDLER(click)
|
||||
|
|
|
@ -305,13 +305,6 @@ Classes = [
|
|||
'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'],
|
||||
|
|
|
@ -13349,15 +13349,6 @@
|
|||
"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"],
|
||||
|
|
|
@ -1261,7 +1261,6 @@
|
|||
"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",
|
||||
|
|
Загрузка…
Ссылка в новой задаче