diff --git a/dom/serviceworkers/ServiceWorkerRegistration.cpp b/dom/serviceworkers/ServiceWorkerRegistration.cpp index c5886ee470a5..60b7810af1ac 100644 --- a/dom/serviceworkers/ServiceWorkerRegistration.cpp +++ b/dom/serviceworkers/ServiceWorkerRegistration.cpp @@ -334,11 +334,26 @@ already_AddRefed ServiceWorkerRegistration::GetNotifications(const GetNotificationOptions& aOptions, ErrorResult& aRv) { - if (!mInner) { + nsIGlobalObject* global = GetParentObject(); + if (!global) { aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR); return nullptr; } - return mInner->GetNotifications(aOptions, aRv); + + NS_ConvertUTF8toUTF16 scope(mDescriptor.Scope()); + + if (NS_IsMainThread()) { + nsCOMPtr window = do_QueryInterface(global); + if (NS_WARN_IF(!window)) { + aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR); + return nullptr; + } + return Notification::Get(window, aOptions, scope, aRv); + } + + WorkerPrivate* worker = GetCurrentThreadWorkerPrivate(); + worker->AssertIsOnWorkerThread(); + return Notification::WorkerGet(worker, aOptions, scope, aRv); } } // dom namespace diff --git a/dom/serviceworkers/ServiceWorkerRegistration.h b/dom/serviceworkers/ServiceWorkerRegistration.h index 150293f7c068..709c9e7013ab 100644 --- a/dom/serviceworkers/ServiceWorkerRegistration.h +++ b/dom/serviceworkers/ServiceWorkerRegistration.h @@ -49,10 +49,6 @@ public: virtual RefPtr Unregister() = 0; - - virtual already_AddRefed - GetNotifications(const GetNotificationOptions& aOptions, - ErrorResult& aRv) = 0; }; NS_DECLARE_STATIC_IID_ACCESSOR(NS_DOM_SERVICEWORKERREGISTRATION_IID) diff --git a/dom/serviceworkers/ServiceWorkerRegistrationImpl.cpp b/dom/serviceworkers/ServiceWorkerRegistrationImpl.cpp index c4f7f3c48e05..80778d6c971a 100644 --- a/dom/serviceworkers/ServiceWorkerRegistrationImpl.cpp +++ b/dom/serviceworkers/ServiceWorkerRegistrationImpl.cpp @@ -8,7 +8,6 @@ #include "ipc/ErrorIPCUtils.h" #include "mozilla/dom/DOMPrefs.h" -#include "mozilla/dom/Notification.h" #include "mozilla/dom/Promise.h" #include "mozilla/dom/PromiseWorkerProxy.h" #include "mozilla/dom/PushManagerBinding.h" @@ -572,20 +571,6 @@ ServiceWorkerRegistrationMainThread::Unregister() return cb->Promise(); } -already_AddRefed -ServiceWorkerRegistrationMainThread::GetNotifications(const GetNotificationOptions& aOptions, ErrorResult& aRv) -{ - MOZ_ASSERT(NS_IsMainThread()); - MOZ_DIAGNOSTIC_ASSERT(mOuter); - - nsCOMPtr window = mOuter->GetOwner(); - if (NS_WARN_IF(!window)) { - aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR); - return nullptr; - } - return Notification::Get(window, aOptions, mScope, aRv); -} - //////////////////////////////////////////////////// // Worker Thread implementation @@ -955,14 +940,6 @@ WorkerListener::RegistrationRemoved() mRegistration->RegistrationRemoved(); } -already_AddRefed -ServiceWorkerRegistrationWorkerThread::GetNotifications(const GetNotificationOptions& aOptions, - ErrorResult& aRv) -{ - MOZ_ASSERT(mWorkerRef && mWorkerRef->GetPrivate()); - return Notification::WorkerGet(mWorkerRef->GetPrivate(), aOptions, mScope, aRv); -} - void ServiceWorkerRegistrationWorkerThread::UpdateFound() { diff --git a/dom/serviceworkers/ServiceWorkerRegistrationImpl.h b/dom/serviceworkers/ServiceWorkerRegistrationImpl.h index 2098ae988008..77d0c205f730 100644 --- a/dom/serviceworkers/ServiceWorkerRegistrationImpl.h +++ b/dom/serviceworkers/ServiceWorkerRegistrationImpl.h @@ -48,10 +48,6 @@ public: RefPtr Unregister() override; - already_AddRefed - GetNotifications(const GetNotificationOptions& aOptions, - ErrorResult& aRv) override; - // ServiceWorkerRegistrationListener void UpdateFound() override; @@ -119,10 +115,6 @@ public: RefPtr Unregister() override; - already_AddRefed - GetNotifications(const GetNotificationOptions& aOptions, - ErrorResult& aRv) override; - void UpdateFound();