Bug 1050174: Use |SocketIOReceiveRunnable| for Bluetooth sockets (under bluetooth2/), r=btian
--- a/dom/bluetooth2/bluedroid/BluetoothSocket.cpp
+++ b/dom/bluetooth2/bluedroid/BluetoothSocket.cpp
@@ -249,48 +249,16 @@ class ShutdownSocketTask : public Task {
}
DroidSocketImpl* mImpl;
public:
ShutdownSocketTask(DroidSocketImpl* aImpl) : mImpl(aImpl) { }
};
-class SocketReceiveTask : public SocketIORunnable<DroidSocketImpl>
-{
-public:
- SocketReceiveTask(DroidSocketImpl* aImpl, UnixSocketRawData* aData)
- : SocketIORunnable<DroidSocketImpl>(aImpl)
- , mRawData(aData)
- {
- MOZ_ASSERT(aData);
- }
-
- NS_IMETHOD Run()
- {
- MOZ_ASSERT(NS_IsMainThread());
-
- DroidSocketImpl* impl = GetIO();
-
- if (impl->IsShutdownOnMainThread()) {
- NS_WARNING("mConsumer is null, aborting receive!");
- // Since we've already explicitly closed and the close happened before
- // this, this isn't really an error. Since we've warned, return OK.
- return NS_OK;
- }
-
- MOZ_ASSERT(impl->mConsumer);
- impl->mConsumer->ReceiveSocketData(mRawData);
- return NS_OK;
- }
-
-private:
- nsAutoPtr<UnixSocketRawData> mRawData;
-};
-
class SocketSendTask : public Task
{
public:
SocketSendTask(BluetoothSocket* aConsumer, DroidSocketImpl* aImpl,
UnixSocketRawData* aData)
: mConsumer(aConsumer),
mImpl(aImpl),
mData(aData)
@@ -498,19 +466,19 @@ DroidSocketImpl::OnSocketCanReceiveWitho
// cause us to end up back here.
RemoveWatchers(READ_WATCHER | WRITE_WATCHER);
nsRefPtr<RequestClosingSocketTask> t = new RequestClosingSocketTask(this);
NS_DispatchToMainThread(t);
return;
}
incoming->mSize = ret;
- nsRefPtr<SocketReceiveTask> t =
- new SocketReceiveTask(this, incoming.forget());
- NS_DispatchToMainThread(t);
+ nsRefPtr<nsRunnable> r =
+ new SocketIOReceiveRunnable<DroidSocketImpl>(this, incoming.forget());
+ NS_DispatchToMainThread(r);
// If ret is less than MAX_READ_SIZE, there's no
// more data in the socket for us to read now.
if (ret < ssize_t(MAX_READ_SIZE)) {
return;
}
}