Bug 1455695 P2 Remove ServiceWorkerRegistration::Inner::GetPushManager(). r=baku
authorBen Kelly <ben@wanderview.com>
Mon, 30 Apr 2018 07:55:01 -0700
changeset 472405 8f25c38c4fd68b8b424e020eaeba1b7c780c790b
parent 472404 cd48fe9eb3dd3cc05b5662e9a5d861846ae47f89
child 472406 c21114e606e2d492a2477c9461619ee66f8d8987
push id1728
push userjlund@mozilla.com
push dateMon, 18 Jun 2018 21:12:27 +0000
treeherdermozilla-release@c296fde26f5f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbaku
bugs1455695
milestone61.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 1455695 P2 Remove ServiceWorkerRegistration::Inner::GetPushManager(). r=baku
dom/serviceworkers/ServiceWorkerRegistration.cpp
dom/serviceworkers/ServiceWorkerRegistration.h
dom/serviceworkers/ServiceWorkerRegistrationImpl.cpp
dom/serviceworkers/ServiceWorkerRegistrationImpl.h
--- a/dom/serviceworkers/ServiceWorkerRegistration.cpp
+++ b/dom/serviceworkers/ServiceWorkerRegistration.cpp
@@ -269,26 +269,34 @@ ServiceWorkerRegistration::Unregister(Er
     })->Track(*holder);
 
   return outer.forget();
 }
 
 already_AddRefed<PushManager>
 ServiceWorkerRegistration::GetPushManager(JSContext* aCx, ErrorResult& aRv)
 {
-  if (!mInner) {
-    aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
-    return nullptr;
-  }
   if (!mPushManager) {
-    mPushManager = mInner->GetPushManager(aCx, aRv);
+    nsCOMPtr<nsIGlobalObject> globalObject = GetParentObject();
+
+    if (!globalObject) {
+      aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
+      return nullptr;
+    }
+
+    GlobalObject global(aCx, globalObject->GetGlobalJSObject());
+    mPushManager =
+      PushManager::Constructor(global,
+                               NS_ConvertUTF8toUTF16(mDescriptor.Scope()),
+                               aRv);
     if (aRv.Failed()) {
       return nullptr;
     }
   }
+
   RefPtr<PushManager> ret = mPushManager;
   return ret.forget();
 }
 
 already_AddRefed<Promise>
 ServiceWorkerRegistration::ShowNotification(JSContext* aCx,
                                             const nsAString& aTitle,
                                             const NotificationOptions& aOptions,
--- a/dom/serviceworkers/ServiceWorkerRegistration.h
+++ b/dom/serviceworkers/ServiceWorkerRegistration.h
@@ -54,19 +54,16 @@ public:
     ShowNotification(JSContext* aCx,
                      const nsAString& aTitle,
                      const NotificationOptions& aOptions,
                      ErrorResult& aRv) = 0;
 
     virtual already_AddRefed<Promise>
     GetNotifications(const GetNotificationOptions& aOptions,
                      ErrorResult& aRv) = 0;
-
-    virtual already_AddRefed<PushManager>
-    GetPushManager(JSContext* aCx, ErrorResult& aRv) = 0;
   };
 
   NS_DECLARE_STATIC_IID_ACCESSOR(NS_DOM_SERVICEWORKERREGISTRATION_IID)
   NS_DECL_ISUPPORTS_INHERITED
   NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(ServiceWorkerRegistration, DOMEventTargetHelper)
 
   IMPL_EVENT_HANDLER(updatefound)
 
--- a/dom/serviceworkers/ServiceWorkerRegistrationImpl.cpp
+++ b/dom/serviceworkers/ServiceWorkerRegistrationImpl.cpp
@@ -619,39 +619,16 @@ ServiceWorkerRegistrationMainThread::Get
   nsCOMPtr<nsPIDOMWindowInner> 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);
 }
 
-already_AddRefed<PushManager>
-ServiceWorkerRegistrationMainThread::GetPushManager(JSContext* aCx,
-                                                    ErrorResult& aRv)
-{
-  MOZ_ASSERT(NS_IsMainThread());
-  MOZ_DIAGNOSTIC_ASSERT(mOuter);
-
-  nsCOMPtr<nsIGlobalObject> globalObject = mOuter->GetParentObject();
-
-  if (!globalObject) {
-    aRv.Throw(NS_ERROR_FAILURE);
-    return nullptr;
-  }
-
-  GlobalObject global(aCx, globalObject->GetGlobalJSObject());
-  RefPtr<PushManager> ret = PushManager::Constructor(global, mScope, aRv);
-  if (aRv.Failed()) {
-    return nullptr;
-  }
-
-  return ret.forget();
-}
-
 ////////////////////////////////////////////////////
 // Worker Thread implementation
 
 class WorkerListener final : public ServiceWorkerRegistrationListener
 {
   const nsString mScope;
   bool mListeningForEvents;
 
@@ -1046,23 +1023,16 @@ ServiceWorkerRegistrationWorkerThread::S
 already_AddRefed<Promise>
 ServiceWorkerRegistrationWorkerThread::GetNotifications(const GetNotificationOptions& aOptions,
                                                         ErrorResult& aRv)
 {
   MOZ_ASSERT(mWorkerRef && mWorkerRef->GetPrivate());
   return Notification::WorkerGet(mWorkerRef->GetPrivate(), aOptions, mScope, aRv);
 }
 
-already_AddRefed<PushManager>
-ServiceWorkerRegistrationWorkerThread::GetPushManager(JSContext* aCx, ErrorResult& aRv)
-{
-  RefPtr<PushManager> ret = new PushManager(mScope);
-  return ret.forget();
-}
-
 void
 ServiceWorkerRegistrationWorkerThread::UpdateFound()
 {
   mOuter->DispatchTrustedEvent(NS_LITERAL_STRING("updatefound"));
 }
 
 WorkerPrivate*
 ServiceWorkerRegistrationWorkerThread::GetWorkerPrivate(const MutexAutoLock& aProofOfLock)
--- a/dom/serviceworkers/ServiceWorkerRegistrationImpl.h
+++ b/dom/serviceworkers/ServiceWorkerRegistrationImpl.h
@@ -53,19 +53,16 @@ public:
                    const nsAString& aTitle,
                    const NotificationOptions& aOptions,
                    ErrorResult& aRv) override;
 
   already_AddRefed<Promise>
   GetNotifications(const GetNotificationOptions& aOptions,
                    ErrorResult& aRv) override;
 
-  already_AddRefed<PushManager>
-  GetPushManager(JSContext* aCx, ErrorResult& aRv) override;
-
   // ServiceWorkerRegistrationListener
   void
   UpdateFound() override;
 
   void
   UpdateState(const ServiceWorkerRegistrationDescriptor& aDescriptor) override;
 
   void
@@ -133,19 +130,16 @@ public:
                    const nsAString& aTitle,
                    const NotificationOptions& aOptions,
                    ErrorResult& aRv) override;
 
   already_AddRefed<Promise>
   GetNotifications(const GetNotificationOptions& aOptions,
                    ErrorResult& aRv) override;
 
-  already_AddRefed<PushManager>
-  GetPushManager(JSContext* aCx, ErrorResult& aRv) override;
-
   void
   UpdateFound();
 
 private:
   ~ServiceWorkerRegistrationWorkerThread();
 
   void
   InitListener();