Bug 1251045 part 8. Remove the JSContext argument from some nsINotificationStorageCallback methods. r=khuey
authorBoris Zbarsky <bzbarsky@mit.edu>
Fri, 26 Feb 2016 15:23:12 -0500
changeset 324109 5df0d723ab90b531edb68a11109b973db1dd04c8
parent 324108 1870eb804a6d2057d7ea74e14e6c8e5f6d7045ac
child 324110 0685962294de623d50bcbef680ab730814308f2e
push id1128
push userjlund@mozilla.com
push dateWed, 01 Jun 2016 01:31:59 +0000
treeherdermozilla-release@fe0d30de989d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskhuey
bugs1251045
milestone47.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 1251045 part 8. Remove the JSContext argument from some nsINotificationStorageCallback methods. r=khuey
dom/interfaces/notification/nsINotificationStorage.idl
dom/notification/Notification.cpp
--- a/dom/interfaces/notification/nsINotificationStorage.idl
+++ b/dom/interfaces/notification/nsINotificationStorage.idl
@@ -14,33 +14,31 @@ interface nsINotificationStorageCallback
    * @param id: a uuid for this notification
    * @param title: the notification title
    * @param dir: the notification direction,
    *             possible values are "ltr", "rtl", "auto"
    * @param lang: the notification language
    * @param body: the notification body
    * @param tag: the notification tag
    */
-  [implicit_jscontext]
   void handle(in DOMString id,
               in DOMString title,
               in DOMString dir,
               in DOMString lang,
               in DOMString body,
               in DOMString tag,
               in DOMString icon,
               in DOMString data,
               in DOMString behavior,
               in DOMString serviceWorkerRegistrationID);
 
   /**
    * Callback function used to notify C++ the we have returned
    * all notification objects for this Notification.get call.
    */
-  [implicit_jscontext]
   void done();
 };
 
 /**
  * Interface for notification persistence layer.
  */
 [scriptable, uuid(17f85e52-fe57-440e-9ba1-5c312ca02b95)]
 interface nsINotificationStorage : nsISupports
--- a/dom/notification/Notification.cpp
+++ b/dom/notification/Notification.cpp
@@ -92,18 +92,17 @@ public:
                     const nsAString& aTitle,
                     const nsAString& aDir,
                     const nsAString& aLang,
                     const nsAString& aBody,
                     const nsAString& aTag,
                     const nsAString& aIcon,
                     const nsAString& aData,
                     const nsAString& aBehavior,
-                    const nsAString& aServiceWorkerRegistrationID,
-                    JSContext* aCx) final
+                    const nsAString& aServiceWorkerRegistrationID) final
   {
     AssertIsOnMainThread();
     MOZ_ASSERT(!aID.IsEmpty());
 
     // Skip scopes that don't match when called from getNotifications().
     if (!mScope.IsEmpty() && !mScope.Equals(aServiceWorkerRegistrationID)) {
       return NS_OK;
     }
@@ -120,17 +119,17 @@ public:
       nsString(aBehavior),
       nsString(aServiceWorkerRegistrationID),
     };
 
     mStrings.AppendElement(Move(strings));
     return NS_OK;
   }
 
-  NS_IMETHOD Done(JSContext* aCx) override = 0;
+  NS_IMETHOD Done() override = 0;
 
 protected:
   virtual ~ScopeCheckingGetCallback()
   {}
 
   nsTArray<NotificationStrings> mStrings;
 };
 
@@ -146,22 +145,18 @@ public:
       mWindow(aWindow),
       mPromise(aPromise)
   {
     AssertIsOnMainThread();
     MOZ_ASSERT(aWindow);
     MOZ_ASSERT(aPromise);
   }
 
-  NS_IMETHOD Done(JSContext* aCx) final
+  NS_IMETHOD Done() final
   {
-    AutoJSAPI jsapi;
-    DebugOnly<bool> ok = jsapi.Init(mWindow, aCx);
-    MOZ_ASSERT(ok);
-
     ErrorResult result;
     AutoTArray<RefPtr<Notification>, 5> notifications;
 
     for (uint32_t i = 0; i < mStrings.Length(); ++i) {
       RefPtr<Notification> n =
         Notification::ConstructFromFields(mWindow,
                                           mStrings[i].mID,
                                           mStrings[i].mTitle,
@@ -1574,18 +1569,17 @@ public:
                     const nsAString& aTitle,
                     const nsAString& aDir,
                     const nsAString& aLang,
                     const nsAString& aBody,
                     const nsAString& aTag,
                     const nsAString& aIcon,
                     const nsAString& aData,
                     const nsAString& aBehavior,
-                    const nsAString& aServiceWorkerRegistrationID,
-                    JSContext* aCx) override
+                    const nsAString& aServiceWorkerRegistrationID) override
   {
     MOZ_ASSERT(!aID.IsEmpty());
     MOZ_ASSERT(mScope.Equals(aServiceWorkerRegistrationID));
 
     AssertIsOnMainThread();
 
     nsAutoCString originSuffix;
     nsresult rv = mPrincipal->GetOriginSuffix(originSuffix);
@@ -1607,17 +1601,17 @@ public:
                                       aTag,
                                       aIcon,
                                       aData,
                                       aBehavior);
     }
     return NS_OK;
   }
 
-  NS_IMETHOD Done(JSContext* aCx) override
+  NS_IMETHOD Done() override
   {
     return NS_OK;
   }
 
 private:
   ~NotificationClickEventCallback()
   {
   }
@@ -2128,17 +2122,17 @@ public:
 
   WorkerGetCallback(PromiseWorkerProxy* aProxy, const nsAString& aScope)
     : ScopeCheckingGetCallback(aScope), mPromiseProxy(aProxy)
   {
     AssertIsOnMainThread();
     MOZ_ASSERT(aProxy);
   }
 
-  NS_IMETHOD Done(JSContext* aCx) final
+  NS_IMETHOD Done() final
   {
     AssertIsOnMainThread();
     MOZ_ASSERT(mPromiseProxy, "Was Done() called twice?");
 
     RefPtr<PromiseWorkerProxy> proxy = mPromiseProxy.forget();
     MutexAutoLock lock(proxy->Lock());
     if (proxy->CleanedUp()) {
       return NS_OK;
@@ -2176,44 +2170,41 @@ public:
 
   NS_IMETHOD
   Run() override
   {
     AssertIsOnMainThread();
     nsCOMPtr<nsINotificationStorageCallback> callback =
       new WorkerGetCallback(mPromiseProxy, mScope);
 
-    AutoJSAPI jsapi;
-    jsapi.Init();
-
     nsresult rv;
     nsCOMPtr<nsINotificationStorage> notificationStorage =
       do_GetService(NS_NOTIFICATION_STORAGE_CONTRACTID, &rv);
     if (NS_WARN_IF(NS_FAILED(rv))) {
-      callback->Done(jsapi.cx());
+      callback->Done();
       return rv;
     }
 
     MutexAutoLock lock(mPromiseProxy->Lock());
     if (mPromiseProxy->CleanedUp()) {
       return NS_OK;
     }
 
     nsString origin;
     rv =
       Notification::GetOrigin(mPromiseProxy->GetWorkerPrivate()->GetPrincipal(),
                               origin);
     if (NS_WARN_IF(NS_FAILED(rv))) {
-      callback->Done(jsapi.cx());
+      callback->Done();
       return rv;
     }
 
     rv = notificationStorage->Get(origin, mTag, callback);
     if (NS_WARN_IF(NS_FAILED(rv))) {
-      callback->Done(jsapi.cx());
+      callback->Done();
       return rv;
     }
 
     return NS_OK;
   }
 private:
   ~WorkerGetRunnable()
   {}