Bug 1050174: Use |SocketIOSendTask| for Bluetooth sockets (under bluetooth2/), r=btian
authorThomas Zimmermann <tdz@users.sourceforge.net>
Thu, 21 Aug 2014 09:30:37 +0200
changeset 200791 499650fa344f4bd4c14e25868ac4390c4982f116
parent 200790 85aebdd03a8bba8a20fe6a8e21b7283ed7dd1bd1
child 200792 b7d712b9f963f29eed11e85b8cd55fe079dfc6dc
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewersbtian
bugs1050174
milestone34.0a1
Bug 1050174: Use |SocketIOSendTask| for Bluetooth sockets (under bluetooth2/), r=btian
dom/bluetooth2/bluedroid/BluetoothSocket.cpp
--- a/dom/bluetooth2/bluedroid/BluetoothSocket.cpp
+++ b/dom/bluetooth2/bluedroid/BluetoothSocket.cpp
@@ -202,39 +202,16 @@ public:
 
     nsRefPtr<nsRunnable> r =
       new SocketIODeleteInstanceRunnable<DroidSocketImpl>(impl);
     nsresult rv = NS_DispatchToMainThread(r);
     NS_ENSURE_SUCCESS_VOID(rv);
   }
 };
 
-class SocketSendTask MOZ_FINAL : public SocketIOTask<DroidSocketImpl>
-{
-public:
-  SocketSendTask(BluetoothSocket* aConsumer, DroidSocketImpl* aImpl,
-                 UnixSocketRawData* aData)
-    : SocketIOTask<DroidSocketImpl>(aImpl)
-    , mData(aData)
-  {
-    MOZ_ASSERT(mData);
-  }
-
-  void Run() MOZ_OVERRIDE
-  {
-    MOZ_ASSERT(!NS_IsMainThread());
-    MOZ_ASSERT(!GetIO()->IsShutdownOnIOThread());
-
-    GetIO()->Send(mData);
-  }
-
-private:
-  UnixSocketRawData* mData;
-};
-
 class SocketConnectTask MOZ_FINAL : public SocketIOTask<DroidSocketImpl>
 {
 public:
   SocketConnectTask(DroidSocketImpl* aDroidSocketImpl, int aFd)
   : SocketIOTask<DroidSocketImpl>(aDroidSocketImpl)
   , mFd(aFd)
   { }
 
@@ -654,18 +631,20 @@ BluetoothSocket::Listen(int aChannel)
 
 bool
 BluetoothSocket::SendDroidSocketData(UnixSocketRawData* aData)
 {
   MOZ_ASSERT(NS_IsMainThread());
   NS_ENSURE_TRUE(mImpl, false);
 
   MOZ_ASSERT(!mImpl->IsShutdownOnMainThread());
-  XRE_GetIOMessageLoop()->PostTask(FROM_HERE,
-                                   new SocketSendTask(this, mImpl, aData));
+
+  XRE_GetIOMessageLoop()->PostTask(
+    FROM_HERE, new SocketIOSendTask<DroidSocketImpl>(mImpl, aData));
+
   return true;
 }
 
 void
 BluetoothSocket::ReceiveSocketData(nsAutoPtr<UnixSocketRawData>& aMessage)
 {
   MOZ_ASSERT(NS_IsMainThread());
   MOZ_ASSERT(mObserver);