Verified Commit 67ac4951 authored by Andrea Marchesini's avatar Andrea Marchesini Committed by ma1
Browse files

Bug 2048353 - Improve worker shutdown support in...

Bug 2048353 - Improve worker shutdown support in CookieStoreNotificationWatcher   a=diannaS DONTBUILD

Original Revision: https://phabricator.services.mozilla.com/D311765

Differential Revision: https://phabricator.services.mozilla.com/D314995
parent 4c1edd7e
Loading
Loading
Loading
Loading
+6 −8
Original line number Diff line number Diff line
@@ -99,13 +99,13 @@ void CookieStoreNotificationWatcherWrapper::ResolvePromiseWhenNotified(
          mEventTarget(GetCurrentSerialEventTarget()) {}

    NS_IMETHOD Run() override {
      if (mPromise) {
        mPromise->MaybeResolveWithUndefined();
        mPromise = nullptr;
      }
      return NS_OK;
    }

    bool HasPromise() const { return !!mPromise; }

   private:
    ~PromiseResolver() {
      NS_ProxyRelease(
@@ -140,10 +140,8 @@ void CookieStoreNotificationWatcherWrapper::ResolvePromiseWhenNotified(
  auto callback = [resolver = RefPtr(resolver),
                   eventTarget = RefPtr(GetCurrentSerialEventTarget()),
                   workerRef = RefPtr(workerRef)] {
    if (resolver->HasPromise()) {
    RefPtr<Runnable> runnable(resolver);
    eventTarget->Dispatch(runnable.forget());
    }
  };

  if (!NS_IsMainThread()) {