Bug 1408333 Get rid of nsIIPCBackgroundChildCreateCallback - part 6 - AsmJS, r=asuth
authorAndrea Marchesini <amarchesini@mozilla.com>
Tue, 24 Oct 2017 12:02:40 +0200
changeset 438589 9742e854761a55a851331e9a9c1924c714eea204
parent 438588 b64ffa1024fc39d52f0963ac172a9687534821db
child 438590 d7b3c828ed45ce0fc47ebdcc12bb55ce9344ebae
push id8114
push userjlorenzo@mozilla.com
push dateThu, 02 Nov 2017 16:33:21 +0000
treeherdermozilla-beta@73e0d89a540f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersasuth
bugs1408333
milestone58.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 1408333 Get rid of nsIIPCBackgroundChildCreateCallback - part 6 - AsmJS, r=asuth
dom/asmjscache/AsmJSCache.cpp
--- a/dom/asmjscache/AsmJSCache.cpp
+++ b/dom/asmjscache/AsmJSCache.cpp
@@ -25,17 +25,16 @@
 #include "mozilla/ipc/BackgroundChild.h"
 #include "mozilla/ipc/BackgroundParent.h"
 #include "mozilla/ipc/BackgroundUtils.h"
 #include "mozilla/ipc/PBackgroundChild.h"
 #include "mozilla/Unused.h"
 #include "nsAutoPtr.h"
 #include "nsAtom.h"
 #include "nsIFile.h"
-#include "nsIIPCBackgroundChildCreateCallback.h"
 #include "nsIPrincipal.h"
 #include "nsIRunnable.h"
 #include "nsISimpleEnumerator.h"
 #include "nsIThread.h"
 #include "nsJSPrincipals.h"
 #include "nsThreadUtils.h"
 #include "nsXULAppAPI.h"
 #include "prio.h"
@@ -1057,17 +1056,16 @@ DeallocEntryParent(PAsmJSCacheEntryParen
 
 namespace {
 
 // A runnable that presents a single interface to the AsmJSCache ops which need
 // to wait until the file is open.
 class ChildRunnable final
   : public FileDescriptorHolder
   , public PAsmJSCacheEntryChild
-  , public nsIIPCBackgroundChildCreateCallback
 {
   typedef mozilla::ipc::PBackgroundChild PBackgroundChild;
 
 public:
   class AutoClose
   {
     ChildRunnable* mChildRunnable;
 
@@ -1100,19 +1098,17 @@ public:
     ~AutoClose()
     {
       if (mChildRunnable) {
         mChildRunnable->Close();
       }
     }
   };
 
-  NS_DECL_ISUPPORTS_INHERITED
   NS_DECL_NSIRUNNABLE
-  NS_DECL_NSIIPCBACKGROUNDCHILDCREATECALLBACK
 
   ChildRunnable(nsIPrincipal* aPrincipal,
                 OpenMode aOpenMode,
                 WriteParams aWriteParams,
                 ReadParams aReadParams)
   : mPrincipal(aPrincipal),
     mWriteParams(aWriteParams),
     mReadParams(aReadParams),
@@ -1316,28 +1312,35 @@ ChildRunnable::Run()
       nsresult rv = PrincipalToPrincipalInfo(mPrincipal, principalInfo);
       if (NS_WARN_IF(NS_FAILED(rv))) {
         Fail(JS::AsmJSCache_InternalError);
         return NS_OK;
       }
 
       mPrincipalInfo = Move(principalInfo);
 
-      PBackgroundChild* actor = BackgroundChild::GetForCurrentThread();
-      if (actor) {
-        ActorCreated(actor);
-        return NS_OK;
-      }
-
-      if (NS_WARN_IF(!BackgroundChild::GetOrCreateForCurrentThread(this))) {
+      PBackgroundChild* actor = BackgroundChild::GetOrCreateForCurrentThread();
+      if (NS_WARN_IF(!actor)) {
         Fail(JS::AsmJSCache_InternalError);
         return NS_OK;
       }
 
-      mState = eBackgroundChildPending;
+      if (!actor->SendPAsmJSCacheEntryConstructor(this, mOpenMode, mWriteParams,
+                                                   *mPrincipalInfo)) {
+        // Unblock the parsing thread with a failure.
+
+        Fail(JS::AsmJSCache_InternalError);
+        return NS_OK;
+      }
+
+      // AddRef to keep this runnable alive until IPDL deallocates the
+      // subprotocol (DeallocEntryChild).
+      AddRef();
+
+      mState = eOpening;
       return NS_OK;
     }
 
     case eClosing: {
       MOZ_ASSERT(NS_IsMainThread());
 
       // Per FileDescriptorHolder::Finish()'s comment, call before
       // releasing the directory lock (which happens in the parent upon receipt
@@ -1367,50 +1370,16 @@ ChildRunnable::Run()
       MOZ_MAKE_COMPILER_ASSUME_IS_UNREACHABLE("Shouldn't Run() in this state");
     }
   }
 
   MOZ_MAKE_COMPILER_ASSUME_IS_UNREACHABLE("Corrupt state");
   return NS_OK;
 }
 
-void
-ChildRunnable::ActorCreated(PBackgroundChild* aActor)
-{
-  MOZ_ASSERT(NS_IsMainThread());
-
-  if (!aActor->SendPAsmJSCacheEntryConstructor(this, mOpenMode, mWriteParams,
-                                               *mPrincipalInfo)) {
-    // Unblock the parsing thread with a failure.
-
-    Fail(JS::AsmJSCache_InternalError);
-
-    return;
-  }
-
-  // AddRef to keep this runnable alive until IPDL deallocates the
-  // subprotocol (DeallocEntryChild).
-  AddRef();
-
-  mState = eOpening;
-}
-
-void
-ChildRunnable::ActorFailed()
-{
-  MOZ_ASSERT(NS_IsMainThread());
-  MOZ_ASSERT(mState == eBackgroundChildPending);
-
-  Fail(JS::AsmJSCache_InternalError);
-}
-
-NS_IMPL_ISUPPORTS_INHERITED(ChildRunnable,
-                            FileDescriptorHolder,
-                            nsIIPCBackgroundChildCreateCallback)
-
 } // unnamed namespace
 
 void
 DeallocEntryChild(PAsmJSCacheEntryChild* aActor)
 {
   // Match the AddRef before SendPAsmJSCacheEntryConstructor.
   static_cast<ChildRunnable*>(aActor)->Release();
 }