Bug 1157237 - Move invocation of async NPP_New to an async task. r=jimm, a=lizzard
authorAaron Klotz <aklotz@mozilla.com>
Wed, 06 May 2015 01:53:51 -0600
changeset 266018 6a1a9d282be2b0eb6d4ff254d9c347883a2e5b2d
parent 266017 b38b8126e4d1749706afe0bf89dd074d3efd075b
child 266019 3bb36b3ef64e408a3123eee2d617af6e68cde2ca
push id4731
push userryanvm@gmail.com
push dateMon, 18 May 2015 21:18:07 +0000
treeherdermozilla-beta@6a1a9d282be2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjimm, lizzard
bugs1157237
milestone39.0
Bug 1157237 - Move invocation of async NPP_New to an async task. r=jimm, a=lizzard
dom/plugins/ipc/PluginModuleChild.cpp
--- a/dom/plugins/ipc/PluginModuleChild.cpp
+++ b/dom/plugins/ipc/PluginModuleChild.cpp
@@ -2204,26 +2204,36 @@ public:
         DebugOnly<bool> sendOk = mInstance->SendAsyncNPP_NewResult(mResult);
         MOZ_ASSERT(sendOk);
     }
 
 private:
     NPError  mResult;
 };
 
+static void
+RunAsyncNPP_New(void* aChildInstance)
+{
+    MOZ_ASSERT(aChildInstance);
+    PluginInstanceChild* childInstance =
+        static_cast<PluginInstanceChild*>(aChildInstance);
+    NPError rv = childInstance->DoNPP_New();
+    AsyncNewResultSender* task = new AsyncNewResultSender(childInstance, rv);
+    childInstance->PostChildAsyncCall(task);
+}
+
 bool
 PluginModuleChild::RecvAsyncNPP_New(PPluginInstanceChild* aActor)
 {
     PLUGIN_LOG_DEBUG_METHOD;
     PluginInstanceChild* childInstance =
         reinterpret_cast<PluginInstanceChild*>(aActor);
     AssertPluginThread();
-    NPError rv = childInstance->DoNPP_New();
-    AsyncNewResultSender* task = new AsyncNewResultSender(childInstance, rv);
-    childInstance->PostChildAsyncCall(task);
+    // We don't want to run NPP_New async from within nested calls
+    childInstance->AsyncCall(&RunAsyncNPP_New, childInstance);
     return true;
 }
 
 bool
 PluginModuleChild::DeallocPPluginInstanceChild(PPluginInstanceChild* aActor)
 {
     PLUGIN_LOG_DEBUG_METHOD;
     AssertPluginThread();