Backed out 15 changesets (bug 1070755, bug 998863) for e10s bustage
authorPhil Ringnalda <philringnalda@gmail.com>
Wed, 24 Dec 2014 18:28:45 -0800
changeset 221318 76d1641cf90bfa580bd04864f09c3a086bcf59f2
parent 221317 076d1d47d6019a023c6b79fd0c5dea190e374cbf
child 221319 477f46897b0b90fcd858787f76fb71899156c5b2
push id53317
push userphilringnalda@gmail.com
push dateThu, 25 Dec 2014 02:28:58 +0000
treeherdermozilla-inbound@76d1641cf90b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1070755, 998863
milestone37.0a1
backs out076d1d47d6019a023c6b79fd0c5dea190e374cbf
43819af59ca585003d595966ce48b80855e4bbef
5f587697ae637ffb32b20fdae20bd129b741d5d2
e2cf239e8572d93c0394f77621dba82d488c77fe
fe21b6b789ce47c7febd9454b49c0a145f680494
404f59f86edcd80b42e20b903be6a7f108c15620
5dd57abaf2b077e90f976d0f45f1f07b36e00587
6c1f006a03bca561a6388eda7710ca1c4b6d7bf1
9e69875e3667ae7467eccc2327e3c41b956670cb
c6b68f8f72ba18c71c9f676a0b2b3dbf47183c79
713799a7afe4f1b17e91b6b7ff558c415092dd49
4244d662787c43e9059f5a513747183d72ad57e4
ba058cc7a1b201ce8d6b05263fa4b35aa71fe1de
dabc69b0b09afcd78d20d812b943fd79f34777c8
18dad6d2e7cc7983d6d6e1db4015444f65e60b84
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
Backed out 15 changesets (bug 1070755, bug 998863) for e10s bustage CLOSED TREE Backed out changeset 076d1d47d601 (bug 1070755) Backed out changeset 43819af59ca5 (bug 998863) Backed out changeset 5f587697ae63 (bug 998863) Backed out changeset e2cf239e8572 (bug 998863) Backed out changeset fe21b6b789ce (bug 998863) Backed out changeset 404f59f86edc (bug 998863) Backed out changeset 5dd57abaf2b0 (bug 998863) Backed out changeset 6c1f006a03bc (bug 998863) Backed out changeset 9e69875e3667 (bug 998863) Backed out changeset c6b68f8f72ba (bug 998863) Backed out changeset 713799a7afe4 (bug 998863) Backed out changeset 4244d662787c (bug 998863) Backed out changeset ba058cc7a1b2 (bug 998863) Backed out changeset dabc69b0b09a (bug 998863) Backed out changeset 18dad6d2e7cc (bug 998863)
dom/ipc/ContentChild.cpp
dom/ipc/ContentChild.h
dom/ipc/PContent.ipdl
dom/plugins/base/nsJSNPRuntime.cpp
dom/plugins/base/nsJSNPRuntime.h
dom/plugins/base/nsNPAPIPluginInstance.cpp
dom/plugins/base/nsNPAPIPluginStreamListener.cpp
dom/plugins/base/nsNPAPIPluginStreamListener.h
dom/plugins/base/nsPluginHost.cpp
dom/plugins/base/nsPluginHost.h
dom/plugins/base/nsPluginInstanceOwner.cpp
dom/plugins/base/nsPluginInstanceOwner.h
dom/plugins/base/nsPluginStreamListenerPeer.cpp
dom/plugins/base/nsPluginStreamListenerPeer.h
dom/plugins/ipc/BrowserStreamChild.cpp
dom/plugins/ipc/BrowserStreamChild.h
dom/plugins/ipc/BrowserStreamParent.cpp
dom/plugins/ipc/BrowserStreamParent.h
dom/plugins/ipc/PBrowserStream.ipdl
dom/plugins/ipc/PPluginInstance.ipdl
dom/plugins/ipc/PPluginModule.ipdl
dom/plugins/ipc/PluginAsyncSurrogate.cpp
dom/plugins/ipc/PluginAsyncSurrogate.h
dom/plugins/ipc/PluginDataResolver.h
dom/plugins/ipc/PluginInstanceChild.cpp
dom/plugins/ipc/PluginInstanceChild.h
dom/plugins/ipc/PluginInstanceParent.cpp
dom/plugins/ipc/PluginInstanceParent.h
dom/plugins/ipc/PluginModuleChild.cpp
dom/plugins/ipc/PluginModuleChild.h
dom/plugins/ipc/PluginModuleParent.cpp
dom/plugins/ipc/PluginModuleParent.h
dom/plugins/ipc/PluginProcessParent.cpp
dom/plugins/ipc/PluginProcessParent.h
dom/plugins/ipc/PluginScriptableObjectChild.cpp
dom/plugins/ipc/PluginScriptableObjectParent.cpp
dom/plugins/ipc/PluginScriptableObjectParent.h
dom/plugins/ipc/moz.build
ipc/glue/GeckoChildProcessHost.cpp
ipc/glue/GeckoChildProcessHost.h
ipc/glue/MessageChannel.cpp
ipc/glue/MessageChannel.h
ipc/glue/WindowsMessageLoop.cpp
modules/libpref/init/all.js
toolkit/components/telemetry/Histograms.json
xpcom/base/ErrorList.h
--- a/dom/ipc/ContentChild.cpp
+++ b/dom/ipc/ContentChild.cpp
@@ -946,17 +946,17 @@ ContentChild::DeallocPCycleCollectWithLo
     // this point, so we shouldn't touch the actor in any case.
     return true;
 }
 
 mozilla::plugins::PPluginModuleParent*
 ContentChild::AllocPPluginModuleParent(mozilla::ipc::Transport* aTransport,
                                        base::ProcessId aOtherProcess)
 {
-    return plugins::PluginModuleContentParent::Initialize(aTransport, aOtherProcess);
+    return plugins::PluginModuleContentParent::Create(aTransport, aOtherProcess);
 }
 
 PContentBridgeChild*
 ContentChild::AllocPContentBridgeChild(mozilla::ipc::Transport* aTransport,
                                        base::ProcessId aOtherProcess)
 {
     return ContentBridgeChild::Create(aTransport, aOtherProcess);
 }
@@ -2465,31 +2465,16 @@ ContentChild::RecvGetProfile(nsCString* 
         *aProfile = nsCString(profile, strlen(profile));
         free(profile);
     } else {
         *aProfile = EmptyCString();
     }
     return true;
 }
 
-bool
-ContentChild::RecvLoadPluginResult(const uint32_t& aPluginId, const bool& aResult)
-{
-    plugins::PluginModuleContentParent::OnLoadPluginResult(aPluginId, aResult);
-    return true;
-}
-
-bool
-ContentChild::RecvAssociatePluginId(const uint32_t& aPluginId,
-                                    const base::ProcessId& aProcessId)
-{
-    plugins::PluginModuleContentParent::AssociatePluginId(aPluginId, aProcessId);
-    return true;
-}
-
 PBrowserOrId
 ContentChild::GetBrowserOrId(TabChild* aTabChild)
 {
     if (!aTabChild ||
         this == aTabChild->Manager()) {
         return PBrowserOrId(aTabChild);
     }
     else {
--- a/dom/ipc/ContentChild.h
+++ b/dom/ipc/ContentChild.h
@@ -355,21 +355,16 @@ public:
     void AddIdleObserver(nsIObserver* aObserver, uint32_t aIdleTimeInS);
     void RemoveIdleObserver(nsIObserver* aObserver, uint32_t aIdleTimeInS);
     virtual bool RecvNotifyIdleObserver(const uint64_t& aObserver,
                                         const nsCString& aTopic,
                                         const nsString& aData) MOZ_OVERRIDE;
 
     virtual bool RecvOnAppThemeChanged() MOZ_OVERRIDE;
 
-    virtual bool RecvAssociatePluginId(const uint32_t& aPluginId,
-                                       const base::ProcessId& aProcessId) MOZ_OVERRIDE;
-    virtual bool RecvLoadPluginResult(const uint32_t& aPluginId,
-                                      const bool& aResult) MOZ_OVERRIDE;
-
     virtual bool RecvStartProfiler(const uint32_t& aEntries,
                                    const double& aInterval,
                                    const nsTArray<nsCString>& aFeatures,
                                    const nsTArray<nsCString>& aThreadNameFilters) MOZ_OVERRIDE;
     virtual bool RecvStopProfiler() MOZ_OVERRIDE;
     virtual bool RecvGetProfile(nsCString* aProfile) MOZ_OVERRIDE;
 
 #ifdef ANDROID
--- a/dom/ipc/PContent.ipdl
+++ b/dom/ipc/PContent.ipdl
@@ -54,17 +54,16 @@ include "mozilla/dom/PContentBridgeParen
 include "mozilla/dom/indexedDB/SerializationHelpers.h";
 
 using GeoPosition from "nsGeoPositionIPCSerialiser.h";
 
 using struct ChromePackage from "mozilla/chrome/RegistryMessageUtils.h";
 using struct ResourceMapping from "mozilla/chrome/RegistryMessageUtils.h";
 using struct OverrideMapping from "mozilla/chrome/RegistryMessageUtils.h";
 using base::ChildPrivileges from "base/process_util.h";
-using base::ProcessId from "base/process.h";
 using struct IPC::Permission from "mozilla/net/NeckoMessageUtils.h";
 using class IPC::Principal from "mozilla/dom/PermissionMessageUtils.h";
 using struct mozilla::null_t from "ipc/IPCMessageUtils.h";
 using struct mozilla::void_t from "ipc/IPCMessageUtils.h";
 using mozilla::dom::asmjscache::OpenMode from "mozilla/dom/asmjscache/AsmJSCache.h";
 using mozilla::dom::asmjscache::WriteParams from "mozilla/dom/asmjscache/AsmJSCache.h";
 using mozilla::dom::AudioChannel from "mozilla/dom/AudioChannelBinding.h";
 using mozilla::dom::AudioChannelState from "AudioChannelCommon.h";
@@ -512,29 +511,16 @@ child:
     NotifyIdleObserver(uint64_t observerId, nsCString topic, nsString str);
 
     /**
      * Notify windows in the child to apply a new app style.
      */
     OnAppThemeChanged();
 
     /**
-     * Called during plugin initialization to map a plugin id to a child process
-     * id.
-     */
-    async AssociatePluginId(uint32_t aPluginId, ProcessId aProcessId);
-
-    /**
-     * This call is used by async plugin initialization to notify the
-     * PluginModuleContentParent that the PluginModuleChromeParent's async
-     * init has completed.
-     */
-    async LoadPluginResult(uint32_t aPluginId, bool aResult);
-
-    /**
      * Control the Gecko Profiler in the child process.
      */
     async StartProfiler(uint32_t aEntries, double aInterval, nsCString[] aFeatures,
                         nsCString[] aThreadNameFilters);
     async StopProfiler();
     prio(high) sync GetProfile()
       returns (nsCString aProfile);
 
--- a/dom/plugins/base/nsJSNPRuntime.cpp
+++ b/dom/plugins/base/nsJSNPRuntime.cpp
@@ -23,20 +23,17 @@
 #include "nsIDOMElement.h"
 #include "prmem.h"
 #include "nsIContent.h"
 #include "nsPluginInstanceOwner.h"
 #include "nsWrapperCacheInlines.h"
 #include "js/HashTable.h"
 #include "mozilla/HashFunctions.h"
 #include "mozilla/dom/ScriptSettings.h"
-#include "mozilla/plugins/PluginAsyncSurrogate.h"
-
-using mozilla::plugins::AsyncNPObject;
-using mozilla::plugins::PluginAsyncSurrogate;
+
 
 #define NPRUNTIME_JSCLASS_NAME "NPObject JS wrapper class"
 
 using namespace mozilla::plugins::parent;
 using namespace mozilla;
 
 #include "mozilla/plugins/PluginScriptableObjectParent.h"
 using mozilla::plugins::PluginScriptableObjectParent;
@@ -92,34 +89,20 @@ static int32_t sWrapperCount;
 
 // The runtime service used to register/unregister GC callbacks.
 nsCOMPtr<nsIJSRuntimeService> sCallbackRuntime;
 
 static nsTArray<NPObject*>* sDelayedReleases;
 
 namespace {
 
-inline void
-CastNPObject(NPObject *aObj, PluginScriptableObjectParent*& aActor,
-             PluginAsyncSurrogate*& aSurrogate)
-{
-  aActor = nullptr;
-  aSurrogate = nullptr;
-  if (aObj->_class == PluginScriptableObjectParent::GetClass()) {
-    aActor = static_cast<ParentNPObject*>(aObj)->parent;
-  } else if (aObj->_class == PluginAsyncSurrogate::GetClass()) {
-    aSurrogate = static_cast<AsyncNPObject*>(aObj)->mSurrogate;
-  }
-}
-
 inline bool
 NPObjectIsOutOfProcessProxy(NPObject *obj)
 {
-  return obj->_class == PluginScriptableObjectParent::GetClass() ||
-         obj->_class == PluginAsyncSurrogate::GetClass();
+  return obj->_class == PluginScriptableObjectParent::GetClass();
 }
 
 } // anonymous namespace
 
 // Helper class that reports any JS exceptions that were thrown while
 // the plugin executed JS.
 
 class AutoJSExceptionReporter
@@ -1401,33 +1384,25 @@ NPObjWrapper_GetProperty(JSContext *cx, 
   bool hasProperty, hasMethod;
 
   NPVariant npv;
   VOID_TO_NPVARIANT(npv);
 
   NPIdentifier identifier = JSIdToNPIdentifier(id);
 
   if (NPObjectIsOutOfProcessProxy(npobj)) {
-    PluginScriptableObjectParent* actor = nullptr;
-    PluginAsyncSurrogate* surrogate = nullptr;
-    CastNPObject(npobj, actor, surrogate);
-
-    // actor and surrogate may be null if the plugin crashed.
-    if (!actor && !surrogate)
+    PluginScriptableObjectParent* actor =
+      static_cast<ParentNPObject*>(npobj)->parent;
+
+    // actor may be null if the plugin crashed.
+    if (!actor)
       return false;
 
-    bool success = false;
-    if (surrogate) {
-      success = surrogate->GetPropertyHelper(npobj, identifier, &hasProperty,
-                                             &hasMethod, &npv);
-    } else if (actor) {
-      success = actor->GetPropertyHelper(identifier, &hasProperty, &hasMethod,
-                                         &npv);
-    }
-
+    bool success = actor->GetPropertyHelper(identifier, &hasProperty,
+                                            &hasMethod, &npv);
     if (!ReportExceptionIfPending(cx)) {
       if (success)
         _releasevariantvalue(&npv);
       return false;
     }
 
     if (success) {
       // We return NPObject Member class here to support ambiguous members.
@@ -2273,40 +2248,8 @@ NPObjectMember_Trace(JSTracer *trc, JSOb
   // There's no strong reference from our private data to the
   // NPObject, so make sure to mark the NPObject wrapper to keep the
   // NPObject alive as long as this NPObjectMember is alive.
   if (memberPrivate->npobjWrapper) {
     JS_CallObjectTracer(trc, &memberPrivate->npobjWrapper,
                         "NPObject Member => npobjWrapper");
   }
 }
-
-// static
-bool
-nsJSObjWrapper::HasOwnProperty(NPObject *npobj, NPIdentifier npid)
-{
-  NPP npp = NPPStack::Peek();
-  dom::AutoJSAPI jsapi;
-  if (NS_WARN_IF(!jsapi.InitWithLegacyErrorReporting(GetGlobalObject(npp)))) {
-    return false;
-  }
-  JSContext *cx = jsapi.cx();
-
-  if (!npobj) {
-    ThrowJSException(cx,
-                     "Null npobj in nsJSObjWrapper::NP_HasOwnProperty!");
-
-    return false;
-  }
-
-  nsJSObjWrapper *npjsobj = (nsJSObjWrapper *)npobj;
-  bool found, ok = false;
-
-  AutoJSExceptionReporter reporter(cx);
-  JS::Rooted<JSObject*> jsobj(cx, npjsobj->mJSObj);
-  JSAutoCompartment ac(cx, jsobj);
-
-  NS_ASSERTION(NPIdentifierIsInt(npid) || NPIdentifierIsString(npid),
-               "id must be either string or int!\n");
-  JS::Rooted<jsid> id(cx, NPIdentifierToJSId(npid));
-  ok = ::JS_AlreadyHasOwnPropertyById(cx, jsobj, id, &found);
-  return ok && found;
-}
--- a/dom/plugins/base/nsJSNPRuntime.h
+++ b/dom/plugins/base/nsJSNPRuntime.h
@@ -39,17 +39,16 @@ public:
 class nsJSObjWrapper : public NPObject
 {
 public:
   JS::Heap<JSObject *> mJSObj;
   const NPP mNpp;
 
   static NPObject *GetNewOrUsed(NPP npp, JSContext *cx,
                                 JS::Handle<JSObject*> obj);
-  static bool HasOwnProperty(NPObject* npobj, NPIdentifier npid);
 
 protected:
   explicit nsJSObjWrapper(NPP npp);
   ~nsJSObjWrapper();
 
   static NPObject * NP_Allocate(NPP npp, NPClass *aClass);
   static void NP_Deallocate(NPObject *obj);
   static void NP_Invalidate(NPObject *obj);
--- a/dom/plugins/base/nsNPAPIPluginInstance.cpp
+++ b/dom/plugins/base/nsNPAPIPluginInstance.cpp
@@ -518,17 +518,17 @@ nsNPAPIPluginInstance::Start()
   this, &mNPP, mimetype, mode, quirkParamLength, error));
 
   if (NS_FAILED(newResult) || error != NPERR_NO_ERROR) {
     mRunning = DESTROYED;
     nsJSNPRuntime::OnPluginDestroy(&mNPP);
     return NS_ERROR_FAILURE;
   }
 
-  return newResult;
+  return NS_OK;
 }
 
 nsresult nsNPAPIPluginInstance::SetWindow(NPWindow* window)
 {
   // NPAPI plugins don't want a SetWindow(nullptr).
   if (!window || RUNNING != mRunning)
     return NS_OK;
 
--- a/dom/plugins/base/nsNPAPIPluginStreamListener.cpp
+++ b/dom/plugins/base/nsNPAPIPluginStreamListener.cpp
@@ -326,95 +326,76 @@ nsNPAPIPluginStreamListener::OnStartBind
                           NS_PLUGIN_CALL_UNSAFE_TO_REENTER_GECKO);
   
   NPP_PLUGIN_LOG(PLUGIN_LOG_NORMAL,
                  ("NPP NewStream called: this=%p, npp=%p, mime=%s, seek=%d, type=%d, return=%d, url=%s\n",
                   this, npp, (char *)contentType, seekable, streamType, error, mNPStreamWrapper->mNPStream.url));
   
   if (error != NPERR_NO_ERROR)
     return NS_ERROR_FAILURE;
-
-  if (streamType == nsPluginStreamListenerPeer::STREAM_TYPE_UNKNOWN) {
-    SuspendRequest();
-  } else if (!SetStreamType(streamType, false)) {
-    return NS_ERROR_FAILURE;
-  }
-
-  return NS_OK;
-}
-
-bool
-nsNPAPIPluginStreamListener::SetStreamType(uint16_t aType, bool aNeedsResume)
-{
-  switch(aType)
+  
+  switch(streamType)
   {
     case NP_NORMAL:
-      mStreamType = NP_NORMAL;
+      mStreamType = NP_NORMAL; 
       break;
     case NP_ASFILEONLY:
-      mStreamType = NP_ASFILEONLY;
+      mStreamType = NP_ASFILEONLY; 
       break;
     case NP_ASFILE:
-      mStreamType = NP_ASFILE;
+      mStreamType = NP_ASFILE; 
       break;
     case NP_SEEK:
-      mStreamType = NP_SEEK;
+      mStreamType = NP_SEEK; 
       // Seekable streams should continue to exist even after OnStopRequest
       // is fired, so we AddRef ourself an extra time and Release when the
       // plugin calls NPN_DestroyStream (CleanUpStream). If the plugin never
       // calls NPN_DestroyStream the stream will be destroyed before the plugin
       // instance is destroyed.
       NS_ADDREF_THIS();
       break;
     default:
-      return false;
+      return NS_ERROR_FAILURE;
   }
+  
   mStreamStarted = true;
-  if (aNeedsResume) {
-    if (mStreamListenerPeer) {
-      mStreamListenerPeer->OnStreamTypeSet(mStreamType);
-    }
-    ResumeRequest();
-  }
-  return true;
+  return NS_OK;
 }
 
 void
 nsNPAPIPluginStreamListener::SuspendRequest()
 {
   NS_ASSERTION(!mIsSuspended,
                "Suspending a request that's already suspended!");
 
   nsresult rv = StartDataPump();
   if (NS_FAILED(rv))
     return;
-
+  
   mIsSuspended = true;
 
   if (mStreamListenerPeer) {
-    mStreamListenerPeer->SuspendRequests();
+   mStreamListenerPeer->SuspendRequests();
   }
 }
 
 void
 nsNPAPIPluginStreamListener::ResumeRequest()
 {
-  if (mStreamListenerPeer) {
-    mStreamListenerPeer->ResumeRequests();
-  }
+  mStreamListenerPeer->ResumeRequests();
   mIsSuspended = false;
 }
 
 nsresult
 nsNPAPIPluginStreamListener::StartDataPump()
 {
   nsresult rv;
   mDataPumpTimer = do_CreateInstance("@mozilla.org/timer;1", &rv);
   NS_ENSURE_SUCCESS(rv, rv);
-
+  
   // Start pumping data to the plugin every 100ms until it obeys and
   // eats the data.
   return mDataPumpTimer->InitWithCallback(this, 100,
                                           nsITimer::TYPE_REPEATING_SLACK);
 }
 
 void
 nsNPAPIPluginStreamListener::StopDataPump()
--- a/dom/plugins/base/nsNPAPIPluginStreamListener.h
+++ b/dom/plugins/base/nsNPAPIPluginStreamListener.h
@@ -78,17 +78,16 @@ public:
   nsresult OnDataAvailable(nsPluginStreamListenerPeer* streamPeer,
                            nsIInputStream* input,
                            uint32_t length);
   nsresult OnFileAvailable(nsPluginStreamListenerPeer* streamPeer, 
                            const char* fileName);
   nsresult OnStopBinding(nsPluginStreamListenerPeer* streamPeer, 
                          nsresult status);
   nsresult GetStreamType(int32_t *result);
-  bool SetStreamType(uint16_t aType, bool aNeedsResume = true);
 
   bool IsStarted();
   nsresult CleanUpStream(NPReason reason);
   void CallURLNotify(NPReason reason);
   void SetCallNotify(bool aCallNotify) { mCallNotify = aCallNotify; }
   void SuspendRequest();
   void ResumeRequest();
   nsresult StartDataPump();
--- a/dom/plugins/base/nsPluginHost.cpp
+++ b/dom/plugins/base/nsPluginHost.cpp
@@ -45,17 +45,16 @@
 #include "nsIBlocklistService.h"
 #include "nsVersionComparator.h"
 #include "nsIObjectLoadingContent.h"
 #include "nsIWritablePropertyBag2.h"
 #include "nsICategoryManager.h"
 #include "nsPluginStreamListenerPeer.h"
 #include "mozilla/dom/ContentChild.h"
 #include "mozilla/LoadInfo.h"
-#include "mozilla/plugins/PluginAsyncSurrogate.h"
 #include "mozilla/plugins/PluginBridge.h"
 #include "mozilla/plugins/PluginTypes.h"
 #include "mozilla/Preferences.h"
 
 #include "nsEnumeratorUtils.h"
 #include "nsXPCOM.h"
 #include "nsXPCOMCID.h"
 #include "nsISupportsPrimitives.h"
@@ -106,17 +105,16 @@
 
 #if MOZ_CRASHREPORTER
 #include "nsExceptionHandler.h"
 #endif
 
 using namespace mozilla;
 using mozilla::TimeStamp;
 using mozilla::plugins::PluginTag;
-using mozilla::plugins::PluginAsyncSurrogate;
 
 // Null out a strong ref to a linked list iteratively to avoid
 // exhausting the stack (bug 486349).
 #define NS_ITERATIVE_UNREF_LIST(type_, list_, mNext_)                \
   {                                                                  \
     while (list_) {                                                  \
       type_ temp = list_->mNext_;                                    \
       list_->mNext_ = nullptr;                                        \
@@ -827,27 +825,28 @@ nsPluginHost::InstantiatePluginInstance(
       tagType != nsPluginTagType_Object) {
     return NS_ERROR_FAILURE;
   }
 
   rv = SetUpPluginInstance(aMimeType, aURL, instanceOwner);
   if (NS_FAILED(rv)) {
     return NS_ERROR_FAILURE;
   }
-  const bool isAsyncInit = (rv == NS_PLUGIN_INIT_PENDING);
 
   nsRefPtr<nsNPAPIPluginInstance> instance;
   rv = instanceOwner->GetInstance(getter_AddRefs(instance));
   if (NS_FAILED(rv)) {
     return rv;
   }
 
-  // Async init plugins will initiate their own widget creation.
-  if (!isAsyncInit && instance) {
-    CreateWidget(instanceOwner);
+  if (instance) {
+    instanceOwner->CreateWidget();
+
+    // If we've got a native window, the let the plugin know about it.
+    instanceOwner->CallSetWindow();
   }
 
   // At this point we consider instantiation to be successful. Do not return an error.
   instanceOwner.forget(aOwner);
 
 #ifdef PLUGIN_LOGGING
   nsAutoCString urlSpec2;
   if (aURL != nullptr) aURL->GetAsciiSpec(urlSpec2);
@@ -3323,24 +3322,16 @@ nsresult nsPluginHost::NewPluginStreamLi
     return rv;
   }
 
   listener.forget(aStreamListener);
 
   return NS_OK;
 }
 
-void nsPluginHost::CreateWidget(nsPluginInstanceOwner* aOwner)
-{
-  aOwner->CreateWidget();
-
-  // If we've got a native window, the let the plugin know about it.
-  aOwner->CallSetWindow();
-}
-
 NS_IMETHODIMP nsPluginHost::Observe(nsISupports *aSubject,
                                     const char *aTopic,
                                     const char16_t *someData)
 {
   if (!strcmp(NS_XPCOM_SHUTDOWN_OBSERVER_ID, aTopic)) {
     OnShutdown();
     UnloadPlugins();
     sInst->Release();
@@ -3958,22 +3949,16 @@ PRCList PluginDestructionGuard::sListHea
   PR_INIT_STATIC_CLIST(&PluginDestructionGuard::sListHead);
 
 PluginDestructionGuard::PluginDestructionGuard(nsNPAPIPluginInstance *aInstance)
   : mInstance(aInstance)
 {
   Init();
 }
 
-PluginDestructionGuard::PluginDestructionGuard(PluginAsyncSurrogate *aSurrogate)
-  : mInstance(static_cast<nsNPAPIPluginInstance*>(aSurrogate->GetNPP()->ndata))
-{
-  InitAsync();
-}
-
 PluginDestructionGuard::PluginDestructionGuard(NPP npp)
   : mInstance(npp ? static_cast<nsNPAPIPluginInstance*>(npp->ndata) : nullptr)
 {
   Init();
 }
 
 PluginDestructionGuard::~PluginDestructionGuard()
 {
--- a/dom/plugins/base/nsPluginHost.h
+++ b/dom/plugins/base/nsPluginHost.h
@@ -25,22 +25,16 @@
 #include "nsITimer.h"
 #include "nsPluginTags.h"
 #include "nsPluginPlayPreviewInfo.h"
 #include "nsIEffectiveTLDService.h"
 #include "nsIIDNService.h"
 #include "nsCRT.h"
 #include "mozilla/plugins/PluginTypes.h"
 
-namespace mozilla {
-namespace plugins {
-class PluginAsyncSurrogate;
-} // namespace mozilla
-} // namespace plugins
-
 class nsNPAPIPlugin;
 class nsIComponentManager;
 class nsIFile;
 class nsIChannel;
 class nsPluginNativeWindow;
 class nsObjectLoadingContent;
 class nsPluginInstanceOwner;
 class nsPluginUnloadRunnable;
@@ -204,18 +198,16 @@ public:
   nsresult GetPlugin(const char *aMimeType, nsNPAPIPlugin** aPlugin);
   nsresult GetPluginForContentProcess(uint32_t aPluginId, nsNPAPIPlugin** aPlugin);
   void NotifyContentModuleDestroyed(uint32_t aPluginId);
 
   nsresult NewPluginStreamListener(nsIURI* aURL,
                                    nsNPAPIPluginInstance* aInstance,
                                    nsIStreamListener **aStreamListener);
 
-  void CreateWidget(nsPluginInstanceOwner* aOwner);
-
 private:
   friend class nsPluginUnloadRunnable;
 
   nsresult
   TrySetUpPluginInstance(const char *aMimeType, nsIURI *aURL, nsPluginInstanceOwner *aOwner);
 
   nsPluginTag*
   FindPreferredPlugin(const InfallibleTArray<nsPluginTag*>& matches);
@@ -336,21 +328,21 @@ private:
 
   static nsIFile *sPluginTempDir;
 
   // We need to hold a global ptr to ourselves because we register for
   // two different CIDs for some reason...
   static nsPluginHost* sInst;
 };
 
-class PluginDestructionGuard : protected PRCList
+class MOZ_STACK_CLASS PluginDestructionGuard : protected PRCList
 {
 public:
   explicit PluginDestructionGuard(nsNPAPIPluginInstance *aInstance);
-  explicit PluginDestructionGuard(mozilla::plugins::PluginAsyncSurrogate *aSurrogate);
+
   explicit PluginDestructionGuard(NPP npp);
 
   ~PluginDestructionGuard();
 
   static bool DelayDestroy(nsNPAPIPluginInstance *aInstance);
 
 protected:
   void Init()
@@ -358,27 +350,15 @@ protected:
     NS_ASSERTION(NS_IsMainThread(), "Should be on the main thread");
 
     mDelayedDestroy = false;
 
     PR_INIT_CLIST(this);
     PR_INSERT_BEFORE(this, &sListHead);
   }
 
-  void InitAsync()
-  {
-    NS_ASSERTION(NS_IsMainThread(), "Should be on the main thread");
-
-    mDelayedDestroy = false;
-
-    PR_INIT_CLIST(this);
-    // Instances with active surrogates must be inserted *after* sListHead so
-    // that they appear to be at the bottom of the stack
-    PR_INSERT_AFTER(this, &sListHead);
-  }
-
   nsRefPtr<nsNPAPIPluginInstance> mInstance;
   bool mDelayedDestroy;
 
   static PRCList sListHead;
 };
 
 #endif // nsPluginHost_h_
--- a/dom/plugins/base/nsPluginInstanceOwner.cpp
+++ b/dom/plugins/base/nsPluginInstanceOwner.cpp
@@ -1447,38 +1447,16 @@ void nsPluginInstanceOwner::ExitFullScre
   if (sFullScreenInstance && sFullScreenInstance->mInstance &&
       env->IsSameObject(view, (jobject)sFullScreenInstance->mInstance->GetJavaSurface())) {
     sFullScreenInstance->ExitFullScreen();
   }
 }
 
 #endif
 
-void
-nsPluginInstanceOwner::NotifyHostAsyncInitFailed()
-{
-  nsCOMPtr<nsIObjectLoadingContent> content = do_QueryInterface(mContent);
-  content->StopPluginInstance();
-}
-
-void
-nsPluginInstanceOwner::NotifyHostCreateWidget()
-{
-  mPluginHost->CreateWidget(this);
-#ifdef XP_MACOSX
-  FixUpPluginWindow(ePluginPaintEnable);
-#else
-  if (mPluginFrame) {
-    mPluginFrame->InvalidateFrame();
-  } else {
-    CallSetWindow();
-  }
-#endif
-}
-
 nsresult nsPluginInstanceOwner::DispatchFocusToPlugin(nsIDOMEvent* aFocusEvent)
 {
 #ifdef MOZ_WIDGET_ANDROID
   if (mInstance) {
     ANPEvent event;
     event.inSize = sizeof(ANPEvent);
     event.eventType = kLifecycle_ANPEventType;
 
@@ -3186,20 +3164,16 @@ nsPluginInstanceOwner::UpdateDocumentAct
     mWidget->Enable(aIsActive);
   }
 #endif // #ifndef XP_MACOSX
 }
 
 NS_IMETHODIMP
 nsPluginInstanceOwner::CallSetWindow()
 {
-  if (!mWidgetCreationComplete) {
-    // No widget yet, we can't run this code
-    return NS_OK;
-  }
   if (mPluginFrame) {
     mPluginFrame->CallSetWindow(false);
   } else if (mInstance) {
     if (UseAsyncRendering()) {
       mInstance->AsyncSetWindow(mPluginWindow);
     } else {
       mInstance->SetWindow(mPluginWindow);
     }
--- a/dom/plugins/base/nsPluginInstanceOwner.h
+++ b/dom/plugins/base/nsPluginInstanceOwner.h
@@ -250,20 +250,17 @@ public:
   void Invalidate();
 
   void RequestFullScreen();
   void ExitFullScreen();
 
   // Called from AndroidJNI when we removed the fullscreen view.
   static void ExitFullScreen(jobject view);
 #endif
-
-  void NotifyHostAsyncInitFailed();
-  void NotifyHostCreateWidget();
-
+  
 private:
   virtual ~nsPluginInstanceOwner();
 
   // return FALSE if LayerSurface dirty (newly created and don't have valid plugin content yet)
   bool IsUpToDate()
   {
     nsIntSize size;
     return NS_SUCCEEDED(mInstance->GetImageSize(&size)) &&
--- a/dom/plugins/base/nsPluginStreamListenerPeer.cpp
+++ b/dom/plugins/base/nsPluginStreamListenerPeer.cpp
@@ -261,17 +261,16 @@ nsPluginStreamListenerPeer::nsPluginStre
   mStartBinding = false;
   mAbort = false;
   mRequestFailed = false;
 
   mPendingRequests = 0;
   mHaveFiredOnStartRequest = false;
   mDataForwardToRequest = nullptr;
 
-  mUseLocalCache = false;
   mSeekable = false;
   mModified = 0;
   mStreamOffset = 0;
   mStreamComplete = 0;
 }
 
 nsPluginStreamListenerPeer::~nsPluginStreamListenerPeer()
 {
@@ -529,19 +528,17 @@ nsPluginStreamListenerPeer::OnStartReque
          ("nsPluginStreamListenerPeer::OnStartRequest this=%p request=%p mime=%s, url=%s\n",
           this, request, aContentType.get(), mURLSpec.get()));
 
   PR_LogFlush();
 #endif
 
   // Set up the stream listener...
   rv = SetUpStreamListener(request, aURL);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
+  if (NS_FAILED(rv)) return rv;
 
   return rv;
 }
 
 NS_IMETHODIMP nsPluginStreamListenerPeer::OnProgress(nsIRequest *request,
                                                      nsISupports* aContext,
                                                      uint64_t aProgress,
                                                      uint64_t aProgressMax)
@@ -1044,16 +1041,18 @@ nsresult nsPluginStreamListenerPeer::Set
       return NS_ERROR_FAILURE;
     }
 
     mPStreamListener = static_cast<nsNPAPIPluginStreamListener*>(streamListener.get());
   }
 
   mPStreamListener->SetStreamListenerPeer(this);
 
+  bool useLocalCache = false;
+
   // get httpChannel to retrieve some info we need for nsIPluginStreamInfo setup
   nsCOMPtr<nsIChannel> channel = do_QueryInterface(request);
   nsCOMPtr<nsIHttpChannel> httpChannel = do_QueryInterface(channel);
 
   /*
    * Assumption
    * By the time nsPluginStreamListenerPeer::OnDataAvailable() gets
    * called, all the headers have been read.
@@ -1099,17 +1098,17 @@ nsresult nsPluginStreamListenerPeer::Set
     // uncompressed data, so it can't make meaningful range requests on a
     // compressed entity.  Also, we force the plugin to use
     // nsPluginStreamType_AsFile stream type and we have to save decompressed
     // file into local plugin cache, because necko cache contains original
     // compressed file.
     nsAutoCString contentEncoding;
     if (NS_SUCCEEDED(httpChannel->GetResponseHeader(NS_LITERAL_CSTRING("Content-Encoding"),
                                                     contentEncoding))) {
-      mUseLocalCache = true;
+      useLocalCache = true;
     } else {
       // set seekability (seekable if the stream has a known length and if the
       // http server accepts byte ranges).
       uint32_t length;
       GetLength(&length);
       if (length) {
         nsAutoCString range;
         if (NS_SUCCEEDED(httpChannel->GetResponseHeader(NS_LITERAL_CSTRING("accept-ranges"), range)) &&
@@ -1128,57 +1127,40 @@ nsresult nsPluginStreamListenerPeer::Set
       PR_ParseTimeString(lastModified.get(), true, &time64);  //convert string time to integer time
 
       // Convert PRTime to unix-style time_t, i.e. seconds since the epoch
       double fpTime = double(time64);
       mModified = (uint32_t)(fpTime * 1e-6 + 0.5);
     }
   }
 
-  MOZ_ASSERT(!mRequest);
-  mRequest = request;
-
   rv = mPStreamListener->OnStartBinding(this);
 
   mStartBinding = true;
 
   if (NS_FAILED(rv))
     return rv;
 
-  int32_t streamType = NP_NORMAL;
-  mPStreamListener->GetStreamType(&streamType);
+  mPStreamListener->GetStreamType(&mStreamType);
 
-  if (streamType != STREAM_TYPE_UNKNOWN) {
-    OnStreamTypeSet(streamType);
+  if (!useLocalCache && mStreamType >= NP_ASFILE) {
+    // check it out if this is not a file channel.
+    nsCOMPtr<nsIFileChannel> fileChannel = do_QueryInterface(request);
+    if (!fileChannel) {
+        useLocalCache = true;
+    }
+  }
+
+  if (useLocalCache) {
+    SetupPluginCacheFile(channel);
   }
 
   return NS_OK;
 }
 
-void
-nsPluginStreamListenerPeer::OnStreamTypeSet(const int32_t aStreamType)
-{
-  MOZ_ASSERT(mRequest);
-  mStreamType = aStreamType;
-  if (!mUseLocalCache && mStreamType >= NP_ASFILE) {
-    // check it out if this is not a file channel.
-    nsCOMPtr<nsIFileChannel> fileChannel = do_QueryInterface(mRequest);
-    if (!fileChannel) {
-      mUseLocalCache = true;
-    }
-  }
-
-  if (mUseLocalCache) {
-    nsCOMPtr<nsIChannel> channel = do_QueryInterface(mRequest);
-    SetupPluginCacheFile(channel);
-  }
-}
-
-const int32_t nsPluginStreamListenerPeer::STREAM_TYPE_UNKNOWN = UINT16_MAX;
-
 nsresult
 nsPluginStreamListenerPeer::OnFileAvailable(nsIFile* aFile)
 {
   nsresult rv;
   if (!mPStreamListener)
     return NS_ERROR_FAILURE;
 
   nsAutoCString path;
--- a/dom/plugins/base/nsPluginStreamListenerPeer.h
+++ b/dom/plugins/base/nsPluginStreamListenerPeer.h
@@ -123,21 +123,16 @@ public:
   }
 
   void ResumeRequests() {
     nsCOMArray<nsIRequest> requestsCopy(mRequests);
     for (int32_t i = 0; i < requestsCopy.Count(); ++i)
       requestsCopy[i]->Resume();
   }
 
-  // Called by nsNPAPIPluginStreamListener
-  void OnStreamTypeSet(const int32_t aStreamType);
-
-  static const int32_t STREAM_TYPE_UNKNOWN;
-
 private:
   nsresult SetUpStreamListener(nsIRequest* request, nsIURI* aURL);
   nsresult SetupPluginCacheFile(nsIChannel* channel);
   nsresult GetInterfaceGlobal(const nsIID& aIID, void** result);
 
   nsCOMPtr<nsIURI> mURL;
   nsCString mURLSpec; // Have to keep this member because GetURL hands out char*
   nsRefPtr<nsNPAPIPluginStreamListener> mPStreamListener;
@@ -159,18 +154,16 @@ private:
 
   // local cached file, we save the content into local cache if browser cache is not available,
   // or plugin asks stream as file and it expects file extension until bug 90558 got fixed
   nsRefPtr<CachedFileHolder> mLocalCachedFileHolder;
   nsCOMPtr<nsIOutputStream> mFileCacheOutputStream;
   nsDataHashtable<nsUint32HashKey, uint32_t>* mDataForwardToRequest;
 
   nsCString mContentType;
-  bool mUseLocalCache;
-  nsCOMPtr<nsIRequest> mRequest;
   bool mSeekable;
   uint32_t mModified;
   nsRefPtr<nsNPAPIPluginInstance> mPluginInstance;
   int32_t mStreamOffset;
   bool mStreamComplete;
 
 public:
   bool                    mAbort;
--- a/dom/plugins/ipc/BrowserStreamChild.cpp
+++ b/dom/plugins/ipc/BrowserStreamChild.cpp
@@ -12,45 +12,47 @@
 namespace mozilla {
 namespace plugins {
 
 BrowserStreamChild::BrowserStreamChild(PluginInstanceChild* instance,
                                        const nsCString& url,
                                        const uint32_t& length,
                                        const uint32_t& lastmodified,
                                        StreamNotifyChild* notifyData,
-                                       const nsCString& headers)
+                                       const nsCString& headers,
+                                       const nsCString& mimeType,
+                                       const bool& seekable,
+                                       NPError* rv,
+                                       uint16_t* stype)
   : mInstance(instance)
   , mStreamStatus(kStreamOpen)
   , mDestroyPending(NOT_DESTROYED)
   , mNotifyPending(false)
   , mStreamAsFilePending(false)
   , mInstanceDying(false)
   , mState(CONSTRUCTING)
   , mURL(url)
   , mHeaders(headers)
   , mStreamNotify(notifyData)
   , mDeliveryTracker(MOZ_THIS_IN_INITIALIZER_LIST())
 {
-  PLUGIN_LOG_DEBUG(("%s (%s, %i, %i, %p, %s)", FULLFUNCTION,
+  PLUGIN_LOG_DEBUG(("%s (%s, %i, %i, %p, %s, %s)", FULLFUNCTION,
                     url.get(), length, lastmodified, (void*) notifyData,
-                    headers.get()));
+                    headers.get(), mimeType.get()));
 
   AssertPluginThread();
 
   memset(&mStream, 0, sizeof(mStream));
   mStream.ndata = static_cast<AStream*>(this);
   mStream.url = NullableStringGet(mURL);
   mStream.end = length;
   mStream.lastmodified = lastmodified;
   mStream.headers = NullableStringGet(mHeaders);
-  if (notifyData) {
+  if (notifyData)
     mStream.notifyData = notifyData->mClosure;
-    notifyData->SetAssociatedStream(this);
-  }
 }
 
 NPError
 BrowserStreamChild::StreamConstructed(
             const nsCString& mimeType,
             const bool& seekable,
             uint16_t* stype)
 {
@@ -61,16 +63,19 @@ BrowserStreamChild::StreamConstructed(
     &mInstance->mData, const_cast<char*>(NullableStringGet(mimeType)),
     &mStream, seekable, stype);
   if (rv != NPERR_NO_ERROR) {
     mState = DELETING;
     mStreamNotify = nullptr;
   }
   else {
     mState = ALIVE;
+
+    if (mStreamNotify)
+      mStreamNotify->SetAssociatedStream(this);
   }
 
   return rv;
 }
 
 BrowserStreamChild::~BrowserStreamChild()
 {
   NS_ASSERTION(!mStreamNotify, "Should have nulled it by now!");
--- a/dom/plugins/ipc/BrowserStreamChild.h
+++ b/dom/plugins/ipc/BrowserStreamChild.h
@@ -18,17 +18,21 @@ class StreamNotifyChild;
 class BrowserStreamChild : public PBrowserStreamChild, public AStream
 {
 public:
   BrowserStreamChild(PluginInstanceChild* instance,
                      const nsCString& url,
                      const uint32_t& length,
                      const uint32_t& lastmodified,
                      StreamNotifyChild* notifyData,
-                     const nsCString& headers);
+                     const nsCString& headers,
+                     const nsCString& mimeType,
+                     const bool& seekable,
+                     NPError* rv,
+                     uint16_t* stype);
   virtual ~BrowserStreamChild();
 
   virtual bool IsBrowserStream() MOZ_OVERRIDE { return true; }
 
   NPError StreamConstructed(
             const nsCString& mimeType,
             const bool& seekable,
             uint16_t* stype);
--- a/dom/plugins/ipc/BrowserStreamParent.cpp
+++ b/dom/plugins/ipc/BrowserStreamParent.cpp
@@ -1,102 +1,53 @@
 /* -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 8 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 
 #include "BrowserStreamParent.h"
-#include "PluginAsyncSurrogate.h"
 #include "PluginInstanceParent.h"
 #include "nsNPAPIPlugin.h"
 
 #include "mozilla/unused.h"
 
 // How much data are we willing to send across the wire
 // in one chunk?
 static const int32_t kSendDataChunk = 0x4000;
 
 namespace mozilla {
 namespace plugins {
 
 BrowserStreamParent::BrowserStreamParent(PluginInstanceParent* npp,
                                          NPStream* stream)
   : mNPP(npp)
   , mStream(stream)
-  , mDeferredDestroyReason(NPRES_DONE)
-  , mState(INITIALIZING)
+  , mState(ALIVE)
 {
   mStream->pdata = static_cast<AStream*>(this);
-  nsNPAPIStreamWrapper* wrapper =
-    reinterpret_cast<nsNPAPIStreamWrapper*>(mStream->ndata);
-  if (wrapper) {
-    mStreamListener = wrapper->GetStreamListener();
-  }
 }
 
 BrowserStreamParent::~BrowserStreamParent()
 {
 }
 
 void
 BrowserStreamParent::ActorDestroy(ActorDestroyReason aWhy)
 {
   // Implement me! Bug 1005159
 }
 
 bool
-BrowserStreamParent::RecvAsyncNPP_NewStreamResult(const NPError& rv,
-                                                  const uint16_t& stype)
-{
-  PLUGIN_LOG_DEBUG_FUNCTION;
-  PluginAsyncSurrogate* surrogate = mNPP->GetAsyncSurrogate();
-  MOZ_ASSERT(surrogate);
-  surrogate->AsyncCallArriving();
-  nsRefPtr<nsNPAPIPluginStreamListener> streamListener = mStreamListener.forget();
-  if (mState == DEFERRING_DESTROY) {
-    // We've been asked to destroy ourselves before init was complete.
-    mState = DYING;
-    unused << SendNPP_DestroyStream(mDeferredDestroyReason);
-    return true;
-  }
-
-  NPError error = rv;
-  if (error == NPERR_NO_ERROR) {
-    if (!streamListener) {
-      return false;
-    }
-    if (streamListener->SetStreamType(stype)) {
-      mState = ALIVE;
-    } else {
-      error = NPERR_GENERIC_ERROR;
-    }
-  }
-
-  if (error != NPERR_NO_ERROR) {
-    // We need to clean up the stream
-    parent::_destroystream(mNPP->GetNPP(), mStream, NPRES_DONE);
-    unused << PBrowserStreamParent::Send__delete__(this);
-  }
-
-  return true;
-}
-
-bool
 BrowserStreamParent::AnswerNPN_RequestRead(const IPCByteRanges& ranges,
                                            NPError* result)
 {
   PLUGIN_LOG_DEBUG_FUNCTION;
 
   switch (mState) {
-  case INITIALIZING:
-    NS_ERROR("Requesting a read before initialization has completed");
-    *result = NPERR_GENERIC_ERROR;
-    return false;
-
   case ALIVE:
     break;
 
   case DYING:
     *result = NPERR_GENERIC_ERROR;
     return true;
 
   default:
@@ -139,26 +90,19 @@ BrowserStreamParent::RecvNPN_DestroyStre
 
   mNPP->mNPNIface->destroystream(mNPP->mNPP, mStream, reason);
   return true;
 }
 
 void
 BrowserStreamParent::NPP_DestroyStream(NPReason reason)
 {
-  NS_ASSERTION(ALIVE == mState || INITIALIZING == mState,
-               "NPP_DestroyStream called twice?");
-  bool stillInitializing = INITIALIZING == mState;
-  if (stillInitializing) {
-    mState = DEFERRING_DESTROY;
-    mDeferredDestroyReason = reason;
-  } else {
-    mState = DYING;
-    unused << SendNPP_DestroyStream(reason);
-  }
+  NS_ASSERTION(ALIVE == mState, "NPP_DestroyStream called twice?");
+  mState = DYING;
+  unused << SendNPP_DestroyStream(reason);
 }
 
 bool
 BrowserStreamParent::RecvStreamDestroyed()
 {
   if (DYING != mState) {
     NS_ERROR("Unexpected state");
     return false;
@@ -168,19 +112,16 @@ BrowserStreamParent::RecvStreamDestroyed
 
   mState = DELETING;
   return Send__delete__(this);
 }
 
 int32_t
 BrowserStreamParent::WriteReady()
 {
-  if (mState == INITIALIZING) {
-    return 0;
-  }
   return kSendDataChunk;
 }
 
 int32_t
 BrowserStreamParent::Write(int32_t offset,
                            int32_t len,
                            void* buffer)
 {
--- a/dom/plugins/ipc/BrowserStreamParent.h
+++ b/dom/plugins/ipc/BrowserStreamParent.h
@@ -3,18 +3,16 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef mozilla_plugins_BrowserStreamParent_h
 #define mozilla_plugins_BrowserStreamParent_h
 
 #include "mozilla/plugins/PBrowserStreamParent.h"
 #include "mozilla/plugins/AStream.h"
-#include "nsNPAPIPluginStreamListener.h"
-#include "nsPluginStreamListenerPeer.h"
 
 namespace mozilla {
 namespace plugins {
 
 class PluginInstanceParent;
 
 class BrowserStreamParent : public PBrowserStreamParent, public AStream
 {
@@ -25,52 +23,37 @@ public:
   BrowserStreamParent(PluginInstanceParent* npp,
                       NPStream* stream);
   virtual ~BrowserStreamParent();
 
   virtual bool IsBrowserStream() MOZ_OVERRIDE { return true; }
 
   virtual void ActorDestroy(ActorDestroyReason aWhy) MOZ_OVERRIDE;
 
-  virtual bool RecvAsyncNPP_NewStreamResult(
-            const NPError& rv,
-            const uint16_t& stype) MOZ_OVERRIDE;
-
   virtual bool AnswerNPN_RequestRead(const IPCByteRanges& ranges,
                                      NPError* result) MOZ_OVERRIDE;
 
   virtual bool RecvNPN_DestroyStream(const NPReason& reason) MOZ_OVERRIDE;
 
   virtual bool RecvStreamDestroyed() MOZ_OVERRIDE;
 
   int32_t WriteReady();
   int32_t Write(int32_t offset, int32_t len, void* buffer);
   void StreamAsFile(const char* fname);
 
   void NPP_DestroyStream(NPReason reason);
 
-  void SetAlive()
-  {
-    if (mState == INITIALIZING) {
-      mState = ALIVE;
-    }
-  }
-
 private:
   using PBrowserStreamParent::SendNPP_DestroyStream;
 
   PluginInstanceParent* mNPP;
   NPStream* mStream;
   nsCOMPtr<nsISupports> mStreamPeer;
-  nsRefPtr<nsNPAPIPluginStreamListener> mStreamListener;
-  NPReason mDeferredDestroyReason;
 
   enum {
-    INITIALIZING,
-    DEFERRING_DESTROY,
     ALIVE,
     DYING,
     DELETING
   } mState;
 };
 
 } // namespace plugins
 } // namespace mozilla
--- a/dom/plugins/ipc/PBrowserStream.ipdl
+++ b/dom/plugins/ipc/PBrowserStream.ipdl
@@ -31,17 +31,16 @@ child:
   /**
    * NPP_DestroyStream may race with other messages: the child acknowledges
    * the message with StreamDestroyed before this actor is deleted.
    */
   async NPP_DestroyStream(NPReason reason);
   async __delete__();
 
 parent:
-  async AsyncNPP_NewStreamResult(NPError rv, uint16_t stype);
   intr NPN_RequestRead(IPCByteRanges ranges)
     returns (NPError result);
   async NPN_DestroyStream(NPReason reason);
   async StreamDestroyed();
 
 /*
   TODO: turn on state machine.
 
--- a/dom/plugins/ipc/PPluginInstance.ipdl
+++ b/dom/plugins/ipc/PPluginInstance.ipdl
@@ -202,39 +202,31 @@ parent:
 
   async RedrawPlugin();
 
   // Send notification that a plugin tried to negotiate Carbon NPAPI so that
   // users can be notified that restarting the browser in i386 mode may allow
   // them to use the plugin.
   sync NegotiatedCarbon();
 
-  // Notifies the parent of its NPP_New result code.
-  async AsyncNPP_NewResult(NPError aResult);
-
 both:
   async PPluginScriptableObject();
 
 child:
   /* NPP_NewStream */
-  async PBrowserStream(nsCString url,
-                       uint32_t length,
-                       uint32_t lastmodified,
-                       nullable PStreamNotify notifyData,
-                       nsCString headers);
-
-  // Implements the legacy (synchronous) version of NPP_NewStream for when
-  // async plugin init is preffed off.
-  intr NPP_NewStream(PBrowserStream actor, nsCString mimeType, bool seekable)
+  intr PBrowserStream(nsCString url,
+                     uint32_t length,
+                     uint32_t lastmodified,
+                     nullable PStreamNotify notifyData,
+                     nsCString headers,
+                     nsCString mimeType,
+                     bool seekable)
     returns (NPError rv,
              uint16_t stype);
 
-  // Implements the async plugin init version of NPP_NewStream.
-  async AsyncNPP_NewStream(PBrowserStream actor, nsCString mimeType, bool seekable);
-
 parent:
   /* NPN_NewStream */
   intr PPluginStream(nsCString mimeType,
                     nsCString target)
     returns (NPError result);
 
 parent:
   intr PluginFocusChange(bool gotFocus);
--- a/dom/plugins/ipc/PPluginModule.ipdl
+++ b/dom/plugins/ipc/PPluginModule.ipdl
@@ -49,31 +49,22 @@ child:
 
   // Forces the child process to update its plugin function table.
   intr NP_GetEntryPoints()
     returns (NPError rv);
 
   intr NP_Initialize(PluginSettings settings)
     returns (NPError rv);
 
-  async AsyncNP_Initialize(PluginSettings settings);
-
-  async PPluginInstance(nsCString aMimeType,
-                        uint16_t aMode,
-                        nsCString[] aNames,
-                        nsCString[] aValues);
-
-  // Implements the synchronous version of NPP_New for when async plugin init
-  // is preffed off.
-  intr SyncNPP_New(PPluginInstance aActor)
+  intr PPluginInstance(nsCString aMimeType,
+                      uint16_t aMode,
+                      nsCString[] aNames,
+                      nsCString[] aValues)
     returns (NPError rv);
 
-  // Implements the async plugin init version of NPP_New.
-  async AsyncNPP_New(PPluginInstance aActor);
-
   intr NP_Shutdown()
     returns (NPError rv);
 
   intr OptionalFunctionsSupported()
     returns (bool aURLRedirectNotify, bool aClearSiteData,
              bool aGetSitesWithData);
 
   intr NPP_ClearSiteData(nsCString site, uint64_t flags, uint64_t maxAge)
@@ -93,25 +84,22 @@ child:
     returns (NativeThreadId tid, uint32_t processType);
 
   /**
    * Control the Gecko Profiler in the plugin process.
    */
   async StartProfiler(uint32_t aEntries, double aInterval, nsCString[] aFeatures,
                       nsCString[] aThreadNameFilters);
   async StopProfiler();
-
   intr GetProfile()
     returns (nsCString aProfile);
 
   async SettingChanged(PluginSettings settings);
 
 parent:
-  async NP_InitializeResult(NPError aError);
-
   /**
    * This message is only used on X11 platforms.
    *
    * Send a dup of the plugin process's X socket to the parent
    * process.  In theory, this scheme keeps the plugin's X resources
    * around until after both the plugin process shuts down *and* the
    * parent process closes the dup fd.  This is used to prevent the
    * parent process from crashing on X errors if, e.g., the plugin
deleted file mode 100644
--- a/dom/plugins/ipc/PluginAsyncSurrogate.cpp
+++ /dev/null
@@ -1,882 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=8 sts=2 et sw=2 tw=80: */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#include "PluginAsyncSurrogate.h"
-
-#include "base/message_loop.h"
-#include "base/message_pump_default.h"
-#include "mozilla/dom/ContentChild.h"
-#include "mozilla/plugins/PluginInstanceParent.h"
-#include "mozilla/plugins/PluginModuleParent.h"
-#include "mozilla/plugins/PluginScriptableObjectParent.h"
-#include "mozilla/Telemetry.h"
-#include "nsJSNPRuntime.h"
-#include "nsNPAPIPlugin.h"
-#include "nsNPAPIPluginInstance.h"
-#include "nsNPAPIPluginStreamListener.h"
-#include "nsPluginInstanceOwner.h"
-#include "nsPluginStreamListenerPeer.h"
-#include "npruntime.h"
-#include "nsThreadUtils.h"
-#include "PluginMessageUtils.h"
-
-namespace mozilla {
-namespace plugins {
-
-AsyncNPObject::AsyncNPObject(PluginAsyncSurrogate* aSurrogate)
-  : NPObject()
-  , mSurrogate(aSurrogate)
-  , mRealObject(nullptr)
-{
-}
-
-AsyncNPObject::~AsyncNPObject()
-{
-  if (mRealObject) {
-    parent::_releaseobject(mRealObject);
-    mRealObject = nullptr;
-  }
-}
-
-NPObject*
-AsyncNPObject::GetRealObject()
-{
-  if (mRealObject) {
-    return mRealObject;
-  }
-  PluginInstanceParent* instance = PluginInstanceParent::Cast(mSurrogate->GetNPP());
-  if (!instance) {
-    return nullptr;
-  }
-  NPError err = instance->NPP_GetValue(NPPVpluginScriptableNPObject,
-                                       &mRealObject);
-  if (err != NPERR_NO_ERROR) {
-    return nullptr;
-  }
-  return mRealObject;
-}
-
-class MOZ_STACK_CLASS RecursionGuard
-{
-public:
-  RecursionGuard()
-    : mIsRecursive(sHasEntered)
-  {
-    if (!mIsRecursive) {
-      sHasEntered = true;
-    }
-  }
-
-  ~RecursionGuard()
-  {
-    if (!mIsRecursive) {
-      sHasEntered = false;
-    }
-  }
-
-  inline bool
-  IsRecursive()
-  {
-    return mIsRecursive;
-  }
-
-private:
-  bool        mIsRecursive;
-  static bool sHasEntered;
-};
-
-bool RecursionGuard::sHasEntered = false;
-
-PluginAsyncSurrogate::PluginAsyncSurrogate(PluginModuleParent* aParent)
-  : mParent(aParent)
-  , mInstance(nullptr)
-  , mMode(0)
-  , mWindow(nullptr)
-  , mAcceptCalls(false)
-  , mInstantiated(false)
-  , mAsyncSetWindow(false)
-  , mInitCancelled(false)
-  , mAsyncCallsInFlight(0)
-{
-  MOZ_ASSERT(aParent);
-}
-
-PluginAsyncSurrogate::~PluginAsyncSurrogate()
-{
-}
-
-bool
-PluginAsyncSurrogate::Init(NPMIMEType aPluginType, NPP aInstance, uint16_t aMode,
-                           int16_t aArgc, char* aArgn[], char* aArgv[])
-{
-  mMimeType = aPluginType;
-  mInstance = aInstance;
-  mMode = aMode;
-  for (int i = 0; i < aArgc; ++i) {
-    mNames.AppendElement(NullableString(aArgn[i]));
-    mValues.AppendElement(NullableString(aArgv[i]));
-  }
-  return true;
-}
-
-/* static */ bool
-PluginAsyncSurrogate::Create(PluginModuleParent* aParent, NPMIMEType aPluginType,
-                             NPP aInstance, uint16_t aMode, int16_t aArgc,
-                             char* aArgn[], char* aArgv[])
-{
-  nsRefPtr<PluginAsyncSurrogate> surrogate(new PluginAsyncSurrogate(aParent));
-  if (!surrogate->Init(aPluginType, aInstance, aMode, aArgc, aArgn, aArgv)) {
-    return false;
-  }
-  PluginAsyncSurrogate* rawSurrogate = nullptr;
-  surrogate.forget(&rawSurrogate);
-  aInstance->pdata = static_cast<PluginDataResolver*>(rawSurrogate);
-  return true;
-}
-
-/* static */ PluginAsyncSurrogate*
-PluginAsyncSurrogate::Cast(NPP aInstance)
-{
-  MOZ_ASSERT(aInstance);
-  PluginDataResolver* resolver =
-    reinterpret_cast<PluginDataResolver*>(aInstance->pdata);
-  if (!resolver) {
-    return nullptr;
-  }
-  return resolver->GetAsyncSurrogate();
-}
-
-nsresult
-PluginAsyncSurrogate::NPP_New(NPError* aError)
-{
-  nsresult rv = mParent->NPP_NewInternal(mMimeType.BeginWriting(), mInstance,
-                                         mMode, mNames, mValues, nullptr,
-                                         aError);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-  return NS_OK;
-}
-
-void
-PluginAsyncSurrogate::NP_GetEntryPoints(NPPluginFuncs* aFuncs)
-{
-  aFuncs->version = (NP_VERSION_MAJOR << 8) | NP_VERSION_MINOR;
-  aFuncs->destroy = &NPP_Destroy;
-  aFuncs->getvalue = &NPP_GetValue;
-  aFuncs->setvalue = &NPP_SetValue;
-  aFuncs->newstream = &NPP_NewStream;
-  aFuncs->setwindow = &NPP_SetWindow;
-  aFuncs->writeready = &NPP_WriteReady;
-  aFuncs->event = &NPP_HandleEvent;
-  // We need to set these so that content code doesn't make assumptions
-  // about these operations not being supported
-  aFuncs->write = &PluginModuleParent::NPP_Write;
-  aFuncs->asfile = &PluginModuleParent::NPP_StreamAsFile;
-  aFuncs->destroystream = &PluginModuleParent::NPP_DestroyStream;
-}
-
-NPError
-PluginAsyncSurrogate::NPP_Destroy(NPSavedData** aSave)
-{
-  if (!WaitForInit()) {
-    return NPERR_GENERIC_ERROR;
-  }
-  return PluginModuleParent::NPP_Destroy(mInstance, aSave);
-}
-
-NPError
-PluginAsyncSurrogate::NPP_GetValue(NPPVariable aVariable, void* aRetval)
-{
-  if (aVariable != NPPVpluginScriptableNPObject) {
-    if (!WaitForInit()) {
-      return NPERR_GENERIC_ERROR;
-    }
-    PluginInstanceParent* instance = PluginInstanceParent::Cast(mInstance);
-    MOZ_ASSERT(instance);
-    return instance->NPP_GetValue(aVariable, aRetval);
-  }
-
-  NPObject* npobject = parent::_createobject(mInstance,
-                                             const_cast<NPClass*>(GetClass()));
-  MOZ_ASSERT(npobject);
-  MOZ_ASSERT(npobject->_class == GetClass());
-  MOZ_ASSERT(npobject->referenceCount == 1);
-  *(NPObject**)aRetval = npobject;
-  return npobject ? NPERR_NO_ERROR : NPERR_GENERIC_ERROR;
-}
-
-NPError
-PluginAsyncSurrogate::NPP_SetValue(NPNVariable aVariable, void* aValue)
-{
-  if (!WaitForInit()) {
-    return NPERR_GENERIC_ERROR;
-  }
-  return PluginModuleParent::NPP_SetValue(mInstance, aVariable, aValue);
-}
-
-NPError
-PluginAsyncSurrogate::NPP_NewStream(NPMIMEType aType, NPStream* aStream,
-                                    NPBool aSeekable, uint16_t* aStype)
-{
-  mPendingNewStreamCalls.AppendElement(PendingNewStreamCall(aType, aStream,
-                                                            aSeekable));
-  if (aStype) {
-    *aStype = nsPluginStreamListenerPeer::STREAM_TYPE_UNKNOWN;
-  }
-  return NPERR_NO_ERROR;
-}
-
-NPError
-PluginAsyncSurrogate::NPP_SetWindow(NPWindow* aWindow)
-{
-  mWindow = aWindow;
-  mAsyncSetWindow = false;
-  return NPERR_NO_ERROR;
-}
-
-nsresult
-PluginAsyncSurrogate::AsyncSetWindow(NPWindow* aWindow)
-{
-  mWindow = aWindow;
-  mAsyncSetWindow = true;
-  return NS_OK;
-}
-
-void
-PluginAsyncSurrogate::NPP_Print(NPPrint* aPrintInfo)
-{
-  // Do nothing, we've got nothing to print right now
-}
-
-int16_t
-PluginAsyncSurrogate::NPP_HandleEvent(void* event)
-{
-  // Drop the event -- the plugin isn't around to handle it
-  return false;
-}
-
-int32_t
-PluginAsyncSurrogate::NPP_WriteReady(NPStream* aStream)
-{
-  // We'll tell the browser to retry in a bit. Eventually NPP_WriteReady
-  // will resolve to the plugin's NPP_WriteReady and this should all just work.
-  return 0;
-}
-
-/* static */ NPError
-PluginAsyncSurrogate::NPP_Destroy(NPP aInstance, NPSavedData** aSave)
-{
-  PluginAsyncSurrogate* rawSurrogate = Cast(aInstance);
-  MOZ_ASSERT(rawSurrogate);
-  PluginModuleParent* module = rawSurrogate->GetParent();
-  if (module && !module->IsInitialized()) {
-    // Take ownership of pdata's surrogate since we're going to release it
-    nsRefPtr<PluginAsyncSurrogate> surrogate(dont_AddRef(rawSurrogate));
-    aInstance->pdata = nullptr;
-    // We haven't actually called NPP_New yet, so we should remove the
-    // surrogate for this instance.
-    bool removeOk = module->RemovePendingSurrogate(surrogate);
-    MOZ_ASSERT(removeOk);
-    if (!removeOk) {
-      return NPERR_GENERIC_ERROR;
-    }
-    surrogate->mInitCancelled = true;
-    return NPERR_NO_ERROR;
-  }
-  return rawSurrogate->NPP_Destroy(aSave);
-}
-
-/* static */ NPError
-PluginAsyncSurrogate::NPP_GetValue(NPP aInstance, NPPVariable aVariable,
-                                   void* aRetval)
-{
-  PluginAsyncSurrogate* surrogate = Cast(aInstance);
-  MOZ_ASSERT(surrogate);
-  return surrogate->NPP_GetValue(aVariable, aRetval);
-}
-
-/* static */ NPError
-PluginAsyncSurrogate::NPP_SetValue(NPP aInstance, NPNVariable aVariable,
-                                   void* aValue)
-{
-  PluginAsyncSurrogate* surrogate = Cast(aInstance);
-  MOZ_ASSERT(surrogate);
-  return surrogate->NPP_SetValue(aVariable, aValue);
-}
-
-/* static */ NPError
-PluginAsyncSurrogate::NPP_NewStream(NPP aInstance, NPMIMEType aType,
-                                    NPStream* aStream, NPBool aSeekable,
-                                    uint16_t* aStype)
-{
-  PluginAsyncSurrogate* surrogate = Cast(aInstance);
-  MOZ_ASSERT(surrogate);
-  return surrogate->NPP_NewStream(aType, aStream, aSeekable, aStype);
-}
-
-/* static */ NPError
-PluginAsyncSurrogate::NPP_SetWindow(NPP aInstance, NPWindow* aWindow)
-{
-  PluginAsyncSurrogate* surrogate = Cast(aInstance);
-  MOZ_ASSERT(surrogate);
-  return surrogate->NPP_SetWindow(aWindow);
-}
-
-/* static */ void
-PluginAsyncSurrogate::NPP_Print(NPP aInstance, NPPrint* aPrintInfo)
-{
-  PluginAsyncSurrogate* surrogate = Cast(aInstance);
-  MOZ_ASSERT(surrogate);
-  surrogate->NPP_Print(aPrintInfo);
-}
-
-/* static */ int16_t
-PluginAsyncSurrogate::NPP_HandleEvent(NPP aInstance, void* aEvent)
-{
-  PluginAsyncSurrogate* surrogate = Cast(aInstance);
-  MOZ_ASSERT(surrogate);
-  return surrogate->NPP_HandleEvent(aEvent);
-}
-
-/* static */ int32_t
-PluginAsyncSurrogate::NPP_WriteReady(NPP aInstance, NPStream* aStream)
-{
-  PluginAsyncSurrogate* surrogate = Cast(aInstance);
-  MOZ_ASSERT(surrogate);
-  return surrogate->NPP_WriteReady(aStream);
-}
-
-PluginAsyncSurrogate::PendingNewStreamCall::PendingNewStreamCall(
-    NPMIMEType aType, NPStream* aStream, NPBool aSeekable)
-  : mType(NullableString(aType))
-  , mStream(aStream)
-  , mSeekable(aSeekable)
-{
-}
-
-/* static */ bool
-PluginAsyncSurrogate::SetStreamType(NPStream* aStream, uint16_t aStreamType)
-{
-  nsNPAPIStreamWrapper* wrapper =
-    reinterpret_cast<nsNPAPIStreamWrapper*>(aStream->ndata);
-  if (!wrapper) {
-    return false;
-  }
-  nsNPAPIPluginStreamListener* streamListener = wrapper->GetStreamListener();
-  if (!streamListener) {
-    return false;
-  }
-  return streamListener->SetStreamType(aStreamType);
-}
-
-void
-PluginAsyncSurrogate::OnInstanceCreated(PluginInstanceParent* aInstance)
-{
-  for (PRUint32 i = 0, len = mPendingNewStreamCalls.Length(); i < len; ++i) {
-    PendingNewStreamCall& curPendingCall = mPendingNewStreamCalls[i];
-    uint16_t streamType = NP_NORMAL;
-    NPError curError = aInstance->NPP_NewStream(
-                    const_cast<char*>(NullableStringGet(curPendingCall.mType)),
-                    curPendingCall.mStream, curPendingCall.mSeekable,
-                    &streamType);
-    if (curError != NPERR_NO_ERROR) {
-      // If we failed here then the send failed and we need to clean up
-      parent::_destroystream(mInstance, curPendingCall.mStream, NPRES_DONE);
-    }
-  }
-  mPendingNewStreamCalls.Clear();
-  mInstantiated = true;
-}
-
-/**
- * During asynchronous initialization it might be necessary to wait for the
- * plugin to complete its initialization. This typically occurs when the result
- * of a plugin call depends on the plugin being fully instantiated. For example,
- * if some JS calls into the plugin, the call must be executed synchronously to
- * preserve correctness.
- *
- * This function works by pumping the plugin's IPC channel for events until
- * initialization has completed.
- */
-bool
-PluginAsyncSurrogate::WaitForInit()
-{
-  if (mInitCancelled) {
-    return false;
-  }
-  if (mAcceptCalls) {
-    return true;
-  }
-  Telemetry::AutoTimer<Telemetry::BLOCKED_ON_PLUGINASYNCSURROGATE_WAITFORINIT_MS>
-    timer(mParent->GetHistogramKey());
-  bool result = false;
-  MOZ_ASSERT(mParent);
-  if (mParent->IsChrome()) {
-    PluginProcessParent* process = static_cast<PluginModuleChromeParent*>(mParent)->Process();
-    MOZ_ASSERT(process);
-    process->SetCallRunnableImmediately(true);
-    if (!process->WaitUntilConnected()) {
-      return false;
-    }
-  }
-  if (!mParent->WaitForIPCConnection()) {
-    return false;
-  }
-  if (!mParent->IsChrome()) {
-    // For e10s content processes, we need to spin the content channel until the
-    // protocol bridging has occurred.
-    dom::ContentChild* cp = dom::ContentChild::GetSingleton();
-    mozilla::ipc::MessageChannel* contentChannel = cp->GetIPCChannel();
-    MOZ_ASSERT(contentChannel);
-    while (!mParent->mNPInitialized) {
-      result = contentChannel->WaitForIncomingMessage();
-      if (!result) {
-        return result;
-      }
-    }
-  }
-  mozilla::ipc::MessageChannel* channel = mParent->GetIPCChannel();
-  MOZ_ASSERT(channel);
-  while (!mAcceptCalls) {
-    result = channel->WaitForIncomingMessage();
-    if (!result) {
-      break;
-    }
-  }
-  return result;
-}
-
-void
-PluginAsyncSurrogate::AsyncCallDeparting()
-{
-  ++mAsyncCallsInFlight;
-  if (!mPluginDestructionGuard) {
-    mPluginDestructionGuard = MakeUnique<PluginDestructionGuard>(this);
-  }
-}
-
-void
-PluginAsyncSurrogate::AsyncCallArriving()
-{
-  MOZ_ASSERT(mAsyncCallsInFlight > 0);
-  if (--mAsyncCallsInFlight == 0) {
-    mPluginDestructionGuard.reset(nullptr);
-  }
-}
-
-void
-PluginAsyncSurrogate::NotifyAsyncInitFailed()
-{
-  // Clean up any pending NewStream requests
-  for (uint32_t i = 0, len = mPendingNewStreamCalls.Length(); i < len; ++i) {
-    PendingNewStreamCall& curPendingCall = mPendingNewStreamCalls[i];
-    parent::_destroystream(mInstance, curPendingCall.mStream, NPRES_DONE);
-  }
-  mPendingNewStreamCalls.Clear();
-
-  nsNPAPIPluginInstance* inst =
-    static_cast<nsNPAPIPluginInstance*>(mInstance->ndata);
-  if (!inst) {
-      return;
-  }
-  nsPluginInstanceOwner* owner = inst->GetOwner();
-  if (!owner) {
-      return;
-  }
-  owner->NotifyHostAsyncInitFailed();
-}
-
-// static
-NPObject*
-PluginAsyncSurrogate::ScriptableAllocate(NPP aInstance, NPClass* aClass)
-{
-  PLUGIN_LOG_DEBUG_FUNCTION;
-  if (aClass != GetClass()) {
-    NS_ERROR("Huh?! Wrong class!");
-    return nullptr;
-  }
-
-  return new AsyncNPObject(Cast(aInstance));
-}
-
-// static
-void
-PluginAsyncSurrogate::ScriptableInvalidate(NPObject* aObject)
-{
-  PLUGIN_LOG_DEBUG_FUNCTION;
-  if (aObject->_class != GetClass()) {
-    NS_ERROR("Don't know what kind of object this is!");
-    return;
-  }
-
-  AsyncNPObject* object = static_cast<AsyncNPObject*>(aObject);
-  if (!object->mSurrogate->WaitForInit()) {
-    return;
-  }
-  NPObject* realObject = object->GetRealObject();
-  if (!realObject) {
-    return;
-  }
-  realObject->_class->invalidate(realObject);
-}
-
-// static
-void
-PluginAsyncSurrogate::ScriptableDeallocate(NPObject* aObject)
-{
-  PLUGIN_LOG_DEBUG_FUNCTION;
-  if (aObject->_class != GetClass()) {
-    NS_ERROR("Don't know what kind of object this is!");
-    return;
-  }
-
-  AsyncNPObject* object = static_cast<AsyncNPObject*>(aObject);
-  delete object;
-}
-
-// static
-bool
-PluginAsyncSurrogate::ScriptableHasMethod(NPObject* aObject,
-                                                  NPIdentifier aName)
-{
-  PLUGIN_LOG_DEBUG_FUNCTION;
-  if (aObject->_class != GetClass()) {
-    NS_ERROR("Don't know what kind of object this is!");
-    return false;
-  }
-
-  RecursionGuard guard;
-  if (guard.IsRecursive()) {
-    return false;
-  }
-
-  AsyncNPObject* object = static_cast<AsyncNPObject*>(aObject);
-  MOZ_ASSERT(object);
-  bool checkPluginObject = !object->mSurrogate->mInstantiated &&
-                           !object->mSurrogate->mAcceptCalls;
-
-  if (!object->mSurrogate->WaitForInit()) {
-    return false;
-  }
-  NPObject* realObject = object->GetRealObject();
-  if (!realObject) {
-    return false;
-  }
-  bool result = realObject->_class->hasMethod(realObject, aName);
-  if (!result && checkPluginObject) {
-    // We may be calling into this object because properties in the WebIDL
-    // object hadn't been set yet. Now that we're further along in
-    // initialization, we should try again.
-    const NPNetscapeFuncs* npn = object->mSurrogate->mParent->GetNetscapeFuncs();
-    NPObject* pluginObject = nullptr;
-    NPError nperror = npn->getvalue(object->mSurrogate->mInstance,
-                                    NPNVPluginElementNPObject,
-                                    (void*)&pluginObject);
-    if (nperror == NPERR_NO_ERROR) {
-      NPPAutoPusher nppPusher(object->mSurrogate->mInstance);
-      result = pluginObject->_class->hasMethod(pluginObject, aName);
-      npn->releaseobject(pluginObject);
-      NPUTF8* idstr = npn->utf8fromidentifier(aName);
-      npn->memfree(idstr);
-    }
-  }
-  return result;
-}
-
-bool
-PluginAsyncSurrogate::GetPropertyHelper(NPObject* aObject, NPIdentifier aName,
-                                        bool* aHasProperty, bool* aHasMethod,
-                                        NPVariant* aResult)
-{
-  PLUGIN_LOG_DEBUG_FUNCTION;
-
-  if (!aObject) {
-    return false;
-  }
-
-  RecursionGuard guard;
-  if (guard.IsRecursive()) {
-    return false;
-  }
-
-  WaitForInit();
-
-  AsyncNPObject* object = static_cast<AsyncNPObject*>(aObject);
-  NPObject* realObject = object->GetRealObject();
-  if (realObject->_class != PluginScriptableObjectParent::GetClass()) {
-    NS_ERROR("Don't know what kind of object this is!");
-    return false;
-  }
-
-  PluginScriptableObjectParent* actor =
-    static_cast<ParentNPObject*>(realObject)->parent;
-  bool success = actor->GetPropertyHelper(aName, aHasProperty, aHasMethod, aResult);
-  if (!success) {
-    const NPNetscapeFuncs* npn = mParent->GetNetscapeFuncs();
-    NPObject* pluginObject = nullptr;
-    NPError nperror = npn->getvalue(mInstance, NPNVPluginElementNPObject,
-                                    (void*)&pluginObject);
-    if (nperror == NPERR_NO_ERROR) {
-      NPPAutoPusher nppPusher(mInstance);
-      bool hasProperty = nsJSObjWrapper::HasOwnProperty(pluginObject, aName);
-      NPUTF8* idstr = npn->utf8fromidentifier(aName);
-      npn->memfree(idstr);
-      bool hasMethod = false;
-      if (hasProperty) {
-        hasMethod = pluginObject->_class->hasMethod(pluginObject, aName);
-        success = pluginObject->_class->getProperty(pluginObject, aName, aResult);
-        idstr = npn->utf8fromidentifier(aName);
-        npn->memfree(idstr);
-      }
-      *aHasProperty = hasProperty;
-      *aHasMethod = hasMethod;
-      npn->releaseobject(pluginObject);
-    }
-  }
-  return success;
-}
-
-// static
-bool
-PluginAsyncSurrogate::ScriptableInvoke(NPObject* aObject,
-                                               NPIdentifier aName,
-                                               const NPVariant* aArgs,
-                                               uint32_t aArgCount,
-                                               NPVariant* aResult)
-{
-  PLUGIN_LOG_DEBUG_FUNCTION;
-  if (aObject->_class != GetClass()) {
-    NS_ERROR("Don't know what kind of object this is!");
-    return false;
-  }
-
-  AsyncNPObject* object = static_cast<AsyncNPObject*>(aObject);
-  if (!object->mSurrogate->WaitForInit()) {
-    return false;
-  }
-  NPObject* realObject = object->GetRealObject();
-  if (!realObject) {
-    return false;
-  }
-  return realObject->_class->invoke(realObject, aName, aArgs, aArgCount, aResult);
-}
-
-// static
-bool
-PluginAsyncSurrogate::ScriptableInvokeDefault(NPObject* aObject,
-                                                      const NPVariant* aArgs,
-                                                      uint32_t aArgCount,
-                                                      NPVariant* aResult)
-{
-  PLUGIN_LOG_DEBUG_FUNCTION;
-  if (aObject->_class != GetClass()) {
-    NS_ERROR("Don't know what kind of object this is!");
-    return false;
-  }
-
-  AsyncNPObject* object = static_cast<AsyncNPObject*>(aObject);
-  if (!object->mSurrogate->WaitForInit()) {
-    return false;
-  }
-  NPObject* realObject = object->GetRealObject();
-  if (!realObject) {
-    return false;
-  }
-  return realObject->_class->invokeDefault(realObject, aArgs, aArgCount, aResult);
-}
-
-// static
-bool
-PluginAsyncSurrogate::ScriptableHasProperty(NPObject* aObject,
-                                                    NPIdentifier aName)
-{
-  PLUGIN_LOG_DEBUG_FUNCTION;
-  if (aObject->_class != GetClass()) {
-    NS_ERROR("Don't know what kind of object this is!");
-    return false;
-  }
-
-  RecursionGuard guard;
-  if (guard.IsRecursive()) {
-    return false;
-  }
-
-  AsyncNPObject* object = static_cast<AsyncNPObject*>(aObject);
-  MOZ_ASSERT(object);
-  bool checkPluginObject = !object->mSurrogate->mInstantiated &&
-                           !object->mSurrogate->mAcceptCalls;
-
-  if (!object->mSurrogate->WaitForInit()) {
-    return false;
-  }
-  NPObject* realObject = object->GetRealObject();
-  if (!realObject) {
-    return false;
-  }
-  bool result = realObject->_class->hasProperty(realObject, aName);
-  const NPNetscapeFuncs* npn = object->mSurrogate->mParent->GetNetscapeFuncs();
-  NPUTF8* idstr = npn->utf8fromidentifier(aName);
-  npn->memfree(idstr);
-  if (!result && checkPluginObject) {
-    // We may be calling into this object because properties in the WebIDL
-    // object hadn't been set yet. Now that we're further along in
-    // initialization, we should try again.
-    NPObject* pluginObject = nullptr;
-    NPError nperror = npn->getvalue(object->mSurrogate->mInstance,
-                                    NPNVPluginElementNPObject,
-                                    (void*)&pluginObject);
-    if (nperror == NPERR_NO_ERROR) {
-      NPPAutoPusher nppPusher(object->mSurrogate->mInstance);
-      result = nsJSObjWrapper::HasOwnProperty(pluginObject, aName);
-      npn->releaseobject(pluginObject);
-      idstr = npn->utf8fromidentifier(aName);
-      npn->memfree(idstr);
-    }
-  }
-  return result;
-}
-
-// static
-bool
-PluginAsyncSurrogate::ScriptableGetProperty(NPObject* aObject,
-                                                    NPIdentifier aName,
-                                                    NPVariant* aResult)
-{
-  PLUGIN_LOG_DEBUG_FUNCTION;
-  // See GetPropertyHelper below.
-  NS_NOTREACHED("Shouldn't ever call this directly!");
-  return false;
-}
-
-// static
-bool
-PluginAsyncSurrogate::ScriptableSetProperty(NPObject* aObject,
-                                                    NPIdentifier aName,
-                                                    const NPVariant* aValue)
-{
-  PLUGIN_LOG_DEBUG_FUNCTION;
-  if (aObject->_class != GetClass()) {
-    NS_ERROR("Don't know what kind of object this is!");
-    return false;
-  }
-
-  AsyncNPObject* object = static_cast<AsyncNPObject*>(aObject);
-  if (!object->mSurrogate->WaitForInit()) {
-    return false;
-  }
-  NPObject* realObject = object->GetRealObject();
-  if (!realObject) {
-    return false;
-  }
-  return realObject->_class->setProperty(realObject, aName, aValue);
-}
-
-// static
-bool
-PluginAsyncSurrogate::ScriptableRemoveProperty(NPObject* aObject,
-                                                       NPIdentifier aName)
-{
-  PLUGIN_LOG_DEBUG_FUNCTION;
-  if (aObject->_class != GetClass()) {
-    NS_ERROR("Don't know what kind of object this is!");
-    return false;
-  }
-
-  AsyncNPObject* object = static_cast<AsyncNPObject*>(aObject);
-  if (!object->mSurrogate->WaitForInit()) {
-    return false;
-  }
-  NPObject* realObject = object->GetRealObject();
-  if (!realObject) {
-    return false;
-  }
-  return realObject->_class->removeProperty(realObject, aName);
-}
-
-// static
-bool
-PluginAsyncSurrogate::ScriptableEnumerate(NPObject* aObject,
-                                                  NPIdentifier** aIdentifiers,
-                                                  uint32_t* aCount)
-{
-  PLUGIN_LOG_DEBUG_FUNCTION;
-  if (aObject->_class != GetClass()) {
-    NS_ERROR("Don't know what kind of object this is!");
-    return false;
-  }
-
-  AsyncNPObject* object = static_cast<AsyncNPObject*>(aObject);
-  if (!object->mSurrogate->WaitForInit()) {
-    return false;
-  }
-  NPObject* realObject = object->GetRealObject();
-  if (!realObject) {
-    return false;
-  }
-  return realObject->_class->enumerate(realObject, aIdentifiers, aCount);
-}
-
-// static
-bool
-PluginAsyncSurrogate::ScriptableConstruct(NPObject* aObject,
-                                                  const NPVariant* aArgs,
-                                                  uint32_t aArgCount,
-                                                  NPVariant* aResult)
-{
-  PLUGIN_LOG_DEBUG_FUNCTION;
-  if (aObject->_class != GetClass()) {
-    NS_ERROR("Don't know what kind of object this is!");
-    return false;
-  }
-
-  AsyncNPObject* object = static_cast<AsyncNPObject*>(aObject);
-  if (!object->mSurrogate->WaitForInit()) {
-    return false;
-  }
-  NPObject* realObject = object->GetRealObject();
-  if (!realObject) {
-    return false;
-  }
-  return realObject->_class->construct(realObject, aArgs, aArgCount, aResult);
-}
-
-const NPClass PluginAsyncSurrogate::sNPClass = {
-  NP_CLASS_STRUCT_VERSION,
-  PluginAsyncSurrogate::ScriptableAllocate,
-  PluginAsyncSurrogate::ScriptableDeallocate,
-  PluginAsyncSurrogate::ScriptableInvalidate,
-  PluginAsyncSurrogate::ScriptableHasMethod,
-  PluginAsyncSurrogate::ScriptableInvoke,
-  PluginAsyncSurrogate::ScriptableInvokeDefault,
-  PluginAsyncSurrogate::ScriptableHasProperty,
-  PluginAsyncSurrogate::ScriptableGetProperty,
-  PluginAsyncSurrogate::ScriptableSetProperty,
-  PluginAsyncSurrogate::ScriptableRemoveProperty,
-  PluginAsyncSurrogate::ScriptableEnumerate,
-  PluginAsyncSurrogate::ScriptableConstruct
-};
-
-PushSurrogateAcceptCalls::PushSurrogateAcceptCalls(PluginInstanceParent* aInstance)
-  : mSurrogate(nullptr)
-  , mPrevAcceptCallsState(false)
-{
-  MOZ_ASSERT(aInstance);
-  mSurrogate = aInstance->GetAsyncSurrogate();
-  if (mSurrogate) {
-    mPrevAcceptCallsState = mSurrogate->SetAcceptingCalls(true);
-  }
-}
-
-PushSurrogateAcceptCalls::~PushSurrogateAcceptCalls()
-{
-  if (mSurrogate) {
-    mSurrogate->SetAcceptingCalls(mPrevAcceptCallsState);
-  }
-}
-
-} // namespace plugins
-} // namespace mozilla
deleted file mode 100644
--- a/dom/plugins/ipc/PluginAsyncSurrogate.h
+++ /dev/null
@@ -1,179 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=8 sts=2 et sw=2 tw=80: */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#ifndef dom_plugins_ipc_PluginAsyncSurrogate_h
-#define dom_plugins_ipc_PluginAsyncSurrogate_h
-
-#include "mozilla/UniquePtr.h"
-#include "npapi.h"
-#include "npfunctions.h"
-#include "npruntime.h"
-#include "nsAutoPtr.h"
-#include "nsISupportsImpl.h"
-#include "nsPluginHost.h"
-#include "nsString.h"
-#include "nsTArray.h"
-#include "PluginDataResolver.h"
-
-namespace mozilla {
-namespace plugins {
-
-class PluginInstanceParent;
-class PluginModuleParent;
-
-class PluginAsyncSurrogate : public PluginDataResolver
-{
-public:
-  NS_INLINE_DECL_REFCOUNTING(PluginAsyncSurrogate)
-
-  bool Init(NPMIMEType aPluginType, NPP aInstance, uint16_t aMode,
-            int16_t aArgc, char* aArgn[], char* aArgv[]);
-  nsresult NPP_New(NPError* aError);
-  NPError NPP_Destroy(NPSavedData** aSave);
-  NPError NPP_GetValue(NPPVariable aVariable, void* aRetval);
-  NPError NPP_SetValue(NPNVariable aVariable, void* aValue);
-  NPError NPP_NewStream(NPMIMEType aType, NPStream* aStream, NPBool aSeekable,
-                        uint16_t* aStype);
-  NPError NPP_SetWindow(NPWindow* aWindow);
-  nsresult AsyncSetWindow(NPWindow* aWindow);
-  void NPP_Print(NPPrint* aPrintInfo);
-  int16_t NPP_HandleEvent(void* aEvent);
-  int32_t NPP_WriteReady(NPStream* aStream);
-  void OnInstanceCreated(PluginInstanceParent* aInstance);
-  static bool Create(PluginModuleParent* aParent, NPMIMEType aPluginType,
-                     NPP aInstance, uint16_t aMode, int16_t aArgc,
-                     char* aArgn[], char* aArgv[]);
-  static const NPClass* GetClass() { return &sNPClass; }
-  static void NP_GetEntryPoints(NPPluginFuncs* aFuncs);
-  static PluginAsyncSurrogate* Cast(NPP aInstance);
-
-  virtual PluginAsyncSurrogate*
-  GetAsyncSurrogate() { return this; }
-
-  virtual PluginInstanceParent*
-  GetInstance() { return nullptr; }
-
-  NPP GetNPP() { return mInstance; }
-
-  bool GetPropertyHelper(NPObject* aObject, NPIdentifier aName,
-                         bool* aHasProperty, bool* aHasMethod,
-                         NPVariant* aResult);
-
-  PluginModuleParent*
-  GetParent() { return mParent; }
-
-  bool SetAcceptingCalls(bool aAccept)
-  {
-    bool prevState = mAcceptCalls;
-    if (mInstantiated) {
-      aAccept = true;
-    }
-    mAcceptCalls = aAccept;
-    return prevState;
-  }
-
-  void AsyncCallDeparting();
-  void AsyncCallArriving();
-
-  void NotifyAsyncInitFailed();
-
-private:
-  explicit PluginAsyncSurrogate(PluginModuleParent* aParent);
-  virtual ~PluginAsyncSurrogate();
-
-  bool WaitForInit();
-
-  static bool SetStreamType(NPStream* aStream, uint16_t aStreamType);
-
-  static NPError NPP_Destroy(NPP aInstance, NPSavedData** aSave);
-  static NPError NPP_GetValue(NPP aInstance, NPPVariable aVariable, void* aRetval);
-  static NPError NPP_SetValue(NPP aInstance, NPNVariable aVariable, void* aValue);
-  static NPError NPP_NewStream(NPP aInstance, NPMIMEType aType, NPStream* aStream,
-                               NPBool aSeekable, uint16_t* aStype);
-  static NPError NPP_SetWindow(NPP aInstance, NPWindow* aWindow);
-  static void NPP_Print(NPP aInstance, NPPrint* aPrintInfo);
-  static int16_t NPP_HandleEvent(NPP aInstance, void* aEvent);
-  static int32_t NPP_WriteReady(NPP aInstance, NPStream* aStream);
-
-  static NPObject* ScriptableAllocate(NPP aInstance, NPClass* aClass);
-  static void ScriptableInvalidate(NPObject* aObject);
-  static void ScriptableDeallocate(NPObject* aObject);
-  static bool ScriptableHasMethod(NPObject* aObject, NPIdentifier aName);
-  static bool ScriptableInvoke(NPObject* aObject, NPIdentifier aName,
-                               const NPVariant* aArgs, uint32_t aArgCount,
-                               NPVariant* aResult);
-  static bool ScriptableInvokeDefault(NPObject* aObject, const NPVariant* aArgs,
-                                      uint32_t aArgCount, NPVariant* aResult);
-  static bool ScriptableHasProperty(NPObject* aObject, NPIdentifier aName);
-  static bool ScriptableGetProperty(NPObject* aObject, NPIdentifier aName,
-                                    NPVariant* aResult);
-  static bool ScriptableSetProperty(NPObject* aObject, NPIdentifier aName,
-                                    const NPVariant* aValue);
-  static bool ScriptableRemoveProperty(NPObject* aObject, NPIdentifier aName);
-  static bool ScriptableEnumerate(NPObject* aObject, NPIdentifier** aIdentifiers,
-                                  uint32_t* aCount);
-  static bool ScriptableConstruct(NPObject* aObject, const NPVariant* aArgs,
-                                  uint32_t aArgCount, NPVariant* aResult);
-
-private:
-  struct PendingNewStreamCall
-  {
-    PendingNewStreamCall(NPMIMEType aType, NPStream* aStream, NPBool aSeekable);
-    ~PendingNewStreamCall() {}
-    nsCString   mType;
-    NPStream*   mStream;
-    NPBool      mSeekable;
-  };
-
-private:
-  PluginModuleParent*             mParent;
-  // These values are used to construct the plugin instance
-  nsCString                       mMimeType;
-  NPP                             mInstance;
-  uint16_t                        mMode;
-  InfallibleTArray<nsCString>     mNames;
-  InfallibleTArray<nsCString>     mValues;
-  // This is safe to store as a pointer because the spec says it will remain
-  // valid until destruction or a subsequent NPP_SetWindow call.
-  NPWindow*                       mWindow;
-  nsTArray<PendingNewStreamCall>  mPendingNewStreamCalls;
-  UniquePtr<PluginDestructionGuard> mPluginDestructionGuard;
-
-  bool      mAcceptCalls;
-  bool      mInstantiated;
-  bool      mAsyncSetWindow;
-  bool      mInitCancelled;
-  int32_t   mAsyncCallsInFlight;
-
-  static const NPClass sNPClass;
-};
-
-struct AsyncNPObject : NPObject
-{
-  explicit AsyncNPObject(PluginAsyncSurrogate* aSurrogate);
-  ~AsyncNPObject();
-
-  NPObject* GetRealObject();
-
-  nsRefPtr<PluginAsyncSurrogate>  mSurrogate;
-  NPObject*                       mRealObject;
-};
-
-class MOZ_STACK_CLASS PushSurrogateAcceptCalls
-{
-public:
-  explicit PushSurrogateAcceptCalls(PluginInstanceParent* aInstance);
-  ~PushSurrogateAcceptCalls();
-
-private:
-  PluginAsyncSurrogate* mSurrogate;
-  bool                  mPrevAcceptCallsState;
-};
-
-} // namespace plugins
-} // namespace mozilla
-
-#endif // dom_plugins_ipc_PluginAsyncSurrogate_h
deleted file mode 100644
--- a/dom/plugins/ipc/PluginDataResolver.h
+++ /dev/null
@@ -1,26 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=8 sts=2 et sw=2 tw=80: */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#ifndef dom_plugins_ipc_PluginDataResolver_h
-#define dom_plugins_ipc_PluginDataResolver_h
-
-namespace mozilla {
-namespace plugins {
-
-class PluginAsyncSurrogate;
-class PluginInstanceParent;
-
-class PluginDataResolver
-{
-public:
-    virtual PluginAsyncSurrogate* GetAsyncSurrogate() = 0;
-    virtual PluginInstanceParent* GetInstance() = 0;
-};
-
-} // namespace plugins
-} // namespace mozilla
-
-#endif // dom_plugins_ipc_PluginDataResolver_h
--- a/dom/plugins/ipc/PluginInstanceChild.cpp
+++ b/dom/plugins/ipc/PluginInstanceChild.cpp
@@ -114,26 +114,18 @@ CreateDrawTargetForSurface(gfxASurface *
   RefPtr<DrawTarget> drawTarget =
     Factory::CreateDrawTargetForCairoSurface(aSurface->CairoSurface(),
                                              ToIntSize(gfxIntSize(aSurface->GetSize())),
                                              &format);
   aSurface->SetData(&kDrawTarget, drawTarget, nullptr);
   return drawTarget;
 }
 
-PluginInstanceChild::PluginInstanceChild(const NPPluginFuncs* aPluginIface,
-                                         const nsCString& aMimeType,
-                                         const uint16_t& aMode,
-                                         const InfallibleTArray<nsCString>& aNames,
-                                         const InfallibleTArray<nsCString>& aValues)
+PluginInstanceChild::PluginInstanceChild(const NPPluginFuncs* aPluginIface)
     : mPluginIface(aPluginIface)
-    , mMimeType(aMimeType)
-    , mMode(aMode)
-    , mNames(aNames)
-    , mValues(aValues)
 #if defined(XP_MACOSX)
     , mContentsScaleFactor(1.0)
 #endif
     , mDrawingModel(kDefaultDrawingModel)
     , mAsyncInvalidateMutex("PluginInstanceChild::mAsyncInvalidateMutex")
     , mAsyncInvalidateTask(0)
     , mCachedWindowActor(nullptr)
     , mCachedElementActor(nullptr)
@@ -213,64 +205,16 @@ PluginInstanceChild::~PluginInstanceChil
         PluginUtilsOSX::ReleaseCGLayer(mCGLayer);
     }
     if (mDrawingModel == NPDrawingModelCoreAnimation) {
         UnscheduleTimer(mCARefreshTimer);
     }
 #endif
 }
 
-NPError
-PluginInstanceChild::DoNPP_New()
-{
-    // unpack the arguments into a C format
-    int argc = mNames.Length();
-    NS_ASSERTION(argc == (int) mValues.Length(),
-                 "argn.length != argv.length");
-
-    nsAutoArrayPtr<char*> argn(new char*[1 + argc]);
-    nsAutoArrayPtr<char*> argv(new char*[1 + argc]);
-    argn[argc] = 0;
-    argv[argc] = 0;
-
-    for (int i = 0; i < argc; ++i) {
-        argn[i] = const_cast<char*>(NullableStringGet(mNames[i]));
-        argv[i] = const_cast<char*>(NullableStringGet(mValues[i]));
-    }
-
-    NPP npp = GetNPP();
-
-    NPError rv = mPluginIface->newp((char*)NullableStringGet(mMimeType), npp,
-                                    mMode, argc, argn, argv, 0);
-    if (NPERR_NO_ERROR != rv) {
-        return rv;
-    }
-
-    Initialize();
-
-#if defined(XP_MACOSX) && defined(__i386__)
-    // If an i386 Mac OS X plugin has selected the Carbon event model then
-    // we have to fail. We do not support putting Carbon event model plugins
-    // out of process. Note that Carbon is the default model so out of process
-    // plugins need to actively negotiate something else in order to work
-    // out of process.
-    if (EventModel() == NPEventModelCarbon) {
-      // Send notification that a plugin tried to negotiate Carbon NPAPI so that
-      // users can be notified that restarting the browser in i386 mode may allow
-      // them to use the plugin.
-      SendNegotiatedCarbon();
-
-      // Fail to instantiate.
-      rv = NPERR_MODULE_LOAD_FAILED_ERROR;
-    }
-#endif
-
-    return rv;
-}
-
 int
 PluginInstanceChild::GetQuirks()
 {
     return PluginModuleChild::GetChrome()->GetQuirks();
 }
 
 NPError
 PluginInstanceChild::InternalGetNPObjectForValue(NPNVariable aValue,
@@ -2285,110 +2229,49 @@ PluginInstanceChild::RecvPPluginScriptab
 
     actor->InitializeProxy();
     NS_ASSERTION(actor->GetObject(false), "Actor should have an object!");
 
     return true;
 }
 
 bool
-PluginInstanceChild::RecvPBrowserStreamConstructor(
+PluginInstanceChild::AnswerPBrowserStreamConstructor(
     PBrowserStreamChild* aActor,
     const nsCString& url,
     const uint32_t& length,
     const uint32_t& lastmodified,
     PStreamNotifyChild* notifyData,
-    const nsCString& headers)
-{
-    return true;
-}
-
-NPError
-PluginInstanceChild::DoNPP_NewStream(BrowserStreamChild* actor,
-                                     const nsCString& mimeType,
-                                     const bool& seekable,
-                                     uint16_t* stype)
+    const nsCString& headers,
+    const nsCString& mimeType,
+    const bool& seekable,
+    NPError* rv,
+    uint16_t* stype)
 {
     AssertPluginThread();
-    NPError rv = actor->StreamConstructed(mimeType, seekable, stype);
-    return rv;
-}
-
-bool
-PluginInstanceChild::AnswerNPP_NewStream(PBrowserStreamChild* actor,
-                                         const nsCString& mimeType,
-                                         const bool& seekable,
-                                         NPError* rv,
-                                         uint16_t* stype)
-{
-    *rv = DoNPP_NewStream(static_cast<BrowserStreamChild*>(actor), mimeType,
-                          seekable, stype);
-    return true;
-}
-
-class NewStreamAsyncCall : public ChildAsyncCall
-{
-public:
-    NewStreamAsyncCall(PluginInstanceChild* aInstance,
-                       BrowserStreamChild* aBrowserStreamChild,
-                       const nsCString& aMimeType,
-                       const bool aSeekable)
-        : ChildAsyncCall(aInstance, nullptr, nullptr)
-        , mBrowserStreamChild(aBrowserStreamChild)
-        , mMimeType(aMimeType)
-        , mSeekable(aSeekable)
-    {
-    }
-
-    void Run() MOZ_OVERRIDE
-    {
-        RemoveFromAsyncList();
-
-        uint16_t stype = NP_NORMAL;
-        NPError rv = mInstance->DoNPP_NewStream(mBrowserStreamChild, mMimeType,
-                                                mSeekable, &stype);
-        DebugOnly<bool> sendOk =
-            mBrowserStreamChild->SendAsyncNPP_NewStreamResult(rv, stype);
-        MOZ_ASSERT(sendOk);
-    }
-
-private:
-    BrowserStreamChild* mBrowserStreamChild;
-    const nsCString     mMimeType;
-    const bool          mSeekable;
-};
-
-bool
-PluginInstanceChild::RecvAsyncNPP_NewStream(PBrowserStreamChild* actor,
-                                            const nsCString& mimeType,
-                                            const bool& seekable)
-{
-    // Reusing ChildAsyncCall so that the task is cancelled properly on Destroy
-    BrowserStreamChild* child = static_cast<BrowserStreamChild*>(actor);
-    NewStreamAsyncCall* task = new NewStreamAsyncCall(this, child, mimeType,
-                                                      seekable);
-    {
-        MutexAutoLock lock(mAsyncCallMutex);
-        mPendingAsyncCalls.AppendElement(task);
-    }
-    MessageLoop::current()->PostTask(FROM_HERE, task);
+    *rv = static_cast<BrowserStreamChild*>(aActor)
+          ->StreamConstructed(mimeType, seekable, stype);
     return true;
 }
 
 PBrowserStreamChild*
 PluginInstanceChild::AllocPBrowserStreamChild(const nsCString& url,
                                               const uint32_t& length,
                                               const uint32_t& lastmodified,
                                               PStreamNotifyChild* notifyData,
-                                              const nsCString& headers)
+                                              const nsCString& headers,
+                                              const nsCString& mimeType,
+                                              const bool& seekable,
+                                              NPError* rv,
+                                              uint16_t *stype)
 {
     AssertPluginThread();
     return new BrowserStreamChild(this, url, length, lastmodified,
                                   static_cast<StreamNotifyChild*>(notifyData),
-                                  headers);
+                                  headers, mimeType, seekable, rv, stype);
 }
 
 bool
 PluginInstanceChild::DeallocPBrowserStreamChild(PBrowserStreamChild* stream)
 {
     AssertPluginThread();
     delete stream;
     return true;
--- a/dom/plugins/ipc/PluginInstanceChild.h
+++ b/dom/plugins/ipc/PluginInstanceChild.h
@@ -138,41 +138,39 @@ protected:
     AllocPPluginScriptableObjectChild() MOZ_OVERRIDE;
 
     virtual bool
     DeallocPPluginScriptableObjectChild(PPluginScriptableObjectChild* aObject) MOZ_OVERRIDE;
 
     virtual bool
     RecvPPluginScriptableObjectConstructor(PPluginScriptableObjectChild* aActor) MOZ_OVERRIDE;
 
-    virtual bool
-    RecvPBrowserStreamConstructor(PBrowserStreamChild* aActor, const nsCString& url,
-                                  const uint32_t& length, const uint32_t& lastmodified,
-                                  PStreamNotifyChild* notifyData, const nsCString& headers);
-
-    virtual bool
-    AnswerNPP_NewStream(
-            PBrowserStreamChild* actor,
-            const nsCString& mimeType,
-            const bool& seekable,
-            NPError* rv,
-            uint16_t* stype) MOZ_OVERRIDE;
-
-    virtual bool
-    RecvAsyncNPP_NewStream(
-            PBrowserStreamChild* actor,
-            const nsCString& mimeType,
-            const bool& seekable) MOZ_OVERRIDE;
-
     virtual PBrowserStreamChild*
     AllocPBrowserStreamChild(const nsCString& url,
                              const uint32_t& length,
                              const uint32_t& lastmodified,
                              PStreamNotifyChild* notifyData,
-                             const nsCString& headers) MOZ_OVERRIDE;
+                             const nsCString& headers,
+                             const nsCString& mimeType,
+                             const bool& seekable,
+                             NPError* rv,
+                             uint16_t *stype) MOZ_OVERRIDE;
+
+    virtual bool
+    AnswerPBrowserStreamConstructor(
+            PBrowserStreamChild* aActor,
+            const nsCString& url,
+            const uint32_t& length,
+            const uint32_t& lastmodified,
+            PStreamNotifyChild* notifyData,
+            const nsCString& headers,
+            const nsCString& mimeType,
+            const bool& seekable,
+            NPError* rv,
+            uint16_t* stype) MOZ_OVERRIDE;
 
     virtual bool
     DeallocPBrowserStreamChild(PBrowserStreamChild* stream) MOZ_OVERRIDE;
 
     virtual PPluginStreamChild*
     AllocPPluginStreamChild(const nsCString& mimeType,
                             const nsCString& target,
                             NPError* result) MOZ_OVERRIDE;
@@ -199,32 +197,20 @@ protected:
     RecvNPP_DidComposite() MOZ_OVERRIDE;
 
 #if defined(MOZ_X11) && defined(XP_UNIX) && !defined(XP_MACOSX)
     bool CreateWindow(const NPRemoteWindow& aWindow);
     void DeleteWindow();
 #endif
 
 public:
-    PluginInstanceChild(const NPPluginFuncs* aPluginIface,
-                        const nsCString& aMimeType,
-                        const uint16_t& aMode,
-                        const InfallibleTArray<nsCString>& aNames,
-                        const InfallibleTArray<nsCString>& aValues);
+    explicit PluginInstanceChild(const NPPluginFuncs* aPluginIface);
 
     virtual ~PluginInstanceChild();
 
-    NPError DoNPP_New();
-
-    // Common sync+async implementation of NPP_NewStream
-    NPError DoNPP_NewStream(BrowserStreamChild* actor,
-                            const nsCString& mimeType,
-                            const bool& seekable,
-                            uint16_t* stype);
-
     bool Initialize();
 
     NPP GetNPP()
     {
         return &mData;
     }
 
     NPError
@@ -361,20 +347,16 @@ private:
         UINT                 mMsg;
         WPARAM               mWParam;
         LPARAM               mLParam;
         bool                 mWindowed;
     };
 
 #endif
     const NPPluginFuncs* mPluginIface;
-    nsCString                   mMimeType;
-    uint16_t                    mMode;
-    InfallibleTArray<nsCString> mNames;
-    InfallibleTArray<nsCString> mValues;
     NPP_t mData;
     NPWindow mWindow;
 #if defined(XP_MACOSX)
     double mContentsScaleFactor;
 #endif
     int16_t               mDrawingModel;
 
     mozilla::Mutex mAsyncInvalidateMutex;
--- a/dom/plugins/ipc/PluginInstanceParent.cpp
+++ b/dom/plugins/ipc/PluginInstanceParent.cpp
@@ -5,29 +5,27 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "mozilla/DebugOnly.h"
 #include <stdint.h> // for intptr_t
 
 #include "mozilla/Telemetry.h"
 #include "PluginInstanceParent.h"
 #include "BrowserStreamParent.h"
-#include "PluginAsyncSurrogate.h"
 #include "PluginBackgroundDestroyer.h"
 #include "PluginModuleParent.h"
 #include "PluginStreamParent.h"
 #include "StreamNotifyParent.h"
 #include "npfunctions.h"
 #include "nsAutoPtr.h"
 #include "gfxASurface.h"
 #include "gfxContext.h"
 #include "gfxPlatform.h"
 #include "gfxSharedImageSurface.h"
 #include "nsNPAPIPluginInstance.h"
-#include "nsPluginInstanceOwner.h"
 #ifdef MOZ_X11
 #include "gfxXlibSurface.h"
 #endif
 #include "gfxContext.h"
 #include "gfxColor.h"
 #include "gfxUtils.h"
 #include "mozilla/gfx/2D.h"
 #include "Layers.h"
@@ -72,19 +70,17 @@ StreamNotifyParent::RecvRedirectNotifyRe
   instance->mNPNIface->urlredirectresponse(instance->mNPP, this, static_cast<NPBool>(allow));
   return true;
 }
 
 PluginInstanceParent::PluginInstanceParent(PluginModuleParent* parent,
                                            NPP npp,
                                            const nsCString& aMimeType,
                                            const NPNetscapeFuncs* npniface)
-    : mParent(parent)
-    , mSurrogate(PluginAsyncSurrogate::Cast(npp))
-    , mUseSurrogate(true)
+  : mParent(parent)
     , mNPP(npp)
     , mNPNIface(npniface)
     , mWindowType(NPWindowTypeWindow)
     , mDrawingModel(kDefaultDrawingModel)
 #if defined(OS_WIN)
     , mPluginHWND(nullptr)
     , mPluginWndProc(nullptr)
     , mNestedEventState(false)
@@ -166,17 +162,21 @@ PluginInstanceParent::Destroy()
     return retval;
 }
 
 PBrowserStreamParent*
 PluginInstanceParent::AllocPBrowserStreamParent(const nsCString& url,
                                                 const uint32_t& length,
                                                 const uint32_t& lastmodified,
                                                 PStreamNotifyParent* notifyData,
-                                                const nsCString& headers)
+                                                const nsCString& headers,
+                                                const nsCString& mimeType,
+                                                const bool& seekable,
+                                                NPError* rv,
+                                                uint16_t *stype)
 {
     NS_RUNTIMEABORT("Not reachable");
     return nullptr;
 }
 
 bool
 PluginInstanceParent::DeallocPBrowserStreamParent(PBrowserStreamParent* stream)
 {
@@ -778,22 +778,16 @@ PluginInstanceParent::EndUpdateBackgroun
     XSync(DefaultXDisplay(), False);
 #endif
 
     unused << SendUpdateBackground(BackgroundDescriptor(), aRect);
 
     return NS_OK;
 }
 
-PluginAsyncSurrogate*
-PluginInstanceParent::GetAsyncSurrogate()
-{
-    return mSurrogate;
-}
-
 bool
 PluginInstanceParent::CreateBackground(const nsIntSize& aSize)
 {
     NS_ABORT_IF_FALSE(!mBackground, "Already have a background");
 
     // XXX refactor me
 
 #if defined(MOZ_X11)
@@ -1310,46 +1304,34 @@ NPError
 PluginInstanceParent::NPP_NewStream(NPMIMEType type, NPStream* stream,
                                     NPBool seekable, uint16_t* stype)
 {
     PLUGIN_LOG_DEBUG(("%s (type=%s, stream=%p, seekable=%i)",
                       FULLFUNCTION, (char*) type, (void*) stream, (int) seekable));
 
     BrowserStreamParent* bs = new BrowserStreamParent(this, stream);
 
-    if (!SendPBrowserStreamConstructor(bs,
-                                       NullableString(stream->url),
-                                       stream->end,
-                                       stream->lastmodified,
-                                       static_cast<PStreamNotifyParent*>(stream->notifyData),
-                                       NullableString(stream->headers))) {
-        return NPERR_GENERIC_ERROR;
+    NPError err;
+    {   // Scope for timer
+        Telemetry::AutoTimer<Telemetry::BLOCKED_ON_PLUGIN_STREAM_INIT_MS>
+            timer(Module()->GetHistogramKey());
+        if (!CallPBrowserStreamConstructor(bs,
+                                           NullableString(stream->url),
+                                           stream->end,
+                                           stream->lastmodified,
+                                           static_cast<PStreamNotifyParent*>(stream->notifyData),
+                                           NullableString(stream->headers),
+                                           NullableString(type), seekable,
+                                           &err, stype)) {
+            return NPERR_GENERIC_ERROR;
+        }
     }
 
-    Telemetry::AutoTimer<Telemetry::BLOCKED_ON_PLUGIN_STREAM_INIT_MS>
-        timer(Module()->GetHistogramKey());
-
-    NPError err = NPERR_NO_ERROR;
-    if (mParent->IsStartingAsync()) {
-        MOZ_ASSERT(mSurrogate);
-        mSurrogate->AsyncCallDeparting();
-        if (SendAsyncNPP_NewStream(bs, NullableString(type), seekable)) {
-            *stype = UINT16_MAX;
-        } else {
-            err = NPERR_GENERIC_ERROR;
-        }
-    } else {
-        bs->SetAlive();
-        if (!CallNPP_NewStream(bs, NullableString(type), seekable, &err, stype)) {
-            err = NPERR_GENERIC_ERROR;
-        }
-        if (NPERR_NO_ERROR != err) {
-            unused << PBrowserStreamParent::Send__delete__(bs);
-        }
-    }
+    if (NPERR_NO_ERROR != err)
+        unused << PBrowserStreamParent::Send__delete__(bs);
 
     return err;
 }
 
 NPError
 PluginInstanceParent::NPP_DestroyStream(NPStream* stream, NPReason reason)
 {
     PLUGIN_LOG_DEBUG(("%s (stream=%p, reason=%i)",
@@ -1649,59 +1631,16 @@ PluginInstanceParent::RecvNegotiatedCarb
     nsNPAPIPluginInstance *inst = static_cast<nsNPAPIPluginInstance*>(mNPP->ndata);
     if (!inst) {
         return false;
     }
     inst->CarbonNPAPIFailure();
     return true;
 }
 
-nsPluginInstanceOwner*
-PluginInstanceParent::GetOwner()
-{
-    nsNPAPIPluginInstance* inst = static_cast<nsNPAPIPluginInstance*>(mNPP->ndata);
-    if (!inst) {
-        return nullptr;
-    }
-    return inst->GetOwner();
-}
-
-bool
-PluginInstanceParent::RecvAsyncNPP_NewResult(const NPError& aResult)
-{
-    // NB: mUseSurrogate must be cleared before doing anything else, especially
-    //     calling NPP_SetWindow!
-    mUseSurrogate = false;
-
-    mSurrogate->AsyncCallArriving();
-    if (aResult == NPERR_NO_ERROR) {
-        mSurrogate->SetAcceptingCalls(true);
-    }
-
-    nsPluginInstanceOwner* owner = GetOwner();
-    if (!owner) {
-        // This is possible in async plugin land; the instance may outlive
-        // the owner
-        return true;
-    }
-
-    if (aResult != NPERR_NO_ERROR) {
-        owner->NotifyHostAsyncInitFailed();
-        return true;
-    }
-
-    // Now we need to do a bunch of exciting post-NPP_New housekeeping.
-    owner->NotifyHostCreateWidget();
-
-    MOZ_ASSERT(mSurrogate);
-    mSurrogate->OnInstanceCreated(this);
-
-    return true;
-}
-
 #if defined(OS_WIN)
 
 /*
   plugin focus changes between processes
 
   focus from dom -> child:
     Focus manager calls on widget to set the focus on the window.
     We pick up the resulting wm_setfocus event here, and forward
@@ -1931,34 +1870,8 @@ PluginInstanceParent::AnswerPluginFocusC
       ::SendMessage(mPluginHWND, gOOPPPluginFocusEvent, gotFocus ? 1 : 0, 0);
     }
     return true;
 #else
     NS_NOTREACHED("PluginInstanceParent::AnswerPluginFocusChange not implemented!");
     return false;
 #endif
 }
-
-PluginInstanceParent*
-PluginInstanceParent::Cast(NPP aInstance, PluginAsyncSurrogate** aSurrogate)
-{
-    PluginDataResolver* resolver =
-        static_cast<PluginDataResolver*>(aInstance->pdata);
-
-    // If the plugin crashed and the PluginInstanceParent was deleted,
-    // aInstance->pdata will be nullptr.
-    if (!resolver) {
-        return nullptr;
-    }
-
-    PluginInstanceParent* instancePtr = resolver->GetInstance();
-
-    if (instancePtr && aInstance != instancePtr->mNPP) {
-        NS_RUNTIMEABORT("Corrupted plugin data.");
-    }
-
-    if (aSurrogate) {
-        *aSurrogate = resolver->GetAsyncSurrogate();
-    }
-
-    return instancePtr;
-}
-
--- a/dom/plugins/ipc/PluginInstanceParent.h
+++ b/dom/plugins/ipc/PluginInstanceParent.h
@@ -17,39 +17,36 @@
 #include "mozilla/gfx/QuartzSupport.h"
 #endif
 
 #include "npfunctions.h"
 #include "nsAutoPtr.h"
 #include "nsDataHashtable.h"
 #include "nsHashKeys.h"
 #include "nsRect.h"
-#include "PluginDataResolver.h"
 
 #ifdef MOZ_X11
 class gfxXlibSurface;
 #endif
 #include "mozilla/unused.h"
 
 class gfxASurface;
 class gfxContext;
-class nsPluginInstanceOwner;
 
 namespace mozilla {
 namespace layers {
 class ImageContainer;
 class CompositionNotifySink;
 }
 namespace plugins {
 
 class PBrowserStreamParent;
 class PluginModuleParent;
 
 class PluginInstanceParent : public PPluginInstanceParent
-                           , public PluginDataResolver
 {
     friend class PluginModuleParent;
     friend class BrowserStreamParent;
     friend class PluginStreamParent;
     friend class StreamNotifyParent;
 
 public:
     PluginInstanceParent(PluginModuleParent* parent,
@@ -72,17 +69,21 @@ public:
 
     virtual bool
     DeallocPPluginScriptableObjectParent(PPluginScriptableObjectParent* aObject) MOZ_OVERRIDE;
     virtual PBrowserStreamParent*
     AllocPBrowserStreamParent(const nsCString& url,
                               const uint32_t& length,
                               const uint32_t& lastmodified,
                               PStreamNotifyParent* notifyData,
-                              const nsCString& headers) MOZ_OVERRIDE;
+                              const nsCString& headers,
+                              const nsCString& mimeType,
+                              const bool& seekable,
+                              NPError* rv,
+                              uint16_t *stype) MOZ_OVERRIDE;
     virtual bool
     DeallocPBrowserStreamParent(PBrowserStreamParent* stream) MOZ_OVERRIDE;
 
     virtual PPluginStreamParent*
     AllocPPluginStreamParent(const nsCString& mimeType,
                              const nsCString& target,
                              NPError* result) MOZ_OVERRIDE;
     virtual bool
@@ -204,19 +205,16 @@ public:
                            bool *result) MOZ_OVERRIDE;
 
     virtual bool
     RecvRedrawPlugin() MOZ_OVERRIDE;
 
     virtual bool
     RecvNegotiatedCarbon() MOZ_OVERRIDE;
 
-    virtual bool
-    RecvAsyncNPP_NewResult(const NPError& aResult) MOZ_OVERRIDE;
-
     NPError NPP_SetWindow(const NPWindow* aWindow);
 
     NPError NPP_GetValue(NPPVariable variable, void* retval);
     NPError NPP_SetValue(NPNVariable variable, void* value);
 
     void NPP_URLRedirectNotify(const char* url, int32_t status,
                                void* notifyData);
 
@@ -251,22 +249,16 @@ public:
     GetActorForNPObject(NPObject* aObject);
 
     NPP
     GetNPP()
     {
       return mNPP;
     }
 
-    bool
-    UseSurrogate() const
-    {
-        return mUseSurrogate;
-    }
-
     virtual bool
     AnswerPluginFocusChange(const bool& gotFocus) MOZ_OVERRIDE;
 
     nsresult AsyncSetWindow(NPWindow* window);
     nsresult GetImageContainer(mozilla::layers::ImageContainer** aContainer);
     nsresult GetImageSize(nsIntSize* aSize);
 #ifdef XP_MACOSX
     nsresult IsRemoteDrawingCoreAnimation(bool *aDrawing);
@@ -274,23 +266,16 @@ public:
 #endif
     nsresult SetBackgroundUnknown();
     nsresult BeginUpdateBackground(const nsIntRect& aRect,
                                    gfxContext** aCtx);
     nsresult EndUpdateBackground(gfxContext* aCtx,
                                  const nsIntRect& aRect);
     void DidComposite() { unused << SendNPP_DidComposite(); }
 
-    virtual PluginAsyncSurrogate* GetAsyncSurrogate();
-
-    virtual PluginInstanceParent* GetInstance() { return this; }
-
-    static PluginInstanceParent* Cast(NPP instance,
-                                      PluginAsyncSurrogate** aSurrogate = nullptr);
-
 private:
     // Create an appropriate platform surface for a background of size
     // |aSize|.  Return true if successful.
     bool CreateBackground(const nsIntSize& aSize);
     void DestroyBackground();
     SurfaceDescriptor BackgroundDescriptor() /*const*/;
 
     typedef mozilla::layers::ImageContainer ImageContainer;
@@ -301,22 +286,18 @@ private:
 
     virtual bool
     DeallocPPluginBackgroundDestroyerParent(PPluginBackgroundDestroyerParent* aActor) MOZ_OVERRIDE;
 
     bool InternalGetValueForNPObject(NPNVariable aVariable,
                                      PPluginScriptableObjectParent** aValue,
                                      NPError* aResult);
 
-    nsPluginInstanceOwner* GetOwner();
-
 private:
     PluginModuleParent* mParent;
-    nsRefPtr<PluginAsyncSurrogate> mSurrogate;
-    bool mUseSurrogate;
     NPP mNPP;
     const NPNetscapeFuncs* mNPNIface;
     NPWindowType mWindowType;
     int16_t            mDrawingModel;
     nsAutoPtr<mozilla::layers::CompositionNotifySink> mNotifySink;
 
     nsDataHashtable<nsPtrHashKey<NPObject>, PluginScriptableObjectParent*> mScriptableObjects;
 
--- a/dom/plugins/ipc/PluginModuleChild.cpp
+++ b/dom/plugins/ipc/PluginModuleChild.cpp
@@ -90,23 +90,16 @@ static WCHAR* sReplacementConfigFile;
 static bool gDelayFlashFocusReplyUntilEval = false;
 // Used to fix GetWindowInfo problems with internal flash settings dialogs
 static WindowsDllInterceptor sUser32Intercept;
 typedef BOOL (WINAPI *GetWindowInfoPtr)(HWND hwnd, PWINDOWINFO pwi);
 static GetWindowInfoPtr sGetWindowInfoPtrStub = nullptr;
 static HWND sBrowserHwnd = nullptr;
 #endif
 
-template<>
-struct RunnableMethodTraits<PluginModuleChild>
-{
-    static void RetainCallee(PluginModuleChild* obj) { }
-    static void ReleaseCallee(PluginModuleChild* obj) { }
-};
-
 /* static */
 PluginModuleChild*
 PluginModuleChild::CreateForContentProcess(mozilla::ipc::Transport* aTransport,
                                            base::ProcessId aOtherProcess)
 {
     PluginModuleChild* child = new PluginModuleChild(false);
     ProcessHandle handle;
     if (!base::OpenProcessHandle(aOtherProcess, &handle)) {
@@ -1883,31 +1876,17 @@ PluginModuleChild::AnswerNP_GetEntryPoin
     *_retval = mGetEntryPointsFunc(&mFunctions);
     return true;
 #else
 #  error Please implement me for your platform
 #endif
 }
 
 bool
-PluginModuleChild::AnswerNP_Initialize(const PluginSettings& aSettings, NPError* rv)
-{
-    *rv = DoNP_Initialize(aSettings);
-    return true;
-}
-
-bool
-PluginModuleChild::RecvAsyncNP_Initialize(const PluginSettings& aSettings)
-{
-    NPError error = DoNP_Initialize(aSettings);
-    return SendNP_InitializeResult(error);
-}
-
-NPError
-PluginModuleChild::DoNP_Initialize(const PluginSettings& aSettings)
+PluginModuleChild::AnswerNP_Initialize(const PluginSettings& aSettings, NPError* _retval)
 {
     PLUGIN_LOG_DEBUG_METHOD;
     AssertPluginThread();
     MOZ_ASSERT(mIsChrome);
 
     mCachedSettings = aSettings;
 
 #ifdef OS_WIN
@@ -1916,30 +1895,29 @@ PluginModuleChild::DoNP_Initialize(const
 
 #ifdef MOZ_X11
     // Send the parent our X socket to act as a proxy reference for our X
     // resources.
     int xSocketFd = ConnectionNumber(DefaultXDisplay());
     SendBackUpXResources(FileDescriptor(xSocketFd));
 #endif
 
-    NPError result;
 #if defined(OS_LINUX) || defined(OS_BSD)
-    result = mInitializeFunc(&sBrowserFuncs, &mFunctions);
+    *_retval = mInitializeFunc(&sBrowserFuncs, &mFunctions);
+    return true;
 #elif defined(OS_WIN) || defined(OS_MACOSX)
-    result = mInitializeFunc(&sBrowserFuncs);
+    *_retval = mInitializeFunc(&sBrowserFuncs);
+    return true;
 #else
 #  error Please implement me for your platform
 #endif
 
 #ifdef XP_WIN
     CleanupProtectedModeHook();
 #endif
-
-    return result;
 }
 
 #if defined(XP_WIN)
 
 HANDLE WINAPI
 CreateFileHookFn(LPCWSTR fname, DWORD access, DWORD share,
                  LPSECURITY_ATTRIBUTES security, DWORD creation, DWORD flags,
                  HANDLE ftemplate)
@@ -2052,34 +2030,34 @@ PMCGetWindowInfoHook(HWND hWnd, PWINDOWI
   return result;
 }
 #endif
 
 PPluginInstanceChild*
 PluginModuleChild::AllocPPluginInstanceChild(const nsCString& aMimeType,
                                              const uint16_t& aMode,
                                              const InfallibleTArray<nsCString>& aNames,
-                                             const InfallibleTArray<nsCString>& aValues)
+                                             const InfallibleTArray<nsCString>& aValues,
+                                             NPError* rv)
 {
     PLUGIN_LOG_DEBUG_METHOD;
     AssertPluginThread();
 
     InitQuirksModes(aMimeType);
 
 #ifdef XP_WIN
     if ((mQuirks & QUIRK_FLASH_HOOK_GETWINDOWINFO) &&
         !sGetWindowInfoPtrStub) {
         sUser32Intercept.Init("user32.dll");
         sUser32Intercept.AddHook("GetWindowInfo", reinterpret_cast<intptr_t>(PMCGetWindowInfoHook),
                                  (void**) &sGetWindowInfoPtrStub);
     }
 #endif
 
-    return new PluginInstanceChild(&mFunctions, aMimeType, aMode, aNames,
-                                   aValues);
+    return new PluginInstanceChild(&mFunctions);
 }
 
 void
 PluginModuleChild::InitQuirksModes(const nsCString& aMimeType)
 {
     if (mQuirks != QUIRKS_NOT_INITIALIZED)
       return;
     mQuirks = 0;
@@ -2122,49 +2100,78 @@ PluginModuleChild::InitQuirksModes(const
     if (FindInReadable(flash, aMimeType) ||
         FindInReadable(quicktime, mPluginFilename)) {
         mQuirks |= QUIRK_ALLOW_OFFLINE_RENDERER;
     }
 #endif
 }
 
 bool
-PluginModuleChild::RecvPPluginInstanceConstructor(PPluginInstanceChild* aActor,
-                                                  const nsCString& aMimeType,
-                                                  const uint16_t& aMode,
-                                                  const InfallibleTArray<nsCString>& aNames,
-                                                  const InfallibleTArray<nsCString>& aValues)
+PluginModuleChild::AnswerPPluginInstanceConstructor(PPluginInstanceChild* aActor,
+                                                    const nsCString& aMimeType,
+                                                    const uint16_t& aMode,
+                                                    const InfallibleTArray<nsCString>& aNames,
+                                                    const InfallibleTArray<nsCString>& aValues,
+                                                    NPError* rv)
 {
     PLUGIN_LOG_DEBUG_METHOD;
     AssertPluginThread();
 
-    NS_ASSERTION(aActor, "Null actor!");
-    return true;
-}
-
-bool
-PluginModuleChild::AnswerSyncNPP_New(PPluginInstanceChild* aActor, NPError* rv)
-{
-    PLUGIN_LOG_DEBUG_METHOD;
     PluginInstanceChild* childInstance =
         reinterpret_cast<PluginInstanceChild*>(aActor);
-    AssertPluginThread();
-    *rv = childInstance->DoNPP_New();
-    return true;
-}
-
-bool
-PluginModuleChild::RecvAsyncNPP_New(PPluginInstanceChild* aActor)
-{
-    PLUGIN_LOG_DEBUG_METHOD;
-    PluginInstanceChild* childInstance =
-        reinterpret_cast<PluginInstanceChild*>(aActor);
-    AssertPluginThread();
-    NPError rv = childInstance->DoNPP_New();
-    childInstance->SendAsyncNPP_NewResult(rv);
+    NS_ASSERTION(childInstance, "Null actor!");
+
+    // unpack the arguments into a C format
+    int argc = aNames.Length();
+    NS_ASSERTION(argc == (int) aValues.Length(),
+                 "argn.length != argv.length");
+
+    nsAutoArrayPtr<char*> argn(new char*[1 + argc]);
+    nsAutoArrayPtr<char*> argv(new char*[1 + argc]);
+    argn[argc] = 0;
+    argv[argc] = 0;
+
+    for (int i = 0; i < argc; ++i) {
+        argn[i] = const_cast<char*>(NullableStringGet(aNames[i]));
+        argv[i] = const_cast<char*>(NullableStringGet(aValues[i]));
+    }
+
+    NPP npp = childInstance->GetNPP();
+
+    // FIXME/cjones: use SAFE_CALL stuff
+    *rv = mFunctions.newp((char*)NullableStringGet(aMimeType),
+                          npp,
+                          aMode,
+                          argc,
+                          argn,
+                          argv,
+                          0);
+    if (NPERR_NO_ERROR != *rv) {
+        return true;
+    }
+
+    childInstance->Initialize();
+
+#if defined(XP_MACOSX) && defined(__i386__)
+    // If an i386 Mac OS X plugin has selected the Carbon event model then
+    // we have to fail. We do not support putting Carbon event model plugins
+    // out of process. Note that Carbon is the default model so out of process
+    // plugins need to actively negotiate something else in order to work
+    // out of process.
+    if (childInstance->EventModel() == NPEventModelCarbon) {
+      // Send notification that a plugin tried to negotiate Carbon NPAPI so that
+      // users can be notified that restarting the browser in i386 mode may allow
+      // them to use the plugin.
+      childInstance->SendNegotiatedCarbon();
+
+      // Fail to instantiate.
+      *rv = NPERR_MODULE_LOAD_FAILED_ERROR;
+    }
+#endif
+
     return true;
 }
 
 bool
 PluginModuleChild::DeallocPPluginInstanceChild(PPluginInstanceChild* aActor)
 {
     PLUGIN_LOG_DEBUG_METHOD;
     AssertPluginThread();
--- a/dom/plugins/ipc/PluginModuleChild.h
+++ b/dom/plugins/ipc/PluginModuleChild.h
@@ -73,42 +73,38 @@ protected:
     virtual bool ShouldContinueFromReplyTimeout() MOZ_OVERRIDE;
 
     virtual bool RecvSettingChanged(const PluginSettings& aSettings) MOZ_OVERRIDE;
 
     // Implement the PPluginModuleChild interface
     virtual bool RecvDisableFlashProtectedMode() MOZ_OVERRIDE;
     virtual bool AnswerNP_GetEntryPoints(NPError* rv) MOZ_OVERRIDE;
     virtual bool AnswerNP_Initialize(const PluginSettings& aSettings, NPError* rv) MOZ_OVERRIDE;
-    virtual bool RecvAsyncNP_Initialize(const PluginSettings& aSettings) MOZ_OVERRIDE;
-    virtual bool AnswerSyncNPP_New(PPluginInstanceChild* aActor, NPError* rv)
-                                   MOZ_OVERRIDE;
-    virtual bool RecvAsyncNPP_New(PPluginInstanceChild* aActor) MOZ_OVERRIDE;
 
     virtual PPluginModuleChild*
     AllocPPluginModuleChild(mozilla::ipc::Transport* aTransport,
                             base::ProcessId aOtherProcess) MOZ_OVERRIDE;
 
     virtual PPluginInstanceChild*
     AllocPPluginInstanceChild(const nsCString& aMimeType,
                               const uint16_t& aMode,
                               const InfallibleTArray<nsCString>& aNames,
-                              const InfallibleTArray<nsCString>& aValues)
-                              MOZ_OVERRIDE;
+                              const InfallibleTArray<nsCString>& aValues,
+                              NPError* rv) MOZ_OVERRIDE;
 
     virtual bool
     DeallocPPluginInstanceChild(PPluginInstanceChild* aActor) MOZ_OVERRIDE;
 
     virtual bool
-    RecvPPluginInstanceConstructor(PPluginInstanceChild* aActor,
-                                   const nsCString& aMimeType,
-                                   const uint16_t& aMode,
-                                   const InfallibleTArray<nsCString>& aNames,
-                                   const InfallibleTArray<nsCString>& aValues)
-                                   MOZ_OVERRIDE;
+    AnswerPPluginInstanceConstructor(PPluginInstanceChild* aActor,
+                                     const nsCString& aMimeType,
+                                     const uint16_t& aMode,
+                                     const InfallibleTArray<nsCString>& aNames,
+                                     const InfallibleTArray<nsCString>& aValues,
+                                     NPError* rv) MOZ_OVERRIDE;
     virtual bool
     AnswerNP_Shutdown(NPError *rv) MOZ_OVERRIDE;
 
     virtual bool
     AnswerOptionalFunctionsSupported(bool *aURLRedirectNotify,
                                      bool *aClearSiteData,
                                      bool *aGetSitesWithData) MOZ_OVERRIDE;
 
@@ -285,17 +281,16 @@ public:
         QUIRK_FLASH_AVOID_CGMODE_CRASHES                = 1 << 10,
     };
 
     int GetQuirks() { return mQuirks; }
 
     const PluginSettings& Settings() const { return mCachedSettings; }
 
 private:
-    NPError DoNP_Initialize(const PluginSettings& aSettings);
     void AddQuirk(PluginQuirks quirk) {
       if (mQuirks == QUIRKS_NOT_INITIALIZED)
         mQuirks = 0;
       mQuirks |= quirk;
     }
     void InitQuirksModes(const nsCString& aMimeType);
     bool InitGraphics();
     void DeinitGraphics();
--- a/dom/plugins/ipc/PluginModuleParent.cpp
+++ b/dom/plugins/ipc/PluginModuleParent.cpp
@@ -12,17 +12,16 @@
 
 #include "base/process_util.h"
 #include "mozilla/Attributes.h"
 #include "mozilla/dom/ContentParent.h"
 #include "mozilla/dom/ContentChild.h"
 #include "mozilla/dom/PCrashReporterParent.h"
 #include "mozilla/ipc/MessageChannel.h"
 #include "mozilla/plugins/BrowserStreamParent.h"
-#include "mozilla/plugins/PluginAsyncSurrogate.h"
 #include "mozilla/plugins/PluginBridge.h"
 #include "mozilla/plugins/PluginInstanceParent.h"
 #include "mozilla/Preferences.h"
 #include "mozilla/Services.h"
 #include "mozilla/Telemetry.h"
 #include "mozilla/unused.h"
 #include "nsAutoPtr.h"
 #include "nsCRT.h"
@@ -66,17 +65,16 @@ using namespace mozilla::plugins::parent
 #include "mozilla/dom/CrashReporterParent.h"
 
 using namespace CrashReporter;
 #endif
 
 static const char kChildTimeoutPref[] = "dom.ipc.plugins.timeoutSecs";
 static const char kParentTimeoutPref[] = "dom.ipc.plugins.parentTimeoutSecs";
 static const char kLaunchTimeoutPref[] = "dom.ipc.plugins.processLaunchTimeoutSecs";
-static const char kAsyncInitPref[] = "dom.ipc.plugins.asyncInit";
 #ifdef XP_WIN
 static const char kHangUITimeoutPref[] = "dom.ipc.plugins.hangUITimeoutSecs";
 static const char kHangUIMinDisplayPref[] = "dom.ipc.plugins.hangUIMinDisplaySecs";
 #define CHILD_TIMEOUT_PREF kHangUITimeoutPref
 #else
 #define CHILD_TIMEOUT_PREF kChildTimeoutPref
 #endif
 
@@ -92,377 +90,134 @@ bool
 mozilla::plugins::SetupBridge(uint32_t aPluginId, dom::ContentParent* aContentParent)
 {
     nsRefPtr<nsPluginHost> host = nsPluginHost::GetInst();
     nsRefPtr<nsNPAPIPlugin> plugin;
     nsresult rv = host->GetPluginForContentProcess(aPluginId, getter_AddRefs(plugin));
     if (NS_FAILED(rv)) {
         return false;
     }
-    PluginModuleChromeParent* chromeParent = static_cast<PluginModuleChromeParent*>(plugin->GetLibrary());
-    chromeParent->SetContentParent(aContentParent);
-    if (chromeParent->IsStartingAsync()) {
-        // We'll handle the bridging asynchronously
-        return true;
-    }
-    if (!chromeParent->SendAssociatePluginId()) {
-        return false;
-    }
+    PluginModuleParent* chromeParent = static_cast<PluginModuleParent*>(plugin->GetLibrary());
     return PPluginModule::Bridge(aContentParent, chromeParent);
 }
 
-/**
- * Objects of this class remain linked until either an error occurs in the
- * plugin initialization sequence, or until
- * PluginModuleContentParent::OnLoadPluginResult has completed executing.
- */
-class PluginModuleMapping : public PRCList
-{
-public:
-    explicit PluginModuleMapping(uint32_t aPluginId)
-        : mPluginId(aPluginId)
-        , mProcessIdValid(false)
-        , mModule(nullptr)
-        , mChannelOpened(false)
-    {
-        MOZ_COUNT_CTOR(PluginModuleMapping);
-        PR_INIT_CLIST(this);
-        PR_APPEND_LINK(this, &sModuleListHead);
-    }
-
-    ~PluginModuleMapping()
-    {
-        PR_REMOVE_LINK(this);
-        MOZ_COUNT_DTOR(PluginModuleMapping);
-    }
-
-    bool
-    IsChannelOpened() const
-    {
-        return mChannelOpened;
-    }
-
-    void
-    SetChannelOpened()
-    {
-        mChannelOpened = true;
-    }
-
-    PluginModuleContentParent*
-    GetModule()
-    {
-        if (!mModule) {
-            mModule = new PluginModuleContentParent();
-        }
-        return mModule;
-    }
-
-    static PluginModuleMapping*
-    AssociateWithProcessId(uint32_t aPluginId, base::ProcessId aProcessId)
-    {
-        PluginModuleMapping* mapping =
-            static_cast<PluginModuleMapping*>(PR_NEXT_LINK(&sModuleListHead));
-        while (mapping != &sModuleListHead) {
-            if (mapping->mPluginId == aPluginId) {
-                mapping->AssociateWithProcessId(aProcessId);
-                return mapping;
-            }
-            mapping = static_cast<PluginModuleMapping*>(PR_NEXT_LINK(mapping));
-        }
-        return nullptr;
-    }
-
-    static PluginModuleMapping*
-    FindModuleByProcessId(base::ProcessId aProcessId)
-    {
-        PluginModuleMapping* mapping =
-            static_cast<PluginModuleMapping*>(PR_NEXT_LINK(&sModuleListHead));
-        while (mapping != &sModuleListHead) {
-            if (mapping->mProcessIdValid && mapping->mProcessId == aProcessId) {
-                return mapping;
-            }
-            mapping = static_cast<PluginModuleMapping*>(PR_NEXT_LINK(mapping));
-        }
-        return nullptr;
-    }
-
-    static PluginModuleMapping*
-    FindModuleByPluginId(uint32_t aPluginId)
-    {
-        PluginModuleMapping* mapping =
-            static_cast<PluginModuleMapping*>(PR_NEXT_LINK(&sModuleListHead));
-        while (mapping != &sModuleListHead) {
-            if (mapping->mPluginId == aPluginId) {
-                return mapping;
-            }
-            mapping = static_cast<PluginModuleMapping*>(PR_NEXT_LINK(mapping));
-        }
-        return nullptr;
-     }
-
-private:
-    void
-    AssociateWithProcessId(base::ProcessId aProcessId)
-    {
-        MOZ_ASSERT(!mProcessIdValid);
-        mProcessId = aProcessId;
-        mProcessIdValid = true;
-    }
-
-    uint32_t mPluginId;
-    bool mProcessIdValid;
-    base::ProcessId mProcessId;
-    PluginModuleContentParent* mModule;
-    bool mChannelOpened;
-
-    static PRCList sModuleListHead;
-};
-
-PRCList PluginModuleMapping::sModuleListHead =
-    PR_INIT_STATIC_CLIST(&PluginModuleMapping::sModuleListHead);
+PluginModuleContentParent* PluginModuleContentParent::sSavedModuleParent;
 
 /* static */ PluginLibrary*
 PluginModuleContentParent::LoadModule(uint32_t aPluginId)
 {
-    nsAutoPtr<PluginModuleMapping> mapping(new PluginModuleMapping(aPluginId));
-
+    MOZ_ASSERT(!sSavedModuleParent);
     MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Content);
 
     /*
      * We send a LoadPlugin message to the chrome process using an intr
      * message. Before it sends its response, it sends a message to create
      * PluginModuleParent instance. That message is handled by
-     * PluginModuleContentParent::Initialize, which saves the instance in
-     * its module mapping. We fetch it from there after LoadPlugin finishes.
+     * PluginModuleContentParent::Create, which saves the instance in
+     * sSavedModuleParent. We fetch it from there after LoadPlugin finishes.
      */
     dom::ContentChild* cp = dom::ContentChild::GetSingleton();
     if (!cp->SendLoadPlugin(aPluginId)) {
         return nullptr;
     }
 
-    PluginModuleContentParent* parent = mapping->GetModule();
+    PluginModuleContentParent* parent = sSavedModuleParent;
     MOZ_ASSERT(parent);
-
-    if (!mapping->IsChannelOpened()) {
-        // mapping is linked into PluginModuleMapping::sModuleListHead and is
-        // needed later, so since this function is returning successfully we
-        // forget it here.
-        mapping.forget();
-    }
+    sSavedModuleParent = nullptr;
 
     return parent;
 }
 
-/* static */ void
-PluginModuleContentParent::AssociatePluginId(uint32_t aPluginId,
-                                             base::ProcessId aProcessId)
+/* static */ PluginModuleContentParent*
+PluginModuleContentParent::Create(mozilla::ipc::Transport* aTransport,
+                                  base::ProcessId aOtherProcess)
 {
-    DebugOnly<PluginModuleMapping*> mapping =
-        PluginModuleMapping::AssociateWithProcessId(aPluginId, aProcessId);
-    MOZ_ASSERT(mapping);
-}
-
-/* static */ PluginModuleContentParent*
-PluginModuleContentParent::Initialize(mozilla::ipc::Transport* aTransport,
-                                      base::ProcessId aOtherProcess)
-{
-    nsAutoPtr<PluginModuleMapping> moduleMapping(
-        PluginModuleMapping::FindModuleByProcessId(aOtherProcess));
-    MOZ_ASSERT(moduleMapping);
-    PluginModuleContentParent* parent = moduleMapping->GetModule();
-    MOZ_ASSERT(parent);
-
+    nsAutoPtr<PluginModuleContentParent> parent(new PluginModuleContentParent());
     ProcessHandle handle;
     if (!base::OpenProcessHandle(aOtherProcess, &handle)) {
         // Bug 1090578 - need to kill |aOtherProcess|, it's boned.
         return nullptr;
     }
 
+    MOZ_ASSERT(!sSavedModuleParent);
+    sSavedModuleParent = parent;
+
     DebugOnly<bool> ok = parent->Open(aTransport, handle, XRE_GetIOMessageLoop(),
                                       mozilla::ipc::ParentSide);
     MOZ_ASSERT(ok);
 
-    moduleMapping->SetChannelOpened();
-
     // Request Windows message deferral behavior on our channel. This
     // applies to the top level and all sub plugin protocols since they
     // all share the same channel.
     parent->GetIPCChannel()->SetChannelFlags(MessageChannel::REQUIRE_DEFERRED_MESSAGE_PROTECTION);
 
-    // moduleMapping is linked into PluginModuleMapping::sModuleListHead and is
-    // needed later, so since this function is returning successfully we
-    // forget it here.
-    moduleMapping.forget();
-    return parent;
-}
-
-/* static */ void
-PluginModuleContentParent::OnLoadPluginResult(const uint32_t& aPluginId,
-                                              const bool& aResult)
-{
-    nsAutoPtr<PluginModuleMapping> moduleMapping(
-        PluginModuleMapping::FindModuleByPluginId(aPluginId));
-    MOZ_ASSERT(moduleMapping);
-    PluginModuleContentParent* parent = moduleMapping->GetModule();
-    MOZ_ASSERT(parent);
-    parent->RecvNP_InitializeResult(aResult ? NPERR_NO_ERROR
-                                            : NPERR_GENERIC_ERROR);
-}
-
-void
-PluginModuleChromeParent::SetContentParent(dom::ContentParent* aContentParent)
-{
-    MOZ_ASSERT(aContentParent);
-    mContentParent = aContentParent;
-}
-
-bool
-PluginModuleChromeParent::SendAssociatePluginId()
-{
-    MOZ_ASSERT(mContentParent);
-    return mContentParent->SendAssociatePluginId(mPluginId, OtherSidePID());
+    return parent.forget();
 }
 
 // static
 PluginLibrary*
 PluginModuleChromeParent::LoadModule(const char* aFilePath, uint32_t aPluginId,
                                      nsPluginTag* aPluginTag)
 {
     PLUGIN_LOG_DEBUG_FUNCTION;
 
+    int32_t prefSecs = Preferences::GetInt(kLaunchTimeoutPref, 0);
+
+    // Block on the child process being launched and initialized.
     nsAutoPtr<PluginModuleChromeParent> parent(new PluginModuleChromeParent(aFilePath, aPluginId));
-    UniquePtr<LaunchCompleteTask> onLaunchedRunnable(new LaunchedTask(parent));
-    parent->mSubprocess->SetCallRunnableImmediately(!parent->mIsStartingAsync);
     TimeStamp launchStart = TimeStamp::Now();
-    bool launched = parent->mSubprocess->Launch(Move(onLaunchedRunnable));
+    bool launched = parent->mSubprocess->Launch(prefSecs * 1000);
     if (!launched) {
         // We never reached open
         parent->mShutdown = true;
         return nullptr;
     }
-    if (!parent->mIsStartingAsync) {
-        int32_t launchTimeoutSecs = Preferences::GetInt(kLaunchTimeoutPref, 0);
-        if (!parent->mSubprocess->WaitUntilConnected(launchTimeoutSecs * 1000)) {
-            parent->mShutdown = true;
-            return nullptr;
-        }
-    }
     TimeStamp launchEnd = TimeStamp::Now();
     parent->mTimeBlocked = (launchEnd - launchStart);
-    parent->mIsFlashPlugin = aPluginTag->mIsFlashPlugin;
-    return parent.forget();
-}
-
-void
-PluginModuleChromeParent::OnProcessLaunched(const bool aSucceeded)
-{
-    if (!aSucceeded) {
-        mShutdown = true;
-        OnInitFailure();
-        return;
-    }
-    // We may have already been initialized by another call that was waiting
-    // for process connect. If so, this function doesn't need to run.
-    if (mAsyncInitRv != NS_ERROR_NOT_INITIALIZED || mShutdown) {
-        return;
-    }
-    Open(mSubprocess->GetChannel(), mSubprocess->GetChildProcessHandle());
+    parent->Open(parent->mSubprocess->GetChannel(),
+                 parent->mSubprocess->GetChildProcessHandle());
 
     // Request Windows message deferral behavior on our channel. This
     // applies to the top level and all sub plugin protocols since they
     // all share the same channel.
-    GetIPCChannel()->SetChannelFlags(MessageChannel::REQUIRE_DEFERRED_MESSAGE_PROTECTION);
-
-    TimeoutChanged(CHILD_TIMEOUT_PREF, this);
+    parent->GetIPCChannel()->SetChannelFlags(MessageChannel::REQUIRE_DEFERRED_MESSAGE_PROTECTION);
 
-    Preferences::RegisterCallback(TimeoutChanged, kChildTimeoutPref, this);
-    Preferences::RegisterCallback(TimeoutChanged, kParentTimeoutPref, this);
-#ifdef XP_WIN
-    Preferences::RegisterCallback(TimeoutChanged, kHangUITimeoutPref, this);
-    Preferences::RegisterCallback(TimeoutChanged, kHangUIMinDisplayPref, this);
-#endif
+    TimeoutChanged(CHILD_TIMEOUT_PREF, parent);
 
 #ifdef MOZ_CRASHREPORTER
     // If this fails, we're having IPC troubles, and we're doomed anyways.
-    if (!CrashReporterParent::CreateCrashReporter(this)) {
-        mShutdown = true;
-        Close();
-        OnInitFailure();
-        return;
+    if (!CrashReporterParent::CreateCrashReporter(parent.get())) {
+        parent->Close();
+        return nullptr;
     }
 #ifdef XP_WIN
-    { // Scope for lock
-        mozilla::MutexAutoLock lock(mCrashReporterMutex);
-        mCrashReporter = CrashReporter();
-    }
+    mozilla::MutexAutoLock lock(parent->mCrashReporterMutex);
+    parent->mCrashReporter = parent->CrashReporter();
 #endif
 #endif
 
 #ifdef XP_WIN
-    if (mIsFlashPlugin &&
+    if (aPluginTag->mIsFlashPlugin &&
         Preferences::GetBool("dom.ipc.plugins.flash.disable-protected-mode", false)) {
-        SendDisableFlashProtectedMode();
+        parent->SendDisableFlashProtectedMode();
     }
 #endif
 
-    if (mInitOnAsyncConnect) {
-        mInitOnAsyncConnect = false;
-#if defined(XP_WIN)
-        mAsyncInitRv = NP_GetEntryPoints(mAsyncInitPluginFuncs,
-                                         &mAsyncInitError);
-        if (NS_SUCCEEDED(mAsyncInitRv))
-#endif
-        {
-#if defined(XP_UNIX) && !defined(XP_MACOSX) && !defined(MOZ_WIDGET_GONK)
-            mAsyncInitRv = NP_Initialize(mNPNIface,
-                                         mAsyncInitPluginFuncs,
-                                         &mAsyncInitError);
-#else
-            mAsyncInitRv = NP_Initialize(mNPNIface,
-                                         &mAsyncInitError);
-#endif
-        }
-
-#if defined(XP_MACOSX)
-        if (NS_SUCCEEDED(mAsyncInitRv)) {
-            mAsyncInitRv = NP_GetEntryPoints(mAsyncInitPluginFuncs,
-                                             &mAsyncInitError);
-        }
-#endif
-    }
-}
-
-bool
-PluginModuleChromeParent::WaitForIPCConnection()
-{
-    PluginProcessParent* process = Process();
-    MOZ_ASSERT(process);
-    process->SetCallRunnableImmediately(true);
-    if (!process->WaitUntilConnected()) {
-        return false;
-    }
-    return true;
+    return parent.forget();
 }
 
 PluginModuleParent::PluginModuleParent(bool aIsChrome)
     : mIsChrome(aIsChrome)
     , mShutdown(false)
     , mClearSiteDataSupported(false)
     , mGetSitesWithDataSupported(false)
     , mNPNIface(nullptr)
     , mPlugin(nullptr)
     , mTaskFactory(MOZ_THIS_IN_INITIALIZER_LIST())
-    , mIsStartingAsync(false)
-    , mNPInitialized(false)
-    , mAsyncNewRv(NS_ERROR_NOT_INITIALIZED)
-    , mAsyncInitPluginFuncs(nullptr)
 {
-#if defined(XP_WIN) || defined(XP_MACOSX) || defined(MOZ_WIDGET_GTK)
-    mIsStartingAsync = Preferences::GetBool(kAsyncInitPref, false);
-#endif
 }
 
 PluginModuleParent::~PluginModuleParent()
 {
     if (!OkToCleanup()) {
         NS_RUNTIMEABORT("unsafe destruction");
     }
 
@@ -493,24 +248,26 @@ PluginModuleChromeParent::PluginModuleCh
     , mCrashReporterMutex("PluginModuleParent::mCrashReporterMutex")
     , mCrashReporter(nullptr)
 #endif
 #endif
 #ifdef MOZ_CRASHREPORTER_INJECTOR
     , mFlashProcess1(0)
     , mFlashProcess2(0)
 #endif
-    , mInitOnAsyncConnect(false)
-    , mAsyncInitRv(NS_ERROR_NOT_INITIALIZED)
-    , mAsyncInitError(NPERR_NO_ERROR)
-    , mContentParent(nullptr)
-    , mIsFlashPlugin(false)
 {
     NS_ASSERTION(mSubprocess, "Out of memory!");
 
+    Preferences::RegisterCallback(TimeoutChanged, kChildTimeoutPref, this);
+    Preferences::RegisterCallback(TimeoutChanged, kParentTimeoutPref, this);
+#ifdef XP_WIN
+    Preferences::RegisterCallback(TimeoutChanged, kHangUITimeoutPref, this);
+    Preferences::RegisterCallback(TimeoutChanged, kHangUIMinDisplayPref, this);
+#endif
+
     RegisterSettingsCallbacks();
 
 #ifdef MOZ_ENABLE_PROFILER_SPS
     InitPluginProfiling();
 #endif
 
     mozilla::HangMonitor::RegisterAnnotator(*this);
 }
@@ -1185,17 +942,18 @@ PluginModuleParent::NotifyPluginCrashed(
     if (mPlugin)
         mPlugin->PluginCrashed(mPluginDumpID, mBrowserDumpID);
 }
 
 PPluginInstanceParent*
 PluginModuleParent::AllocPPluginInstanceParent(const nsCString& aMimeType,
                                                const uint16_t& aMode,
                                                const InfallibleTArray<nsCString>& aNames,
-                                               const InfallibleTArray<nsCString>& aValues)
+                                               const InfallibleTArray<nsCString>& aValues,
+                                               NPError* rv)
 {
     NS_ERROR("Not reachable!");
     return nullptr;
 }
 
 bool
 PluginModuleParent::DeallocPPluginInstanceParent(PPluginInstanceParent* aActor)
 {
@@ -1237,41 +995,29 @@ PluginModuleParent::SetPluginFuncs(NPPlu
     unused << CallOptionalFunctionsSupported(&urlRedirectSupported,
                                              &mClearSiteDataSupported,
                                              &mGetSitesWithDataSupported);
     if (urlRedirectSupported) {
       aFuncs->urlredirectnotify = NPP_URLRedirectNotify;
     }
 }
 
-#define RESOLVE_AND_CALL(instance, func)                                       \
-NP_BEGIN_MACRO                                                                 \
-    PluginAsyncSurrogate* surrogate = nullptr;                                 \
-    PluginInstanceParent* i = PluginInstanceParent::Cast(instance, &surrogate);\
-    if (surrogate && (!i || i->UseSurrogate())) {                              \
-        return surrogate->func;                                                \
-    }                                                                          \
-    if (!i) {                                                                  \
-        return NPERR_GENERIC_ERROR;                                            \
-    }                                                                          \
-    return i->func;                                                            \
-NP_END_MACRO
-
 NPError
 PluginModuleParent::NPP_Destroy(NPP instance,
                                 NPSavedData** /*saved*/)
 {
     // FIXME/cjones:
     //  (1) send a "destroy" message to the child
     //  (2) the child shuts down its instance
     //  (3) remove both parent and child IDs from map
     //  (4) free parent
+    PLUGIN_LOG_DEBUG_FUNCTION;
 
-    PLUGIN_LOG_DEBUG_FUNCTION;
-    PluginInstanceParent* parentInstance = PluginInstanceParent::Cast(instance);
+    PluginInstanceParent* parentInstance =
+        static_cast<PluginInstanceParent*>(instance->pdata);
 
     if (!parentInstance)
         return NPERR_NO_ERROR;
 
     NPError retval = parentInstance->Destroy();
     instance->pdata = nullptr;
 
     unused << PluginInstanceParent::Call__delete__(parentInstance);
@@ -1280,49 +1026,54 @@ PluginModuleParent::NPP_Destroy(NPP inst
 
 NPError
 PluginModuleParent::NPP_NewStream(NPP instance, NPMIMEType type,
                                   NPStream* stream, NPBool seekable,
                                   uint16_t* stype)
 {
     PROFILER_LABEL("PluginModuleParent", "NPP_NewStream",
       js::ProfileEntry::Category::OTHER);
-    RESOLVE_AND_CALL(instance, NPP_NewStream(type, stream, seekable, stype));
+
+    PluginInstanceParent* i = InstCast(instance);
+    if (!i)
+        return NPERR_GENERIC_ERROR;
+
+    return i->NPP_NewStream(type, stream, seekable,
+                            stype);
 }
 
 NPError
 PluginModuleParent::NPP_SetWindow(NPP instance, NPWindow* window)
 {
-    RESOLVE_AND_CALL(instance, NPP_SetWindow(window));
+    PluginInstanceParent* i = InstCast(instance);
+    if (!i)
+        return NPERR_GENERIC_ERROR;
+
+    return i->NPP_SetWindow(window);
 }
 
 NPError
 PluginModuleParent::NPP_DestroyStream(NPP instance,
                                       NPStream* stream,
                                       NPReason reason)
 {
-    PluginInstanceParent* i = PluginInstanceParent::Cast(instance);
+    PluginInstanceParent* i = InstCast(instance);
     if (!i)
         return NPERR_GENERIC_ERROR;
 
     return i->NPP_DestroyStream(stream, reason);
 }
 
 int32_t
 PluginModuleParent::NPP_WriteReady(NPP instance,
                                    NPStream* stream)
 {
-    PluginAsyncSurrogate* surrogate = nullptr;
-    BrowserStreamParent* s = StreamCast(instance, stream, &surrogate);
-    if (!s) {
-        if (surrogate) {
-            return surrogate->NPP_WriteReady(stream);
-        }
+    BrowserStreamParent* s = StreamCast(instance, stream);
+    if (!s)
         return -1;
-    }
 
     return s->WriteReady();
 }
 
 int32_t
 PluginModuleParent::NPP_Write(NPP instance,
                               NPStream* stream,
                               int32_t offset,
@@ -1346,60 +1097,62 @@ PluginModuleParent::NPP_StreamAsFile(NPP
         return;
 
     s->StreamAsFile(fname);
 }
 
 void
 PluginModuleParent::NPP_Print(NPP instance, NPPrint* platformPrint)
 {
-
-    PluginInstanceParent* i = PluginInstanceParent::Cast(instance);
-    i->NPP_Print(platformPrint);
+    PluginInstanceParent* i = InstCast(instance);
+    if (i)
+        i->NPP_Print(platformPrint);
 }
 
 int16_t
 PluginModuleParent::NPP_HandleEvent(NPP instance, void* event)
 {
-    RESOLVE_AND_CALL(instance, NPP_HandleEvent(event));
+    PluginInstanceParent* i = InstCast(instance);
+    if (!i)
+        return false;
+
+    return i->NPP_HandleEvent(event);
 }
 
 void
 PluginModuleParent::NPP_URLNotify(NPP instance, const char* url,
                                   NPReason reason, void* notifyData)
 {
-    PluginInstanceParent* i = PluginInstanceParent::Cast(instance);
+    PluginInstanceParent* i = InstCast(instance);
     if (!i)
         return;
 
     i->NPP_URLNotify(url, reason, notifyData);
 }
 
 NPError
 PluginModuleParent::NPP_GetValue(NPP instance,
                                  NPPVariable variable, void *ret_value)
 {
-    // The rules are slightly different for this function.
-    // If there is a surrogate, we *always* use it.
-    PluginAsyncSurrogate* surrogate = nullptr;
-    PluginInstanceParent* i = PluginInstanceParent::Cast(instance, &surrogate);
-    if (surrogate) {
-        return surrogate->NPP_GetValue(variable, ret_value);
-    }
-    if (!i) {
+    PluginInstanceParent* i = InstCast(instance);
+    if (!i)
         return NPERR_GENERIC_ERROR;
-    }
+
     return i->NPP_GetValue(variable, ret_value);
 }
 
 NPError
 PluginModuleParent::NPP_SetValue(NPP instance, NPNVariable variable,
                                  void *value)
 {
-    RESOLVE_AND_CALL(instance, NPP_SetValue(variable, value));
+    PluginInstanceParent* i = InstCast(instance);
+    if (!i)
+        return NPERR_GENERIC_ERROR;
+
+    return i->NPP_SetValue(variable, value);
 }
 
 bool
 PluginModuleParent::RecvBackUpXResources(const FileDescriptor& aXSocketFd)
 {
 #ifndef MOZ_X11
     NS_RUNTIMEABORT("This message only makes sense on X11 platforms");
 #else
@@ -1412,31 +1165,47 @@ PluginModuleParent::RecvBackUpXResources
 #endif
     return true;
 }
 
 void
 PluginModuleParent::NPP_URLRedirectNotify(NPP instance, const char* url,
                                           int32_t status, void* notifyData)
 {
-  PluginInstanceParent* i = PluginInstanceParent::Cast(instance);
+  PluginInstanceParent* i = InstCast(instance);
   if (!i)
     return;
 
   i->NPP_URLRedirectNotify(url, status, notifyData);
 }
 
-BrowserStreamParent*
-PluginModuleParent::StreamCast(NPP instance, NPStream* s,
-                               PluginAsyncSurrogate** aSurrogate)
+PluginInstanceParent*
+PluginModuleParent::InstCast(NPP instance)
 {
-    PluginInstanceParent* ip = PluginInstanceParent::Cast(instance, aSurrogate);
-    if (!ip || (aSurrogate && *aSurrogate && ip->UseSurrogate())) {
+    PluginInstanceParent* ip =
+        static_cast<PluginInstanceParent*>(instance->pdata);
+
+    // If the plugin crashed and the PluginInstanceParent was deleted,
+    // instance->pdata will be nullptr.
+    if (!ip)
         return nullptr;
+
+    if (instance != ip->mNPP) {
+        NS_RUNTIMEABORT("Corrupted plugin data.");
     }
+    return ip;
+}
+
+BrowserStreamParent*
+PluginModuleParent::StreamCast(NPP instance,
+                               NPStream* s)
+{
+    PluginInstanceParent* ip = InstCast(instance);
+    if (!ip)
+        return nullptr;
 
     BrowserStreamParent* sp =
         static_cast<BrowserStreamParent*>(static_cast<AStream*>(s->pdata));
     if (sp->mNPP != ip || s != sp->mStream) {
         NS_RUNTIMEABORT("Corrupted plugin stream data.");
     }
     return sp;
 }
@@ -1445,91 +1214,73 @@ bool
 PluginModuleParent::HasRequiredFunctions()
 {
     return true;
 }
 
 nsresult
 PluginModuleParent::AsyncSetWindow(NPP instance, NPWindow* window)
 {
-    PluginAsyncSurrogate* surrogate = nullptr;
-    PluginInstanceParent* i = PluginInstanceParent::Cast(instance, &surrogate);
-    if (surrogate && (!i || i->UseSurrogate())) {
-        return surrogate->AsyncSetWindow(window);
-    } else if (!i) {
+    PluginInstanceParent* i = InstCast(instance);
+    if (!i)
         return NS_ERROR_FAILURE;
-    }
+
     return i->AsyncSetWindow(window);
 }
 
 nsresult
 PluginModuleParent::GetImageContainer(NPP instance,
                              mozilla::layers::ImageContainer** aContainer)
 {
-    PluginInstanceParent* i = PluginInstanceParent::Cast(instance);
+    PluginInstanceParent* i = InstCast(instance);
     return !i ? NS_ERROR_FAILURE : i->GetImageContainer(aContainer);
 }
 
 nsresult
 PluginModuleParent::GetImageSize(NPP instance,
                                  nsIntSize* aSize)
 {
-    PluginInstanceParent* i = PluginInstanceParent::Cast(instance);
+    PluginInstanceParent* i = InstCast(instance);
     return !i ? NS_ERROR_FAILURE : i->GetImageSize(aSize);
 }
 
 nsresult
 PluginModuleParent::SetBackgroundUnknown(NPP instance)
 {
-    PluginInstanceParent* i = PluginInstanceParent::Cast(instance);
+    PluginInstanceParent* i = InstCast(instance);
     if (!i)
         return NS_ERROR_FAILURE;
 
     return i->SetBackgroundUnknown();
 }
 
 nsresult
 PluginModuleParent::BeginUpdateBackground(NPP instance,
                                           const nsIntRect& aRect,
                                           gfxContext** aCtx)
 {
-    PluginInstanceParent* i = PluginInstanceParent::Cast(instance);
+    PluginInstanceParent* i = InstCast(instance);
     if (!i)
         return NS_ERROR_FAILURE;
 
     return i->BeginUpdateBackground(aRect, aCtx);
 }
 
 nsresult
 PluginModuleParent::EndUpdateBackground(NPP instance,
                                         gfxContext* aCtx,
                                         const nsIntRect& aRect)
 {
-    PluginInstanceParent* i = PluginInstanceParent::Cast(instance);
+    PluginInstanceParent* i = InstCast(instance);
     if (!i)
         return NS_ERROR_FAILURE;
 
     return i->EndUpdateBackground(aCtx, aRect);
 }
 
-void
-PluginModuleParent::OnInitFailure()
-{
-    if (GetIPCChannel()->CanSend()) {
-        Close();
-    }
-    /* If we've failed then we need to enumerate any pending NPP_New calls
-       and clean them up. */
-    uint32_t len = mSurrogateInstances.Length();
-    for (uint32_t i = 0; i < len; ++i) {
-        mSurrogateInstances[i]->NotifyAsyncInitFailed();
-    }
-    mSurrogateInstances.Clear();
-}
-
 class OfflineObserver MOZ_FINAL : public nsIObserver
 {
 public:
     NS_DECL_ISUPPORTS
     NS_DECL_NSIOBSERVER
 
     explicit OfflineObserver(PluginModuleChromeParent* pmp)
       : mPmp(pmp)
@@ -1634,116 +1385,38 @@ PluginModuleParent::NP_Initialize(NPNets
 
     mNPNIface = bFuncs;
 
     if (mShutdown) {
         *error = NPERR_GENERIC_ERROR;
         return NS_ERROR_FAILURE;
     }
 
-    SetPluginFuncs(pFuncs);
-
     *error = NPERR_NO_ERROR;
-    return NS_OK;
-}
-
-nsresult
-PluginModuleChromeParent::NP_Initialize(NPNetscapeFuncs* bFuncs, NPPluginFuncs* pFuncs, NPError* error)
-{
-    PLUGIN_LOG_DEBUG_METHOD;
-
-    mNPNIface = bFuncs;
-
-    if (mShutdown) {
-        *error = NPERR_GENERIC_ERROR;
-        return NS_ERROR_FAILURE;
-    }
-
-    mAsyncInitPluginFuncs = pFuncs;
-
-    if (!mSubprocess->IsConnected()) {
-        // The subprocess isn't connected yet. Defer NP_Initialize until
-        // OnProcessLaunched is invoked.
-        mInitOnAsyncConnect = true;
-        *error = NPERR_NO_ERROR;
-        return NS_OK;
-    }
-
-    if (mIsStartingAsync) {
-        PluginAsyncSurrogate::NP_GetEntryPoints(pFuncs);
-    }
-
-    *error = NPERR_NO_ERROR;
-
-    PluginSettings settings;
-    GetSettings(&settings);
-
-    TimeStamp callNpInitStart = TimeStamp::Now();
-    // Asynchronous case
-    if (mIsStartingAsync) {
-        if (!SendAsyncNP_Initialize(settings)) {
+    if (IsChrome()) {
+        PluginSettings settings;
+        GetSettings(&settings);
+        TimeStamp callNpInitStart = TimeStamp::Now();
+        if (!CallNP_Initialize(settings, error)) {
+            Close();
             return NS_ERROR_FAILURE;
         }
+        else if (*error != NPERR_NO_ERROR) {
+            Close();
+            return NS_OK;
+        }
         TimeStamp callNpInitEnd = TimeStamp::Now();
         mTimeBlocked += (callNpInitEnd - callNpInitStart);
-        return NS_PLUGIN_INIT_PENDING;
     }
 
-    // Synchronous case
-    if (!CallNP_Initialize(settings, error)) {
-        Close();
-        return NS_ERROR_FAILURE;
-    }
-    else if (*error != NPERR_NO_ERROR) {
-        Close();
-        return NS_OK;
-    }
-    TimeStamp callNpInitEnd = TimeStamp::Now();
-    mTimeBlocked += (callNpInitEnd - callNpInitStart);
-    RecvNP_InitializeResult(*error);
+    SetPluginFuncs(pFuncs);
 
     return NS_OK;
 }
-
-bool
-PluginModuleParent::RecvNP_InitializeResult(const NPError& aError)
-{
-    if (aError != NPERR_NO_ERROR) {
-        OnInitFailure();
-        return true;
-    }
-
-    SetPluginFuncs(mAsyncInitPluginFuncs);
-    InitAsyncSurrogates();
-
-    mNPInitialized = true;
-    return true;
-}
-
-bool
-PluginModuleChromeParent::RecvNP_InitializeResult(const NPError& aError)
-{
-    if (!mContentParent) {
-        return PluginModuleParent::RecvNP_InitializeResult(aError);
-    }
-    bool initOk = aError == NPERR_NO_ERROR;
-    if (initOk) {
-        SetPluginFuncs(mAsyncInitPluginFuncs);
-        if (SendAssociatePluginId()) {
-            PPluginModule::Bridge(mContentParent, this);
-            mNPInitialized = true;
-        } else {
-            initOk = false;
-        }
-    }
-    return mContentParent->SendLoadPluginResult(mPluginId, initOk);
-}
-
 #else
-
 nsresult
 PluginModuleParent::NP_Initialize(NPNetscapeFuncs* bFuncs, NPError* error)
 {
     PLUGIN_LOG_DEBUG_METHOD;
 
     mNPNIface = bFuncs;
 
     if (mShutdown) {
@@ -1757,133 +1430,49 @@ PluginModuleParent::NP_Initialize(NPNets
 
 nsresult
 PluginModuleChromeParent::NP_Initialize(NPNetscapeFuncs* bFuncs, NPError* error)
 {
     nsresult rv = PluginModuleParent::NP_Initialize(bFuncs, error);
     if (NS_FAILED(rv))
         return rv;
 
-#if defined(XP_MACOSX)
-    if (!mSubprocess->IsConnected()) {
-        // The subprocess isn't connected yet. Defer NP_Initialize until
-        // OnProcessLaunched is invoked.
-        mInitOnAsyncConnect = true;
-        *error = NPERR_NO_ERROR;
-        return NS_OK;
-    }
-#else
-    if (mInitOnAsyncConnect) {
-        *error = NPERR_NO_ERROR;
-        return NS_OK;
-    }
-#endif
-
     PluginSettings settings;
     GetSettings(&settings);
-
     TimeStamp callNpInitStart = TimeStamp::Now();
-    if (mIsStartingAsync) {
-        if (!SendAsyncNP_Initialize(settings)) {
-            return NS_ERROR_FAILURE;
-        }
-        TimeStamp callNpInitEnd = TimeStamp::Now();
-        mTimeBlocked += (callNpInitEnd - callNpInitStart);
-        return NS_PLUGIN_INIT_PENDING;
-    }
-
     if (!CallNP_Initialize(settings, error)) {
         Close();
         return NS_ERROR_FAILURE;
     }
+    if (*error != NPERR_NO_ERROR) {
+        Close();
+        return NS_OK;
+    }
     TimeStamp callNpInitEnd = TimeStamp::Now();
     mTimeBlocked += (callNpInitEnd - callNpInitStart);
-    RecvNP_InitializeResult(*error);
-    return NS_OK;
-}
-
-bool
-PluginModuleParent::RecvNP_InitializeResult(const NPError& aError)
-{
-    if (aError != NPERR_NO_ERROR) {
-        OnInitFailure();
-        return true;
-    }
-
-    if (mIsStartingAsync) {
-#if defined(XP_WIN)
-        SetPluginFuncs(mAsyncInitPluginFuncs);
-#endif
-        InitAsyncSurrogates();
-    }
-
-    mNPInitialized = true;
-    return true;
-}
 
-bool
-PluginModuleChromeParent::RecvNP_InitializeResult(const NPError& aError)
-{
-    bool ok = true;
-    if (mContentParent) {
-        if ((ok = SendAssociatePluginId())) {
-            PPluginModule::Bridge(mContentParent, this);
-            ok = mContentParent->SendLoadPluginResult(mPluginId,
-                                                      aError == NPERR_NO_ERROR);
-        }
-    } else if (aError == NPERR_NO_ERROR) {
-        // Initialization steps when e10s is disabled
 #if defined XP_WIN
-        if (mIsStartingAsync) {
-            SetPluginFuncs(mAsyncInitPluginFuncs);
-        }
+    // Send the info needed to join the chrome process's audio session to the
+    // plugin process
+    nsID id;
+    nsString sessionName;
+    nsString iconPath;
 
-        // Send the info needed to join the chrome process's audio session to the
-        // plugin process
-        nsID id;
-        nsString sessionName;
-        nsString iconPath;
-
-        if (NS_SUCCEEDED(mozilla::widget::GetAudioSessionData(id, sessionName,
-                                                              iconPath))) {
-            unused << SendSetAudioSessionData(id, sessionName, iconPath);
-        }
+    if (NS_SUCCEEDED(mozilla::widget::GetAudioSessionData(id, sessionName,
+                                                          iconPath)))
+        unused << SendSetAudioSessionData(id, sessionName, iconPath);
 #endif
 
 #ifdef MOZ_CRASHREPORTER_INJECTOR
-        InitializeInjector();
-#endif
-    }
-
-    return PluginModuleParent::RecvNP_InitializeResult(aError) && ok;
-}
-
+    InitializeInjector();
 #endif
 
-void
-PluginModuleParent::InitAsyncSurrogates()
-{
-    uint32_t len = mSurrogateInstances.Length();
-    for (uint32_t i = 0; i < len; ++i) {
-        NPError err;
-        mAsyncNewRv = mSurrogateInstances[i]->NPP_New(&err);
-        if (NS_FAILED(mAsyncNewRv)) {
-            mSurrogateInstances[i]->NotifyAsyncInitFailed();
-            continue;
-        }
-    }
-    mSurrogateInstances.Clear();
+    return NS_OK;
 }
-
-bool
-PluginModuleParent::RemovePendingSurrogate(
-                            const nsRefPtr<PluginAsyncSurrogate>& aSurrogate)
-{
-    return mSurrogateInstances.RemoveElement(aSurrogate);
-}
+#endif
 
 nsresult
 PluginModuleParent::NP_Shutdown(NPError* error)
 {
     PLUGIN_LOG_DEBUG_METHOD;
 
     if (mShutdown) {
         *error = NPERR_GENERIC_ERROR;
@@ -1926,95 +1515,50 @@ PluginModuleParent::NP_GetValue(void *fu
 }
 
 #if defined(XP_WIN) || defined(XP_MACOSX)
 nsresult
 PluginModuleParent::NP_GetEntryPoints(NPPluginFuncs* pFuncs, NPError* error)
 {
     NS_ASSERTION(pFuncs, "Null pointer!");
 
-    *error = NPERR_NO_ERROR;
-    if (mIsStartingAsync && !IsChrome()) {
-        PluginAsyncSurrogate::NP_GetEntryPoints(pFuncs);
-        mAsyncInitPluginFuncs = pFuncs;
-    } else {
-        SetPluginFuncs(pFuncs);
-    }
-
-    return NS_OK;
-}
-
-nsresult
-PluginModuleChromeParent::NP_GetEntryPoints(NPPluginFuncs* pFuncs, NPError* error)
-{
-#if defined(XP_MACOSX)
-    if (mInitOnAsyncConnect) {
-        PluginAsyncSurrogate::NP_GetEntryPoints(pFuncs);
-        mAsyncInitPluginFuncs = pFuncs;
-        *error = NPERR_NO_ERROR;
-        return NS_OK;
-    }
-#else
-    if (mIsStartingAsync) {
-        PluginAsyncSurrogate::NP_GetEntryPoints(pFuncs);
-    }
-    if (!mSubprocess->IsConnected()) {
-        mAsyncInitPluginFuncs = pFuncs;
-        mInitOnAsyncConnect = true;
-        *error = NPERR_NO_ERROR;
-        return NS_OK;
-    }
-#endif
-
     // We need to have the plugin process update its function table here by
     // actually calling NP_GetEntryPoints. The parent's function table will
     // reflect nullptr entries in the child's table once SetPluginFuncs is
     // called.
 
-    if (!CallNP_GetEntryPoints(error)) {
-        return NS_ERROR_FAILURE;
-    }
-    else if (*error != NPERR_NO_ERROR) {
-        return NS_OK;
+    if (IsChrome()) {
+        if (!CallNP_GetEntryPoints(error)) {
+            return NS_ERROR_FAILURE;
+        }
+        else if (*error != NPERR_NO_ERROR) {
+            return NS_OK;
+        }
     }
 
-    return PluginModuleParent::NP_GetEntryPoints(pFuncs, error);
+    *error = NPERR_NO_ERROR;
+    SetPluginFuncs(pFuncs);
+
+    return NS_OK;
 }
-
 #endif
 
 nsresult
 PluginModuleParent::NPP_New(NPMIMEType pluginType, NPP instance,
                             uint16_t mode, int16_t argc, char* argn[],
                             char* argv[], NPSavedData* saved,
                             NPError* error)
 {
     PLUGIN_LOG_DEBUG_METHOD;
 
     if (mShutdown) {
         *error = NPERR_GENERIC_ERROR;
         return NS_ERROR_FAILURE;
     }
 
-    if (mIsStartingAsync) {
-        if (!PluginAsyncSurrogate::Create(this, pluginType, instance, mode,
-                                          argc, argn, argv)) {
-            *error = NPERR_GENERIC_ERROR;
-            return NS_ERROR_FAILURE;
-        }
-
-        if (!mNPInitialized) {
-            nsRefPtr<PluginAsyncSurrogate> surrogate =
-                PluginAsyncSurrogate::Cast(instance);
-            mSurrogateInstances.AppendElement(surrogate);
-            *error = NPERR_NO_ERROR;
-            return NS_PLUGIN_INIT_PENDING;
-        }
-    }
-
     if (mPluginName.IsEmpty()) {
         GetPluginDetails(mPluginName, mPluginVersion);
         /** mTimeBlocked measures the time that the main thread has been blocked
          *  on plugin module initialization. As implemented, this is the sum of
          *  plugin-container launch + toolhelp32 snapshot + NP_Initialize.
          *  We don't accumulate its value until here because the plugin info
          *  is not available until *after* NP_Initialize.
          */
@@ -2028,83 +1572,46 @@ PluginModuleParent::NPP_New(NPMIMEType p
     InfallibleTArray<nsCString> names;
     InfallibleTArray<nsCString> values;
 
     for (int i = 0; i < argc; ++i) {
         names.AppendElement(NullableString(argn[i]));
         values.AppendElement(NullableString(argv[i]));
     }
 
-    nsresult rv = NPP_NewInternal(pluginType, instance, mode, names, values,
-                                  saved, error);
-    if (NS_FAILED(rv) || !mIsStartingAsync) {
-        return rv;
-    }
-    return NS_PLUGIN_INIT_PENDING;
-}
-
-nsresult
-PluginModuleParent::NPP_NewInternal(NPMIMEType pluginType, NPP instance,
-                                    uint16_t mode,
-                                    InfallibleTArray<nsCString>& names,
-                                    InfallibleTArray<nsCString>& values,
-                                    NPSavedData* saved, NPError* error)
-{
     PluginInstanceParent* parentInstance =
         new PluginInstanceParent(this, instance,
                                  nsDependentCString(pluginType), mNPNIface);
 
     if (!parentInstance->Init()) {
         delete parentInstance;
         return NS_ERROR_FAILURE;
     }
 
-    // Release the surrogate reference that was in pdata
-    nsRefPtr<PluginAsyncSurrogate> surrogate(
-        dont_AddRef(PluginAsyncSurrogate::Cast(instance)));
-    // Now replace it with the instance
-    instance->pdata = static_cast<PluginDataResolver*>(parentInstance);
-
-    if (!SendPPluginInstanceConstructor(parentInstance,
-                                        nsDependentCString(pluginType), mode,
-                                        names, values)) {
-        // |parentInstance| is automatically deleted.
-        instance->pdata = nullptr;
-        *error = NPERR_GENERIC_ERROR;
-        return NS_ERROR_FAILURE;
-    }
+    instance->pdata = parentInstance;
 
     {   // Scope for timer
         Telemetry::AutoTimer<Telemetry::BLOCKED_ON_PLUGIN_INSTANCE_INIT_MS>
             timer(GetHistogramKey());
-        if (mIsStartingAsync) {
-            MOZ_ASSERT(surrogate);
-            surrogate->AsyncCallDeparting();
-            if (!SendAsyncNPP_New(parentInstance)) {
+        if (!CallPPluginInstanceConstructor(parentInstance,
+                                            nsDependentCString(pluginType), mode,
+                                            names, values, error)) {
+            // |parentInstance| is automatically deleted.
+            instance->pdata = nullptr;
+            // if IPC is down, we'll get an immediate "failed" return, but
+            // without *error being set.  So make sure that the error
+            // condition is signaled to nsNPAPIPluginInstance
+            if (NPERR_NO_ERROR == *error)
                 *error = NPERR_GENERIC_ERROR;
-                return NS_ERROR_FAILURE;
-            }
-            *error = NPERR_NO_ERROR;
-        } else {
-            if (!CallSyncNPP_New(parentInstance, error)) {
-                // if IPC is down, we'll get an immediate "failed" return, but
-                // without *error being set.  So make sure that the error
-                // condition is signaled to nsNPAPIPluginInstance
-                if (NPERR_NO_ERROR == *error) {
-                    *error = NPERR_GENERIC_ERROR;
-                }
-                return NS_ERROR_FAILURE;
-            }
+            return NS_ERROR_FAILURE;
         }
     }
 
     if (*error != NPERR_NO_ERROR) {
-        if (!mIsStartingAsync) {
-            NPP_Destroy(instance, 0);
-        }
+        NPP_Destroy(instance, 0);
         return NS_ERROR_FAILURE;
     }
 
     UpdatePluginTimeout();
 
     return NS_OK;
 }
 
@@ -2148,27 +1655,27 @@ PluginModuleParent::NPP_GetSitesWithData
 
     return NS_OK;
 }
 
 #if defined(XP_MACOSX)
 nsresult
 PluginModuleParent::IsRemoteDrawingCoreAnimation(NPP instance, bool *aDrawing)
 {
-    PluginInstanceParent* i = PluginInstanceParent::Cast(instance);
+    PluginInstanceParent* i = InstCast(instance);
     if (!i)
         return NS_ERROR_FAILURE;
 
     return i->IsRemoteDrawingCoreAnimation(aDrawing);
 }
 
 nsresult
 PluginModuleParent::ContentsScaleFactorChanged(NPP instance, double aContentsScaleFactor)
 {
-    PluginInstanceParent* i = PluginInstanceParent::Cast(instance);
+    PluginInstanceParent* i = InstCast(instance);
     if (!i)
         return NS_ERROR_FAILURE;
 
     return i->ContentsScaleFactorChanged(aContentsScaleFactor);
 }
 #endif // #if defined(XP_MACOSX)
 
 #if defined(MOZ_WIDGET_QT)
--- a/dom/plugins/ipc/PluginModuleParent.h
+++ b/dom/plugins/ipc/PluginModuleParent.h
@@ -35,17 +35,16 @@ namespace dom {
 class PCrashReporterParent;
 class CrashReporterParent;
 }
 
 namespace plugins {
 //-----------------------------------------------------------------------------
 
 class BrowserStreamParent;
-class PluginAsyncSurrogate;
 class PluginInstanceParent;
 
 #ifdef XP_WIN
 class PluginHangUIParent;
 #endif
 
 /**
  * PluginModuleParent
@@ -75,33 +74,26 @@ protected:
     typedef mozilla::PluginLibrary PluginLibrary;
     typedef mozilla::dom::PCrashReporterParent PCrashReporterParent;
     typedef mozilla::dom::CrashReporterParent CrashReporterParent;
 
     PPluginInstanceParent*
     AllocPPluginInstanceParent(const nsCString& aMimeType,
                                const uint16_t& aMode,
                                const InfallibleTArray<nsCString>& aNames,
-                               const InfallibleTArray<nsCString>& aValues)
-                               MOZ_OVERRIDE;
+                               const InfallibleTArray<nsCString>& aValues,
+                               NPError* rv) MOZ_OVERRIDE;
 
     virtual bool
     DeallocPPluginInstanceParent(PPluginInstanceParent* aActor) MOZ_OVERRIDE;
 
 public:
     explicit PluginModuleParent(bool aIsChrome);
     virtual ~PluginModuleParent();
 
-    bool RemovePendingSurrogate(const nsRefPtr<PluginAsyncSurrogate>& aSurrogate);
-
-    /** @return the state of the pref that controls async plugin init */
-    bool IsStartingAsync() const { return mIsStartingAsync; }
-    /** @return whether this modules NP_Initialize has successfully completed
-        executing */
-    bool IsInitialized() const { return mNPInitialized; }
     bool IsChrome() const { return mIsChrome; }
 
     virtual void SetPlugin(nsNPAPIPlugin* plugin) MOZ_OVERRIDE
     {
         mPlugin = plugin;
     }
 
     virtual void ActorDestroy(ActorDestroyReason why) MOZ_OVERRIDE;
@@ -111,18 +103,16 @@ public:
     }
 
     bool OkToCleanup() const {
         return !IsOnCxxStack();
     }
 
     void ProcessRemoteNativeEventsInInterruptCall();
 
-    virtual bool WaitForIPCConnection() { return true; }
-
     nsCString GetHistogramKey() const {
         return mPluginName + mPluginVersion;
     }
 
 protected:
     virtual mozilla::ipc::RacyInterruptPolicy
     MediateInterruptRace(const Message& parent, const Message& child) MOZ_OVERRIDE
     {
@@ -164,34 +154,26 @@ protected:
     RecvPopCursor() MOZ_OVERRIDE;
 
     virtual bool
     RecvNPN_SetException(const nsCString& aMessage) MOZ_OVERRIDE;
 
     virtual bool
     RecvNPN_ReloadPlugins(const bool& aReloadPages) MOZ_OVERRIDE;
 
-    virtual bool
-    RecvNP_InitializeResult(const NPError& aError) MOZ_OVERRIDE;
-
-    static BrowserStreamParent* StreamCast(NPP instance, NPStream* s,
-                                           PluginAsyncSurrogate** aSurrogate = nullptr);
+    static PluginInstanceParent* InstCast(NPP instance);
+    static BrowserStreamParent* StreamCast(NPP instance, NPStream* s);
 
 protected:
     virtual void UpdatePluginTimeout() {}
 
     virtual bool RecvNotifyContentModuleDestroyed() MOZ_OVERRIDE { return true; }
 
     void SetPluginFuncs(NPPluginFuncs* aFuncs);
 
-    nsresult NPP_NewInternal(NPMIMEType pluginType, NPP instance, uint16_t mode,
-                             InfallibleTArray<nsCString>& names,
-                             InfallibleTArray<nsCString>& values,
-                             NPSavedData* saved, NPError* error);
-
     // NPP-like API that Gecko calls are trampolined into.  These 
     // messages then get forwarded along to the plugin instance,
     // and then eventually the child process.
 
     static NPError NPP_Destroy(NPP instance, NPSavedData** save);
 
     static NPError NPP_SetWindow(NPP instance, NPWindow* window);
     static NPError NPP_NewStream(NPP instance, NPMIMEType type, NPStream* stream,
@@ -248,30 +230,27 @@ protected:
                                        uint64_t maxAge);
     virtual nsresult NPP_GetSitesWithData(InfallibleTArray<nsCString>& result);
 
 #if defined(XP_MACOSX)
     virtual nsresult IsRemoteDrawingCoreAnimation(NPP instance, bool *aDrawing);
     virtual nsresult ContentsScaleFactorChanged(NPP instance, double aContentsScaleFactor);
 #endif
 
-    void InitAsyncSurrogates();
-
 protected:
     void NotifyPluginCrashed();
-    void OnInitFailure();
 
     bool GetSetting(NPNVariable aVariable);
     void GetSettings(PluginSettings* aSettings);
 
     bool mIsChrome;
     bool mShutdown;
     bool mClearSiteDataSupported;
     bool mGetSitesWithDataSupported;
-    NPNetscapeFuncs* mNPNIface;
+    const NPNetscapeFuncs* mNPNIface;
     nsNPAPIPlugin* mPlugin;
     ScopedMethodFactory<PluginModuleParent> mTaskFactory;
     nsString mPluginDumpID;
     nsString mBrowserDumpID;
     nsString mHangID;
     nsRefPtr<nsIObserver> mProfilerObserver;
     TimeDuration mTimeBlocked;
     nsCString mPluginName;
@@ -282,39 +261,28 @@ protected:
     // object instead of the plugin process's lifetime
     ScopedClose mPluginXSocketFdDup;
 #endif
 
     bool
     GetPluginDetails(nsACString& aPluginName, nsACString& aPluginVersion);
 
     friend class mozilla::dom::CrashReporterParent;
-    friend class mozilla::plugins::PluginAsyncSurrogate;
-
-    bool              mIsStartingAsync;
-    bool              mNPInitialized;
-    nsTArray<nsRefPtr<PluginAsyncSurrogate>> mSurrogateInstances;
-    nsresult          mAsyncNewRv;
-    NPPluginFuncs*    mAsyncInitPluginFuncs;
 };
 
 class PluginModuleContentParent : public PluginModuleParent
 {
   public:
-    explicit PluginModuleContentParent();
-
     static PluginLibrary* LoadModule(uint32_t aPluginId);
 
-    static PluginModuleContentParent* Initialize(mozilla::ipc::Transport* aTransport,
-                                                 base::ProcessId aOtherProcess);
-
-    static void OnLoadPluginResult(const uint32_t& aPluginId, const bool& aResult);
-    static void AssociatePluginId(uint32_t aPluginId, base::ProcessId aProcessId);
+    static PluginModuleContentParent* Create(mozilla::ipc::Transport* aTransport,
+                                             base::ProcessId aOtherProcess);
 
   private:
+    explicit PluginModuleContentParent();
 
 #ifdef MOZ_CRASHREPORTER_INJECTOR
     void OnCrash(DWORD processID) MOZ_OVERRIDE {}
 #endif
 
     static PluginModuleContentParent* sSavedModuleParent;
 };
 
@@ -340,27 +308,16 @@ class PluginModuleChromeParent
     /**
      * Called by Plugin Hang UI to notify that the user has clicked continue.
      * Used for chrome hang annotations.
      */
     void
     OnHangUIContinue();
 #endif // XP_WIN
 
-    virtual bool WaitForIPCConnection() MOZ_OVERRIDE;
-
-    virtual bool
-    RecvNP_InitializeResult(const NPError& aError) MOZ_OVERRIDE;
-
-    void
-    SetContentParent(dom::ContentParent* aContentParent);
-
-    bool
-    SendAssociatePluginId();
-
     void CachedSettingChanged();
 
 private:
     virtual void
     EnteredCxxStack() MOZ_OVERRIDE;
 
     void
     ExitedCxxStack() MOZ_OVERRIDE;
@@ -379,24 +336,18 @@ private:
     AllocPCrashReporterParent(mozilla::dom::NativeThreadId* id,
                               uint32_t* processType) MOZ_OVERRIDE;
     virtual bool
     DeallocPCrashReporterParent(PCrashReporterParent* actor) MOZ_OVERRIDE;
 
     PluginProcessParent* Process() const { return mSubprocess; }
     base::ProcessHandle ChildProcessHandle() { return mSubprocess->GetChildProcessHandle(); }
 
-#if defined(XP_UNIX) && !defined(XP_MACOSX) && !defined(MOZ_WIDGET_GONK)
-    virtual nsresult NP_Initialize(NPNetscapeFuncs* bFuncs, NPPluginFuncs* pFuncs, NPError* error) MOZ_OVERRIDE;
-#else
-    virtual nsresult NP_Initialize(NPNetscapeFuncs* bFuncs, NPError* error) MOZ_OVERRIDE;
-#endif
-
-#if defined(XP_WIN) || defined(XP_MACOSX)
-    virtual nsresult NP_GetEntryPoints(NPPluginFuncs* pFuncs, NPError* error) MOZ_OVERRIDE;
+#if !defined(XP_UNIX) || defined(XP_MACOSX) || defined(MOZ_WIDGET_GONK)
+    virtual nsresult NP_Initialize(NPNetscapeFuncs* bFuncs, NPError* error);
 #endif
 
     virtual void ActorDestroy(ActorDestroyReason why) MOZ_OVERRIDE;
 
     // aFilePath is UTF8, not native!
     explicit PluginModuleChromeParent(const char* aFilePath, uint32_t aPluginId);
 
     CrashReporterParent* CrashReporter();
@@ -465,53 +416,25 @@ private:
     /**
      * Finishes the Plugin Hang UI and cancels if it is being shown to the user.
      */
     void
     FinishHangUI();
 #endif
 
     friend class mozilla::dom::CrashReporterParent;
-    friend class mozilla::plugins::PluginAsyncSurrogate;
 
 #ifdef MOZ_CRASHREPORTER_INJECTOR
     void InitializeInjector();
-
+    
     void OnCrash(DWORD processID) MOZ_OVERRIDE;
 
     DWORD mFlashProcess1;
     DWORD mFlashProcess2;
 #endif
 
-    void OnProcessLaunched(const bool aSucceeded);
-
-    class LaunchedTask : public LaunchCompleteTask
-    {
-    public:
-        explicit LaunchedTask(PluginModuleChromeParent* aModule)
-            : mModule(aModule)
-        {
-            MOZ_ASSERT(aModule);
-        }
-
-        void Run() MOZ_OVERRIDE
-        {
-            mModule->OnProcessLaunched(mLaunchSucceeded);
-        }
-
-    private:
-        PluginModuleChromeParent* mModule;
-    };
-
-    friend class LaunchedTask;
-
-    bool                mInitOnAsyncConnect;
-    nsresult            mAsyncInitRv;
-    NPError             mAsyncInitError;
-    dom::ContentParent* mContentParent;
     nsCOMPtr<nsIObserver> mOfflineObserver;
-    bool mIsFlashPlugin;
 };
 
 } // namespace plugins
 } // namespace mozilla
 
 #endif // mozilla_plugins_PluginModuleParent_h
--- a/dom/plugins/ipc/PluginProcessParent.cpp
+++ b/dom/plugins/ipc/PluginProcessParent.cpp
@@ -7,17 +7,16 @@
 #include "mozilla/plugins/PluginProcessParent.h"
 
 #include "base/string_util.h"
 #include "base/process_util.h"
 
 #include "mozilla/ipc/BrowserProcessSubThread.h"
 #include "mozilla/plugins/PluginMessageUtils.h"
 #include "mozilla/Telemetry.h"
-#include "nsThreadUtils.h"
 
 using std::vector;
 using std::string;
 
 using mozilla::ipc::BrowserProcessSubThread;
 using mozilla::ipc::GeckoChildProcessHost;
 using mozilla::plugins::PluginProcessParent;
 using base::ProcessArchitecture;
@@ -26,28 +25,26 @@ template<>
 struct RunnableMethodTraits<PluginProcessParent>
 {
     static void RetainCallee(PluginProcessParent* obj) { }
     static void ReleaseCallee(PluginProcessParent* obj) { }
 };
 
 PluginProcessParent::PluginProcessParent(const std::string& aPluginFilePath) :
     GeckoChildProcessHost(GeckoProcessType_Plugin),
-    mPluginFilePath(aPluginFilePath),
-    mMainMsgLoop(MessageLoop::current()),
-    mRunCompleteTaskImmediately(false)
+    mPluginFilePath(aPluginFilePath)
 {
 }
 
 PluginProcessParent::~PluginProcessParent()
 {
 }
 
 bool
-PluginProcessParent::Launch(UniquePtr<LaunchCompleteTask> aLaunchCompleteTask)
+PluginProcessParent::Launch(int32_t timeoutMs)
 {
     ProcessArchitecture currentArchitecture = base::GetCurrentProcessArchitecture();
     uint32_t containerArchitectures = GetSupportedArchitecturesForProcessType(GeckoProcessType_Plugin);
 
     uint32_t pluginLibArchitectures = currentArchitecture;
 #ifdef XP_MACOSX
     nsresult rv = GetArchitecturesForBinary(mPluginFilePath.c_str(), &pluginLibArchitectures);
     if (NS_FAILED(rv)) {
@@ -72,81 +69,28 @@ PluginProcessParent::Launch(UniquePtr<La
         else if (base::PROCESS_ARCH_ARM & pluginLibArchitectures & containerArchitectures) {
           selectedArchitecture = base::PROCESS_ARCH_ARM;
         }
         else {
             return false;
         }
     }
 
-    mLaunchCompleteTask = Move(aLaunchCompleteTask);
-
     vector<string> args;
     args.push_back(MungePluginDsoPath(mPluginFilePath));
-
-    bool result = AsyncLaunch(args, selectedArchitecture);
-    if (!result) {
-        mLaunchCompleteTask = nullptr;
-    }
-    return result;
+    Telemetry::AutoTimer<Telemetry::PLUGIN_STARTUP_MS> timer;
+    return SyncLaunch(args, timeoutMs, selectedArchitecture);
 }
 
 void
 PluginProcessParent::Delete()
 {
   MessageLoop* currentLoop = MessageLoop::current();
   MessageLoop* ioLoop = XRE_GetIOMessageLoop();
 
   if (currentLoop == ioLoop) {
       delete this;
       return;
   }
 
   ioLoop->PostTask(FROM_HERE,
                    NewRunnableMethod(this, &PluginProcessParent::Delete));
 }
-
-void
-PluginProcessParent::SetCallRunnableImmediately(bool aCallImmediately)
-{
-    mRunCompleteTaskImmediately = aCallImmediately;
-}
-
-bool
-PluginProcessParent::WaitUntilConnected(int32_t aTimeoutMs)
-{
-    bool result = GeckoChildProcessHost::WaitUntilConnected(aTimeoutMs);
-    if (mRunCompleteTaskImmediately && mLaunchCompleteTask) {
-        if (result) {
-            mLaunchCompleteTask->SetLaunchSucceeded();
-        }
-        mLaunchCompleteTask->Run();
-        mLaunchCompleteTask = nullptr;
-    }
-    return result;
-}
-
-void
-PluginProcessParent::OnChannelConnected(int32_t peer_pid)
-{
-    GeckoChildProcessHost::OnChannelConnected(peer_pid);
-    if (mLaunchCompleteTask && !mRunCompleteTaskImmediately) {
-        mLaunchCompleteTask->SetLaunchSucceeded();
-        mMainMsgLoop->PostTask(FROM_HERE, mLaunchCompleteTask.release());
-    }
-}
-
-void
-PluginProcessParent::OnChannelError()
-{
-    GeckoChildProcessHost::OnChannelError();
-    if (mLaunchCompleteTask && !mRunCompleteTaskImmediately) {
-        mMainMsgLoop->PostTask(FROM_HERE, mLaunchCompleteTask.release());
-    }
-}
-
-bool
-PluginProcessParent::IsConnected()
-{
-    mozilla::MonitorAutoLock lock(mMonitor);
-    return mProcessState == PROCESS_CONNECTED;
-}
-
--- a/dom/plugins/ipc/PluginProcessParent.h
+++ b/dom/plugins/ipc/PluginProcessParent.h
@@ -6,83 +6,52 @@
 
 #ifndef dom_plugins_PluginProcessParent_h
 #define dom_plugins_PluginProcessParent_h 1
 
 #include "mozilla/Attributes.h"
 #include "base/basictypes.h"
 
 #include "base/file_path.h"
-#include "base/task.h"
 #include "base/thread.h"
 #include "base/waitable_event.h"
 #include "chrome/common/child_process_host.h"
 
 #include "mozilla/ipc/GeckoChildProcessHost.h"
-#include "mozilla/UniquePtr.h"
-#include "nsCOMPtr.h"
-#include "nsIRunnable.h"
 
 namespace mozilla {
 namespace plugins {
-
-class LaunchCompleteTask : public Task
-{
-public:
-    LaunchCompleteTask()
-        : mLaunchSucceeded(false)
-    {
-    }
-
-    void SetLaunchSucceeded() { mLaunchSucceeded = true; }
-
-protected:
-    bool mLaunchSucceeded;
-};
+//-----------------------------------------------------------------------------
 
 class PluginProcessParent : public mozilla::ipc::GeckoChildProcessHost
 {
 public:
     explicit PluginProcessParent(const std::string& aPluginFilePath);
     ~PluginProcessParent();
 
     /**
-     * Launch the plugin process. If the process fails to launch,
-     * this method will return false.
-     *
-     * @param aLaunchCompleteTask Task that is executed on the main
-     * thread once the asynchonous launch has completed.
+     * Synchronously launch the plugin process. If the process fails to launch
+     * after timeoutMs, this method will return false.
      */
-    bool Launch(UniquePtr<LaunchCompleteTask> aLaunchCompleteTask = UniquePtr<LaunchCompleteTask>());
+    bool Launch(int32_t timeoutMs);
 
     void Delete();
 
     virtual bool CanShutdown() MOZ_OVERRIDE
     {
         return true;
     }
 
     const std::string& GetPluginFilePath() { return mPluginFilePath; }
 
     using mozilla::ipc::GeckoChildProcessHost::GetShutDownEvent;
     using mozilla::ipc::GeckoChildProcessHost::GetChannel;
 
-    void SetCallRunnableImmediately(bool aCallImmediately);
-    virtual bool WaitUntilConnected(int32_t aTimeoutMs = 0) MOZ_OVERRIDE;
-
-    virtual void OnChannelConnected(int32_t peer_pid) MOZ_OVERRIDE;
-    virtual void OnChannelError() MOZ_OVERRIDE;
-
-    bool IsConnected();
-
 private:
     std::string mPluginFilePath;
-    UniquePtr<LaunchCompleteTask> mLaunchCompleteTask;
-    MessageLoop* mMainMsgLoop;
-    bool mRunCompleteTaskImmediately;
 
     DISALLOW_EVIL_CONSTRUCTORS(PluginProcessParent);
 };
 
 
 } // namespace plugins
 } // namespace mozilla
 
--- a/dom/plugins/ipc/PluginScriptableObjectChild.cpp
+++ b/dom/plugins/ipc/PluginScriptableObjectChild.cpp
@@ -1276,12 +1276,10 @@ PluginScriptableObjectChild::CollectForI
     }
     return PL_DHASH_NEXT;
 }
 
 /* static */ void
 PluginScriptableObjectChild::NotifyOfInstanceShutdown(PluginInstanceChild* aInstance)
 {
   AssertPluginThread();
-  if (sObjectMap) {
-    sObjectMap->EnumerateEntries(CollectForInstance, aInstance);
-  }
+  sObjectMap->EnumerateEntries(CollectForInstance, aInstance);
 }
--- a/dom/plugins/ipc/PluginScriptableObjectParent.cpp
+++ b/dom/plugins/ipc/PluginScriptableObjectParent.cpp
@@ -7,17 +7,16 @@
 #include "PluginScriptableObjectParent.h"
 
 #include "jsapi.h"
 #include "mozilla/DebugOnly.h"
 #include "mozilla/dom/ScriptSettings.h"
 #include "mozilla/plugins/PluginTypes.h"
 #include "mozilla/unused.h"
 #include "nsNPAPIPlugin.h"
-#include "PluginAsyncSurrogate.h"
 #include "PluginScriptableObjectUtils.h"
 
 using namespace mozilla;
 using namespace mozilla::plugins;
 using namespace mozilla::plugins::parent;
 
 /**
  * NPIdentifiers in the chrome process are stored as jsids. The difficulty is in
@@ -106,17 +105,16 @@ FromNPIdentifier(NPIdentifier aIdentifie
 }
 
 namespace {
 
 inline void
 ReleaseVariant(NPVariant& aVariant,
                PluginInstanceParent* aInstance)
 {
-  PushSurrogateAcceptCalls acceptCalls(aInstance);
   const NPNetscapeFuncs* npn = GetNetscapeFuncs(aInstance);
   if (npn) {
     npn->releasevariantvalue(&aVariant);
   }
 }
 
 } // anonymous namespace
 
@@ -640,17 +638,16 @@ PluginScriptableObjectParent::Initialize
 }
 
 NPObject*
 PluginScriptableObjectParent::CreateProxyObject()
 {
   NS_ASSERTION(mInstance, "Must have an instance!");
   NS_ASSERTION(mType == Proxy, "Shouldn't call this for non-proxy object!");
 
-  PushSurrogateAcceptCalls acceptCalls(mInstance);
   const NPNetscapeFuncs* npn = GetNetscapeFuncs(mInstance);
 
   NPObject* npobject = npn->createobject(mInstance->GetNPP(),
                                          const_cast<NPClass*>(GetClass()));
   NS_ASSERTION(npobject, "Failed to create object?!");
   NS_ASSERTION(npobject->_class == GetClass(), "Wrong kind of object!");
   NS_ASSERTION(npobject->referenceCount == 1, "Some kind of live object!");
 
@@ -759,17 +756,16 @@ PluginScriptableObjectParent::AnswerHasM
 
   PluginInstanceParent* instance = GetInstance();
   if (!instance) {
     NS_ERROR("No instance?!");
     *aHasMethod = false;
     return true;
   }
 
-  PushSurrogateAcceptCalls acceptCalls(instance);
   const NPNetscapeFuncs* npn = GetNetscapeFuncs(instance);
   if (!npn) {
     NS_ERROR("No netscape funcs?!");
     *aHasMethod = false;
     return true;
   }
 
   StackIdentifier stackID(aId);
@@ -800,17 +796,16 @@ PluginScriptableObjectParent::AnswerInvo
   PluginInstanceParent* instance = GetInstance();
   if (!instance) {
     NS_ERROR("No instance?!");
     *aResult = void_t();
     *aSuccess = false;
     return true;
   }
 
-  PushSurrogateAcceptCalls acceptCalls(instance);
   const NPNetscapeFuncs* npn = GetNetscapeFuncs(instance);
   if (!npn) {
     NS_ERROR("No netscape funcs?!");
     *aResult = void_t();
     *aSuccess = false;
     return true;
   }
 
@@ -890,17 +885,16 @@ PluginScriptableObjectParent::AnswerInvo
   PluginInstanceParent* instance = GetInstance();
   if (!instance) {
     NS_ERROR("No instance?!");
     *aResult = void_t();
     *aSuccess = false;
     return true;
   }
 
-  PushSurrogateAcceptCalls acceptCalls(instance);
   const NPNetscapeFuncs* npn = GetNetscapeFuncs(instance);
   if (!npn) {
     NS_ERROR("No netscape funcs?!");
     *aResult = void_t();
     *aSuccess = false;
     return true;
   }
 
@@ -971,17 +965,16 @@ PluginScriptableObjectParent::AnswerHasP
 
   PluginInstanceParent* instance = GetInstance();
   if (!instance) {
     NS_ERROR("No instance?!");
     *aHasProperty = false;
     return true;
   }
 
-  PushSurrogateAcceptCalls acceptCalls(instance);
   const NPNetscapeFuncs* npn = GetNetscapeFuncs(instance);
   if (!npn) {
     NS_ERROR("No netscape funcs?!");
     *aHasProperty = false;
     return true;
   }
 
   StackIdentifier stackID(aId);
@@ -1014,17 +1007,16 @@ PluginScriptableObjectParent::AnswerGetP
   PluginInstanceParent* instance = GetInstance();
   if (!instance) {
     NS_ERROR("No instance?!");
     *aResult = void_t();
     *aSuccess = false;
     return true;
   }
 
-  PushSurrogateAcceptCalls acceptCalls(instance);
   const NPNetscapeFuncs* npn = GetNetscapeFuncs(instance);
   if (!npn) {
     NS_ERROR("No netscape funcs?!");
     *aResult = void_t();
     *aSuccess = false;
     return true;
   }
 
@@ -1071,17 +1063,16 @@ PluginScriptableObjectParent::AnswerSetP
 
   PluginInstanceParent* instance = GetInstance();
   if (!instance) {
     NS_ERROR("No instance?!");
     *aSuccess = false;
     return true;
   }
 
-  PushSurrogateAcceptCalls acceptCalls(instance);
   const NPNetscapeFuncs* npn = GetNetscapeFuncs(instance);
   if (!npn) {
     NS_ERROR("No netscape funcs?!");
     *aSuccess = false;
     return true;
   }
 
   NPVariant converted;
@@ -1118,17 +1109,16 @@ PluginScriptableObjectParent::AnswerRemo
 
   PluginInstanceParent* instance = GetInstance();
   if (!instance) {
     NS_ERROR("No instance?!");
     *aSuccess = false;
     return true;
   }
 
-  PushSurrogateAcceptCalls acceptCalls(instance);
   const NPNetscapeFuncs* npn = GetNetscapeFuncs(instance);
   if (!npn) {
     NS_ERROR("No netscape funcs?!");
     *aSuccess = false;
     return true;
   }
 
   StackIdentifier stackID(aId);
@@ -1157,17 +1147,16 @@ PluginScriptableObjectParent::AnswerEnum
 
   PluginInstanceParent* instance = GetInstance();
   if (!instance) {
     NS_ERROR("No instance?!");
     *aSuccess = false;
     return true;
   }
 
-  PushSurrogateAcceptCalls acceptCalls(instance);
   const NPNetscapeFuncs* npn = GetNetscapeFuncs(instance);
   if (!npn) {
     NS_WARNING("No netscape funcs?!");
     *aSuccess = false;
     return true;
   }
 
   NPIdentifier* ids;
@@ -1210,17 +1199,16 @@ PluginScriptableObjectParent::AnswerCons
   PluginInstanceParent* instance = GetInstance();
   if (!instance) {
     NS_ERROR("No instance?!");
     *aResult = void_t();
     *aSuccess = false;
     return true;
   }
 
-  PushSurrogateAcceptCalls acceptCalls(instance);
   const NPNetscapeFuncs* npn = GetNetscapeFuncs(instance);
   if (!npn) {
     NS_ERROR("No netscape funcs?!");
     *aResult = void_t();
     *aSuccess = false;
     return true;
   }
 
@@ -1303,17 +1291,16 @@ PluginScriptableObjectParent::AnswerNPN_
   PluginInstanceParent* instance = GetInstance();
   if (!instance) {
     NS_ERROR("No instance?!");
     *aResult = void_t();
     *aSuccess = false;
     return true;
   }
 
-  PushSurrogateAcceptCalls acceptCalls(instance);
   const NPNetscapeFuncs* npn = GetNetscapeFuncs(instance);
   if (!npn) {
     NS_ERROR("No netscape funcs?!");
     *aResult = void_t();
     *aSuccess = false;
     return true;
   }
 
--- a/dom/plugins/ipc/PluginScriptableObjectParent.h
+++ b/dom/plugins/ipc/PluginScriptableObjectParent.h
@@ -11,17 +11,16 @@
 #include "mozilla/plugins/PluginMessageUtils.h"
 
 #include "npfunctions.h"
 #include "npruntime.h"
 
 namespace mozilla {
 namespace plugins {
 
-class PluginAsyncSurrogate;
 class PluginInstanceParent;
 class PluginScriptableObjectParent;
 
 struct ParentNPObject : NPObject
 {
   ParentNPObject()
     : NPObject(), parent(nullptr), invalidated(false) { }
 
--- a/dom/plugins/ipc/moz.build
+++ b/dom/plugins/ipc/moz.build
@@ -16,19 +16,17 @@ EXPORTS.mozilla.plugins += [
     'BrowserStreamChild.h',
     'BrowserStreamParent.h',
     'ChildAsyncCall.h',
     'ChildTimer.h',
     'NPEventAndroid.h',
     'NPEventOSX.h',
     'NPEventUnix.h',
     'NPEventWindows.h',
-    'PluginAsyncSurrogate.h',
     'PluginBridge.h',
-    'PluginDataResolver.h',
     'PluginInstanceChild.h',
     'PluginInstanceParent.h',
     'PluginMessageUtils.h',
     'PluginModuleChild.h',
     'PluginModuleParent.h',
     'PluginProcessChild.h',
     'PluginProcessParent.h',
     'PluginScriptableObjectChild.h',
@@ -77,17 +75,16 @@ if CONFIG['MOZ_ENABLE_QT']:
         'PluginHelperQt.cpp',
     ]
 
 UNIFIED_SOURCES += [
     'BrowserStreamChild.cpp',
     'BrowserStreamParent.cpp',
     'ChildAsyncCall.cpp',
     'ChildTimer.cpp',
-    'PluginAsyncSurrogate.cpp',
     'PluginBackgroundDestroyer.cpp',
     'PluginInstanceParent.cpp',
     'PluginMessageUtils.cpp',
     'PluginModuleParent.cpp',
     'PluginProcessChild.cpp',
     'PluginProcessParent.cpp',
     'PluginScriptableObjectChild.cpp',
     'PluginScriptableObjectParent.cpp',
--- a/ipc/glue/GeckoChildProcessHost.cpp
+++ b/ipc/glue/GeckoChildProcessHost.cpp
@@ -310,57 +310,27 @@ void GeckoChildProcessHost::InitWindowsG
 }
 #endif
 
 bool
 GeckoChildProcessHost::SyncLaunch(std::vector<std::string> aExtraOpts, int aTimeoutMs, base::ProcessArchitecture arch)
 {
   PrepareLaunch();
 
+  PRIntervalTime timeoutTicks = (aTimeoutMs > 0) ? 
+    PR_MillisecondsToInterval(aTimeoutMs) : PR_INTERVAL_NO_TIMEOUT;
   MessageLoop* ioLoop = XRE_GetIOMessageLoop();
   NS_ASSERTION(MessageLoop::current() != ioLoop, "sync launch from the IO thread NYI");
 
   ioLoop->PostTask(FROM_HERE,
                    NewRunnableMethod(this,
                                      &GeckoChildProcessHost::RunPerformAsyncLaunch,
                                      aExtraOpts, arch));
-
-  return WaitUntilConnected(aTimeoutMs);
-}
-
-bool
-GeckoChildProcessHost::AsyncLaunch(std::vector<std::string> aExtraOpts,
-                                   base::ProcessArchitecture arch)
-{
-  PrepareLaunch();
-
-  MessageLoop* ioLoop = XRE_GetIOMessageLoop();
-  ioLoop->PostTask(FROM_HERE,
-                   NewRunnableMethod(this,
-                                     &GeckoChildProcessHost::RunPerformAsyncLaunch,
-                                     aExtraOpts, arch));
-
-  // This may look like the sync launch wait, but we only delay as
-  // long as it takes to create the channel.
-  MonitorAutoLock lock(mMonitor);
-  while (mProcessState < CHANNEL_INITIALIZED) {
-    lock.Wait();
-  }
-
-  return true;
-}
-
-bool
-GeckoChildProcessHost::WaitUntilConnected(int32_t aTimeoutMs)
-{
   // NB: this uses a different mechanism than the chromium parent
   // class.
-  PRIntervalTime timeoutTicks = (aTimeoutMs > 0) ? 
-    PR_MillisecondsToInterval(aTimeoutMs) : PR_INTERVAL_NO_TIMEOUT;
-
   MonitorAutoLock lock(mMonitor);
   PRIntervalTime waitStart = PR_IntervalNow();
   PRIntervalTime current;
 
   // We'll receive several notifications, we need to exit when we
   // have either successfully launched or have timed out.
   while (mProcessState != PROCESS_CONNECTED) {
     // If there was an error then return it, don't wait out the timeout.
@@ -380,16 +350,37 @@ GeckoChildProcessHost::WaitUntilConnecte
       waitStart = current;
     }
   }
 
   return mProcessState == PROCESS_CONNECTED;
 }
 
 bool
+GeckoChildProcessHost::AsyncLaunch(std::vector<std::string> aExtraOpts)
+{
+  PrepareLaunch();
+
+  MessageLoop* ioLoop = XRE_GetIOMessageLoop();
+  ioLoop->PostTask(FROM_HERE,
+                   NewRunnableMethod(this,
+                                     &GeckoChildProcessHost::RunPerformAsyncLaunch,
+                                     aExtraOpts, base::GetCurrentProcessArchitecture()));
+
+  // This may look like the sync launch wait, but we only delay as
+  // long as it takes to create the channel.
+  MonitorAutoLock lock(mMonitor);
+  while (mProcessState < CHANNEL_INITIALIZED) {
+    lock.Wait();
+  }
+
+  return true;
+}
+
+bool
 GeckoChildProcessHost::LaunchAndWaitForProcessHandle(StringVector aExtraOpts)
 {
   PrepareLaunch();
 
   MessageLoop* ioLoop = XRE_GetIOMessageLoop();
   ioLoop->PostTask(FROM_HERE,
                    NewRunnableMethod(this,
                                      &GeckoChildProcessHost::RunPerformAsyncLaunch,
--- a/ipc/glue/GeckoChildProcessHost.h
+++ b/ipc/glue/GeckoChildProcessHost.h
@@ -47,20 +47,17 @@ public:
 
   static nsresult GetArchitecturesForBinary(const char *path, uint32_t *result);
 
   static uint32_t GetSupportedArchitecturesForProcessType(GeckoProcessType type);
 
   // Block until the IPC channel for our subprocess is initialized,
   // but no longer.  The child process may or may not have been
   // created when this method returns.
-  bool AsyncLaunch(StringVector aExtraOpts=StringVector(),
-                   base::ProcessArchitecture arch=base::GetCurrentProcessArchitecture());
-
-  virtual bool WaitUntilConnected(int32_t aTimeoutMs = 0);
+  bool AsyncLaunch(StringVector aExtraOpts=StringVector());
 
   // Block until the IPC channel for our subprocess is initialized and
   // the OS process is created.  The subprocess may or may not have
   // connected back to us when this method returns.
   //
   // NB: on POSIX, this method is relatively cheap, and doesn't
   // require disk IO.  On win32 however, it requires at least the
   // analogue of stat().  This difference induces a semantic
--- a/ipc/glue/MessageChannel.cpp
+++ b/ipc/glue/MessageChannel.cpp
@@ -293,17 +293,16 @@ MessageChannel::MessageChannel(MessageLi
     mDispatchingSyncMessagePriority(0),
     mDispatchingAsyncMessage(false),
     mDispatchingAsyncMessagePriority(0),
     mCurrentTransaction(0),
     mTimedOutMessageSeqno(0),
     mRecvdErrors(0),
     mRemoteStackDepthGuess(false),
     mSawInterruptOutMsg(false),
-    mIsWaitingForIncoming(false),
     mAbortOnError(false),
     mBlockScripts(false),
     mFlags(REQUIRE_DEFAULT),
     mPeerPidSet(false),
     mPeerPid(-1)
 {
     MOZ_COUNT_CTOR(ipc::MessageChannel);
 
@@ -660,18 +659,17 @@ MessageChannel::OnMessageReceivedFromLin
             mPending.erase((++it).base());
         } else {
             // No other messages with the same type/destination exist.
             compress = false;
         }
     }
 
     bool shouldWakeUp = AwaitingInterruptReply() ||
-                        (AwaitingSyncReply() && !ShouldDeferMessage(aMsg)) ||
-                        AwaitingIncomingMessage();
+                        (AwaitingSyncReply() && !ShouldDeferMessage(aMsg));
 
     // There are three cases we're concerned about, relating to the state of the
     // main thread:
     //
     // (1) We are waiting on a sync reply - main thread is blocked on the
     //     IPC monitor.
     //   - If the message is high priority, we wake up the main thread to
     //     deliver the message depending on ShouldDeferMessage. Otherwise, we
@@ -985,45 +983,16 @@ MessageChannel::Call(Message* aMsg, Mess
             return false;
         }
     }
 
     return true;
 }
 
 bool
-MessageChannel::WaitForIncomingMessage()
-{
-#ifdef OS_WIN
-    SyncStackFrame frame(this, true);
-#endif
-
-    { // Scope for lock
-        MonitorAutoLock lock(*mMonitor);
-        AutoEnterWaitForIncoming waitingForIncoming(*this);
-        if (mChannelState != ChannelConnected) {
-            return false;
-        }
-        if (!HasPendingEvents()) {
-            return WaitForInterruptNotify();
-        }
-    }
-
-    return OnMaybeDequeueOne();
-}
-
-bool
-MessageChannel::HasPendingEvents()
-{
-    AssertWorkerThread();
-    mMonitor->AssertCurrentThreadOwns();
-    return Connected() && !mPending.empty();
-}
-
-bool
 MessageChannel::InterruptEventOccurred()
 {
     AssertWorkerThread();
     mMonitor->AssertCurrentThreadOwns();
     IPC_ASSERT(InterruptStackDepth() > 0, "not in wait loop");
 
     return (!Connected() ||
             !mPending.empty() ||
@@ -1572,17 +1541,17 @@ void
 MessageChannel::OnChannelErrorFromLink()
 {
     AssertLinkThread();
     mMonitor->AssertCurrentThreadOwns();
 
     if (InterruptStackDepth() > 0)
         NotifyWorkerThread();
 
-    if (AwaitingSyncReply() || AwaitingIncomingMessage())
+    if (AwaitingSyncReply())
         NotifyWorkerThread();
 
     if (ChannelClosing != mChannelState) {
         if (mAbortOnError) {
             NS_RUNTIMEABORT("Aborting on channel error.");
         }
         mChannelState = ChannelError;
         mMonitor->Notify();
--- a/ipc/glue/MessageChannel.h
+++ b/ipc/glue/MessageChannel.h
@@ -119,19 +119,16 @@ class MessageChannel : HasResultCodes
     bool Echo(Message* aMsg);
 
     // Synchronously send |msg| (i.e., wait for |reply|)
     bool Send(Message* aMsg, Message* aReply);
 
     // Make an Interrupt call to the other side of the channel
     bool Call(Message* aMsg, Message* aReply);
 
-    // Wait until a message is received
-    bool WaitForIncomingMessage();
-
     bool CanSend() const;
 
     void SetReplyTimeoutMs(int32_t aTimeoutMs);
 
     bool IsOnCxxStack() const {
         return !mCxxStackFrames.empty();
     }
 
@@ -212,17 +209,16 @@ class MessageChannel : HasResultCodes
     bool MaybeHandleError(Result code, const Message& aMsg, const char* channelName);
 
     void Clear();
 
     // Send OnChannelConnected notification to listeners.
     void DispatchOnChannelConnected();
 
     bool InterruptEventOccurred();
-    bool HasPendingEvents();
 
     bool ProcessPendingRequest(const Message &aUrgent);
 
     void MaybeUndeferIncall();
     void EnqueuePendingMessages();
 
     // Executed on the worker thread. Dequeues one pending message.
     bool OnMaybeDequeueOne();
@@ -318,40 +314,16 @@ class MessageChannel : HasResultCodes
     int AwaitingSyncReplyPriority() const {
         mMonitor->AssertCurrentThreadOwns();
         return mAwaitingSyncReplyPriority;
     }
     bool AwaitingInterruptReply() const {
         mMonitor->AssertCurrentThreadOwns();
         return !mInterruptStack.empty();
     }
-    bool AwaitingIncomingMessage() const {
-        mMonitor->AssertCurrentThreadOwns();
-        return mIsWaitingForIncoming;
-    }
-
-    class MOZ_STACK_CLASS AutoEnterWaitForIncoming
-    {
-    public:
-        explicit AutoEnterWaitForIncoming(MessageChannel& aChannel)
-            : mChannel(aChannel)
-        {
-            aChannel.mMonitor->AssertCurrentThreadOwns();
-            aChannel.mIsWaitingForIncoming = true;
-        }
-
-        ~AutoEnterWaitForIncoming()
-        {
-            mChannel.mIsWaitingForIncoming = false;
-        }
-
-    private:
-        MessageChannel& mChannel;
-    };
-    friend class AutoEnterWaitForIncoming;
 
     // Returns true if we're dispatching a sync message's callback.
     bool DispatchingSyncMessage() const {
         AssertWorkerThread();
         return mDispatchingSyncMessage;
     }
 
     int DispatchingSyncMessagePriority() const {
@@ -662,21 +634,16 @@ class MessageChannel : HasResultCodes
     // protected by mMonitor.  It is managed exclusively by the helper
     // |class CxxStackFrame|.
     mozilla::Vector<InterruptFrame> mCxxStackFrames;
 
     // Did we process an Interrupt out-call during this stack?  Only meaningful in
     // ExitedCxxStack(), from which this variable is reset.
     bool mSawInterruptOutMsg;
 
-    // Are we waiting on this channel for an incoming message? This is used
-    // to implement WaitForIncomingMessage(). Must only be accessed while owning
-    // mMonitor.
-    bool mIsWaitingForIncoming;
-
     // Map of replies received "out of turn", because of Interrupt
     // in-calls racing with replies to outstanding in-calls.  See
     // https://bugzilla.mozilla.org/show_bug.cgi?id=521929.
     MessageMap mOutOfTurnReplies;
 
     // Stack of Interrupt in-calls that were deferred because of race
     // conditions.
     std::stack<Message> mDeferred;
--- a/ipc/glue/WindowsMessageLoop.cpp
+++ b/ipc/glue/WindowsMessageLoop.cpp
@@ -961,17 +961,17 @@ MessageChannel::WaitForInterruptNotify()
   MOZ_ASSERT(gUIThreadId, "InitUIThread was not called!");
 
   // Re-use sync notification wait code if this channel does not require
   // Windows message deferral behavior. 
   if (!(mFlags & REQUIRE_DEFERRED_MESSAGE_PROTECTION)) {
     return WaitForSyncNotify();
   }
 
-  if (!InterruptStackDepth() && !AwaitingIncomingMessage()) {
+  if (!InterruptStackDepth()) {
     // There is currently no way to recover from this condition.
     NS_RUNTIMEABORT("StackDepth() is 0 in call to MessageChannel::WaitForNotify!");
   }
 
   NS_ASSERTION(mFlags & REQUIRE_DEFERRED_MESSAGE_PROTECTION,
                "Shouldn't be here for channels that don't use message deferral!");
   NS_ASSERTION(mTopFrame && mTopFrame->mInterrupt,
                "Top frame is not a sync frame!");
--- a/modules/libpref/init/all.js
+++ b/modules/libpref/init/all.js
@@ -2364,18 +2364,16 @@ pref("dom.ipc.plugins.flash.disable-prot
 
 pref("dom.ipc.plugins.flash.subprocess.crashreporter.enabled", true);
 pref("dom.ipc.plugins.reportCrashURL", true);
 
 // How long we wait before unloading an idle plugin process.
 // Defaults to 30 seconds.
 pref("dom.ipc.plugins.unloadTimeoutSecs", 30);
 
-pref("dom.ipc.plugins.asyncInit", false);
-
 pref("dom.ipc.processCount", 1);
 
 // Enable caching of Moz2D Path objects for SVG geometry elements
 pref("svg.path-caching.enabled", true);
 
 // Enable the use of display-lists for SVG hit-testing and painting.
 pref("svg.display-lists.hit-testing.enabled", true);
 pref("svg.display-lists.painting.enabled", true);
--- a/toolkit/components/telemetry/Histograms.json
+++ b/toolkit/components/telemetry/Histograms.json
@@ -7024,25 +7024,16 @@
     "expires_in_version": "40",
     "kind": "exponential",
     "high": "10000",
     "n_buckets": 20,
     "extended_statistics_ok": true,
     "keyed": true,
     "description": "Time (ms) that the main thread has been blocked on NPP_NewStream in an IPC plugin"
   },
-  "BLOCKED_ON_PLUGINASYNCSURROGATE_WAITFORINIT_MS": {
-    "expires_in_version": "40",
-    "kind": "exponential",
-    "high": "10000",
-    "n_buckets": 20,
-    "extended_statistics_ok": true,
-    "keyed": true,
-    "description": "Time (ms) that the main thread has been blocked on PluginAsyncSurrogate::WaitForInit in an IPC plugin"
-  },
   "BLOCKED_ON_PLUGIN_INSTANCE_DESTROY_MS": {
     "expires_in_version": "40",
     "kind": "exponential",
     "high": "10000",
     "n_buckets": 20,
     "extended_statistics_ok": true,
     "keyed": true,
     "description": "Time (ms) that the main thread has been blocked on NPP_Destroy in an IPC plugin"
--- a/xpcom/base/ErrorList.h
+++ b/xpcom/base/ErrorList.h
@@ -325,17 +325,16 @@
   /* 7: NS_ERROR_MODULE_PLUGINS */
   /* ======================================================================= */
 #define MODULE NS_ERROR_MODULE_PLUGINS
   ERROR(NS_ERROR_PLUGINS_PLUGINSNOTCHANGED,        FAILURE(1000)),
   ERROR(NS_ERROR_PLUGIN_DISABLED,                  FAILURE(1001)),
   ERROR(NS_ERROR_PLUGIN_BLOCKLISTED,               FAILURE(1002)),
   ERROR(NS_ERROR_PLUGIN_TIME_RANGE_NOT_SUPPORTED,  FAILURE(1003)),
   ERROR(NS_ERROR_PLUGIN_CLICKTOPLAY,               FAILURE(1004)),
-  ERROR(NS_PLUGIN_INIT_PENDING,                    SUCCESS(1005)),
 #undef MODULE
 
 
   /* ======================================================================= */
   /* 8: NS_ERROR_MODULE_LAYOUT */
   /* ======================================================================= */
 #define MODULE NS_ERROR_MODULE_LAYOUT
   /* Return code for nsITableLayout */