Bug 1156861: Add a TaskFactory to PluginProcessParent to handle launch completion tasks; r=jimm a=rkothari
authorAaron Klotz <aklotz@mozilla.com>
Mon, 25 May 2015 11:53:39 -0600
changeset 266118 f3259a2d48bc
parent 266117 9abcdd8e7712
child 266119 c9cc5b1e1b0f
push id4760
push useraklotz@mozilla.com
push date2015-05-27 22:38 +0000
treeherdermozilla-beta@f3259a2d48bc [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjimm, rkothari
bugs1156861
milestone39.0
Bug 1156861: Add a TaskFactory to PluginProcessParent to handle launch completion tasks; r=jimm a=rkothari
dom/plugins/ipc/PluginProcessParent.cpp
dom/plugins/ipc/PluginProcessParent.h
--- a/dom/plugins/ipc/PluginProcessParent.cpp
+++ b/dom/plugins/ipc/PluginProcessParent.cpp
@@ -32,16 +32,17 @@ struct RunnableMethodTraits<PluginProces
 {
     static void RetainCallee(PluginProcessParent* obj) { }
     static void ReleaseCallee(PluginProcessParent* obj) { }
 };
 
 PluginProcessParent::PluginProcessParent(const std::string& aPluginFilePath) :
     GeckoChildProcessHost(GeckoProcessType_Plugin),
     mPluginFilePath(aPluginFilePath),
+    mTaskFactory(this),
     mMainMsgLoop(MessageLoop::current()),
     mRunCompleteTaskImmediately(false)
 {
 }
 
 PluginProcessParent::~PluginProcessParent()
 {
 }
@@ -210,27 +211,27 @@ PluginProcessParent::WaitUntilConnected(
 }
 
 void
 PluginProcessParent::OnChannelConnected(int32_t peer_pid)
 {
     GeckoChildProcessHost::OnChannelConnected(peer_pid);
     if (mLaunchCompleteTask && !mRunCompleteTaskImmediately) {
         mLaunchCompleteTask->SetLaunchSucceeded();
-        mMainMsgLoop->PostTask(FROM_HERE, NewRunnableMethod(this,
+        mMainMsgLoop->PostTask(FROM_HERE, mTaskFactory.NewRunnableMethod(
                                    &PluginProcessParent::RunLaunchCompleteTask));
     }
 }
 
 void
 PluginProcessParent::OnChannelError()
 {
     GeckoChildProcessHost::OnChannelError();
     if (mLaunchCompleteTask && !mRunCompleteTaskImmediately) {
-        mMainMsgLoop->PostTask(FROM_HERE, NewRunnableMethod(this,
+        mMainMsgLoop->PostTask(FROM_HERE, mTaskFactory.NewRunnableMethod(
                                    &PluginProcessParent::RunLaunchCompleteTask));
     }
 }
 
 bool
 PluginProcessParent::IsConnected()
 {
     mozilla::MonitorAutoLock lock(mMonitor);
--- a/dom/plugins/ipc/PluginProcessParent.h
+++ b/dom/plugins/ipc/PluginProcessParent.h
@@ -12,16 +12,17 @@
 
 #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/plugins/TaskFactory.h"
 #include "mozilla/UniquePtr.h"
 #include "nsCOMPtr.h"
 #include "nsIRunnable.h"
 
 namespace mozilla {
 namespace plugins {
 
 class LaunchCompleteTask : public Task
@@ -75,16 +76,17 @@ public:
     virtual void OnChannelError() override;
 
     bool IsConnected();
 
 private:
     void RunLaunchCompleteTask();
 
     std::string mPluginFilePath;
+    TaskFactory<PluginProcessParent> mTaskFactory;
     UniquePtr<LaunchCompleteTask> mLaunchCompleteTask;
     MessageLoop* mMainMsgLoop;
     bool mRunCompleteTaskImmediately;
 
     DISALLOW_EVIL_CONSTRUCTORS(PluginProcessParent);
 };