Bug 992206: Use |SocketIODeleteInstanceRunnable| for Bluetooth sockets, r=shuang
authorThomas Zimmermann <tdz@users.sourceforge.net>
Thu, 07 Aug 2014 11:37:49 +0200
changeset 212636 9cebbce261ce39aaafa770c4f1595242885802b3
parent 212635 73120fc88efdfb98d117ed6620681cbbada8016a
child 212637 393d9af0a49f51613c1d2cb2b29c2576259da043
push id6741
push userraliiev@mozilla.com
push dateTue, 02 Sep 2014 16:57:58 +0000
treeherdermozilla-aurora@aed50d3edf33 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersshuang
bugs992206
milestone34.0a1
Bug 992206: Use |SocketIODeleteInstanceRunnable| for Bluetooth sockets, r=shuang
dom/bluetooth/bluedroid/BluetoothSocket.cpp
--- a/dom/bluetooth/bluedroid/BluetoothSocket.cpp
+++ b/dom/bluetooth/bluedroid/BluetoothSocket.cpp
@@ -179,50 +179,31 @@ private:
   /**
    * If true, do not requeue whatever task we're running
    */
   bool mShuttingDownOnIOThread;
 
   ConnectionStatus mConnectionStatus;
 };
 
-template<class T>
-class DeleteInstanceRunnable : public nsRunnable
-{
-public:
-  DeleteInstanceRunnable(T* aInstance)
-  : mInstance(aInstance)
-  { }
-
-  NS_IMETHOD Run()
-  {
-    delete mInstance;
-
-    return NS_OK;
-  }
-
-private:
-  T* mInstance;
-};
-
 class ShutdownSocketTask : public Task {
   virtual void Run()
   {
     MOZ_ASSERT(!NS_IsMainThread());
 
     // At this point, there should be no new events on the IO thread after this
     // one with the possible exception of a SocketAcceptTask that
     // ShutdownOnIOThread will cancel for us. We are now fully shut down, so we
     // can send a message to the main thread that will delete mImpl safely knowing
     // that no more tasks reference it.
     mImpl->ShutdownOnIOThread();
 
-    nsRefPtr<nsIRunnable> t(new DeleteInstanceRunnable<
-                                  mozilla::dom::bluetooth::DroidSocketImpl>(mImpl));
-    nsresult rv = NS_DispatchToMainThread(t);
+    nsRefPtr<nsRunnable> r =
+      new SocketIODeleteInstanceRunnable<DroidSocketImpl>(mImpl);
+    nsresult rv = NS_DispatchToMainThread(r);
     NS_ENSURE_SUCCESS_VOID(rv);
   }
 
   DroidSocketImpl* mImpl;
 
 public:
   ShutdownSocketTask(DroidSocketImpl* aImpl) : mImpl(aImpl) { }
 };