зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1268432: Replace |Task| with |Runnable| in B2G code r=fabrice
This patch converts the remaining B2G code from |Task| to |Runnable| and fixes related API calls. This is a follow-up to bug 1266595.
This commit is contained in:
Родитель
85146b9ee1
Коммит
42c137c01d
|
@ -88,16 +88,17 @@ BluetoothDaemonSocketModule::ConnectCmd(const BluetoothAddress& aBdAddr,
|
|||
/* |DeleteTask| deletes a class instance on the I/O thread
|
||||
*/
|
||||
template <typename T>
|
||||
class DeleteTask final : public Task
|
||||
class DeleteTask final : public Runnable
|
||||
{
|
||||
public:
|
||||
DeleteTask(T* aPtr)
|
||||
: mPtr(aPtr)
|
||||
{ }
|
||||
|
||||
void Run() override
|
||||
NS_IMETHOD Run() override
|
||||
{
|
||||
mPtr = nullptr;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -134,7 +135,7 @@ public:
|
|||
}
|
||||
|
||||
MessageLoopForIO::current()->PostTask(
|
||||
FROM_HERE, new DeleteTask<AcceptWatcher>(this));
|
||||
MakeAndAddRef<DeleteTask<AcceptWatcher>>(this));
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -145,8 +146,8 @@ BluetoothDaemonSocketModule::AcceptCmd(int aFd,
|
|||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
/* receive Bluedroid's socket-setup messages and client fd */
|
||||
Task* t = new SocketMessageWatcherTask(new AcceptWatcher(aFd, aRes));
|
||||
XRE_GetIOMessageLoop()->PostTask(FROM_HERE, t);
|
||||
XRE_GetIOMessageLoop()->PostTask(
|
||||
MakeAndAddRef<SocketMessageWatcherTask>(new AcceptWatcher(aFd, aRes)));
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -157,8 +158,8 @@ BluetoothDaemonSocketModule::CloseCmd(BluetoothSocketResultHandler* aRes)
|
|||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
/* stop the watcher corresponding to |aRes| */
|
||||
Task* t = new DeleteSocketMessageWatcherTask(aRes);
|
||||
XRE_GetIOMessageLoop()->PostTask(FROM_HERE, t);
|
||||
XRE_GetIOMessageLoop()->PostTask(
|
||||
MakeAndAddRef<DeleteSocketMessageWatcherTask>(aRes));
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -273,7 +274,7 @@ public:
|
|||
}
|
||||
|
||||
MessageLoopForIO::current()->PostTask(
|
||||
FROM_HERE, new DeleteTask<ConnectWatcher>(this));
|
||||
MakeAndAddRef<DeleteTask<ConnectWatcher>>(this));
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -298,8 +299,8 @@ BluetoothDaemonSocketModule::ConnectRsp(const DaemonSocketPDUHeader& aHeader,
|
|||
}
|
||||
|
||||
/* receive Bluedroid's socket-setup messages */
|
||||
Task* t = new SocketMessageWatcherTask(new ConnectWatcher(fd, aRes));
|
||||
XRE_GetIOMessageLoop()->PostTask(FROM_HERE, t);
|
||||
XRE_GetIOMessageLoop()->PostTask(
|
||||
MakeAndAddRef<SocketMessageWatcherTask>(new ConnectWatcher(fd, aRes)));
|
||||
}
|
||||
|
||||
//
|
||||
|
|
|
@ -172,7 +172,7 @@ private:
|
|||
uint32_t mAvailablePacketSize;
|
||||
};
|
||||
|
||||
class BluetoothOppManager::CloseSocketTask final : public Task
|
||||
class BluetoothOppManager::CloseSocketTask final : public Runnable
|
||||
{
|
||||
public:
|
||||
CloseSocketTask(BluetoothSocket* aSocket) : mSocket(aSocket)
|
||||
|
@ -180,10 +180,11 @@ public:
|
|||
MOZ_ASSERT(aSocket);
|
||||
}
|
||||
|
||||
void Run() override
|
||||
NS_IMETHOD Run() override
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
mSocket->Close();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -1158,8 +1159,8 @@ BluetoothOppManager::ClientDataHandler(UnixSocketBuffer* aMessage)
|
|||
// Disconnect request, so we make a delay here. If the socket hasn't been
|
||||
// disconnected, we will close it.
|
||||
if (mSocket) {
|
||||
MessageLoop::current()->
|
||||
PostDelayedTask(FROM_HERE, new CloseSocketTask(mSocket), 1000);
|
||||
MessageLoop::current()->PostDelayedTask(
|
||||
MakeAndAddRef<CloseSocketTask>(mSocket), 1000);
|
||||
}
|
||||
} else if (mLastCommand == ObexRequestCode::Connect) {
|
||||
MOZ_ASSERT(!mFileName.IsEmpty());
|
||||
|
|
|
@ -200,12 +200,14 @@ public:
|
|||
, mFd(aFd)
|
||||
{ }
|
||||
|
||||
void Run() override
|
||||
NS_IMETHOD Run() override
|
||||
{
|
||||
MOZ_ASSERT(!GetIO()->IsConsumerThread());
|
||||
MOZ_ASSERT(!IsCanceled());
|
||||
|
||||
GetIO()->Connect(mFd);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -220,13 +222,14 @@ public:
|
|||
, mFd(aFd)
|
||||
{ }
|
||||
|
||||
void Run() override
|
||||
NS_IMETHOD Run() override
|
||||
{
|
||||
MOZ_ASSERT(!GetIO()->IsConsumerThread());
|
||||
|
||||
if (!IsCanceled()) {
|
||||
GetIO()->Listen(mFd);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -240,11 +243,13 @@ class SocketConnectClientFdTask final
|
|||
: SocketIOTask<DroidSocketImpl>(aImpl)
|
||||
{ }
|
||||
|
||||
void Run() override
|
||||
NS_IMETHOD Run() override
|
||||
{
|
||||
MOZ_ASSERT(!GetIO()->IsConsumerThread());
|
||||
|
||||
GetIO()->ConnectClientFd();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -303,7 +308,7 @@ DroidSocketImpl::Accept(int aFd)
|
|||
mConnectionStatus = SOCKET_IS_CONNECTED;
|
||||
|
||||
GetConsumerThread()->PostTask(
|
||||
FROM_HERE, new SocketEventTask(this, SocketEventTask::CONNECT_SUCCESS));
|
||||
MakeAndAddRef<SocketEventTask>(this, SocketEventTask::CONNECT_SUCCESS));
|
||||
|
||||
AddWatchers(READ_WATCHER, true);
|
||||
if (HasPendingData()) {
|
||||
|
@ -347,12 +352,14 @@ public:
|
|||
, mFd(aFd)
|
||||
{ }
|
||||
|
||||
void Run() override
|
||||
NS_IMETHOD Run() override
|
||||
{
|
||||
MOZ_ASSERT(!GetIO()->IsConsumerThread());
|
||||
MOZ_ASSERT(!IsCanceled());
|
||||
|
||||
GetIO()->Accept(mFd);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -386,8 +393,8 @@ public:
|
|||
}
|
||||
|
||||
mImpl->mConsumer->SetAddress(aBdAddress);
|
||||
mImpl->GetIOLoop()->PostTask(FROM_HERE,
|
||||
new AcceptTask(mImpl, fd.forget()));
|
||||
mImpl->GetIOLoop()->PostTask(
|
||||
mozilla::MakeAndAddRef<AcceptTask>(mImpl, fd.forget()));
|
||||
}
|
||||
|
||||
void OnError(BluetoothStatus aStatus) override
|
||||
|
@ -416,11 +423,13 @@ public:
|
|||
, mListenFd(aListenFd)
|
||||
{ }
|
||||
|
||||
void Run() override
|
||||
NS_IMETHOD Run() override
|
||||
{
|
||||
MOZ_ASSERT(GetIO()->IsConsumerThread());
|
||||
|
||||
GetIO()->mConsumer->Accept(mListenFd, new AcceptResultHandler(GetIO()));
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -438,7 +447,7 @@ DroidSocketImpl::OnSocketCanAcceptWithoutBlocking(int aFd)
|
|||
*/
|
||||
|
||||
RemoveWatchers(READ_WATCHER);
|
||||
GetConsumerThread()->PostTask(FROM_HERE, new InvokeAcceptTask(this, aFd));
|
||||
GetConsumerThread()->PostTask(MakeAndAddRef<InvokeAcceptTask>(this, aFd));
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -483,7 +492,7 @@ DroidSocketImpl::OnSocketCanConnectWithoutBlocking(int aFd)
|
|||
mConnectionStatus = SOCKET_IS_CONNECTED;
|
||||
|
||||
GetConsumerThread()->PostTask(
|
||||
FROM_HERE, new SocketEventTask(this, SocketEventTask::CONNECT_SUCCESS));
|
||||
MakeAndAddRef<SocketEventTask>(this, SocketEventTask::CONNECT_SUCCESS));
|
||||
|
||||
AddWatchers(READ_WATCHER, true);
|
||||
if (HasPendingData()) {
|
||||
|
@ -519,7 +528,7 @@ public:
|
|||
, mBuffer(aBuffer)
|
||||
{ }
|
||||
|
||||
void Run() override
|
||||
NS_IMETHOD Run() override
|
||||
{
|
||||
DroidSocketImpl* io = SocketTask<DroidSocketImpl>::GetIO();
|
||||
|
||||
|
@ -528,13 +537,15 @@ public:
|
|||
if (NS_WARN_IF(io->IsShutdownOnConsumerThread())) {
|
||||
// Since we've already explicitly closed and the close
|
||||
// happened before this, this isn't really an error.
|
||||
return;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
BluetoothSocket* bluetoothSocket = io->GetBluetoothSocket();
|
||||
MOZ_ASSERT(bluetoothSocket);
|
||||
|
||||
bluetoothSocket->ReceiveSocketData(mBuffer);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -544,8 +555,8 @@ private:
|
|||
void
|
||||
DroidSocketImpl::ConsumeBuffer()
|
||||
{
|
||||
GetConsumerThread()->PostTask(FROM_HERE,
|
||||
new ReceiveTask(this, mBuffer.release()));
|
||||
GetConsumerThread()->PostTask(
|
||||
MakeAndAddRef<ReceiveTask>(this, mBuffer.release()));
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -605,8 +616,8 @@ public:
|
|||
}
|
||||
|
||||
mImpl->mConsumer->SetAddress(aBdAddress);
|
||||
mImpl->GetIOLoop()->PostTask(FROM_HERE,
|
||||
new SocketConnectTask(mImpl, aFd));
|
||||
mImpl->GetIOLoop()->PostTask(
|
||||
mozilla::MakeAndAddRef<SocketConnectTask>(mImpl, aFd));
|
||||
}
|
||||
|
||||
void OnError(BluetoothStatus aStatus) override
|
||||
|
@ -682,7 +693,8 @@ public:
|
|||
{
|
||||
MOZ_ASSERT(mImpl->IsConsumerThread());
|
||||
|
||||
mImpl->GetIOLoop()->PostTask(FROM_HERE, new SocketListenTask(mImpl, aFd));
|
||||
mImpl->GetIOLoop()->PostTask(
|
||||
mozilla::MakeAndAddRef<SocketListenTask>(mImpl, aFd));
|
||||
}
|
||||
|
||||
void OnError(BluetoothStatus aStatus) override
|
||||
|
@ -776,8 +788,8 @@ BluetoothSocket::SendSocketData(UnixSocketIOBuffer* aBuffer)
|
|||
MOZ_ASSERT(!mImpl->IsShutdownOnConsumerThread());
|
||||
|
||||
mImpl->GetIOLoop()->PostTask(
|
||||
FROM_HERE,
|
||||
new SocketIOSendTask<DroidSocketImpl, UnixSocketIOBuffer>(mImpl, aBuffer));
|
||||
MakeAndAddRef<SocketIOSendTask<DroidSocketImpl, UnixSocketIOBuffer>>(
|
||||
mImpl, aBuffer));
|
||||
}
|
||||
|
||||
// |SocketBase|
|
||||
|
@ -860,7 +872,7 @@ BluetoothSocket::Cleanup()
|
|||
// sever the relationship here so any future calls to listen
|
||||
// or connect will create a new implementation.
|
||||
mImpl->ShutdownOnConsumerThread();
|
||||
mImpl->GetIOLoop()->PostTask(FROM_HERE, new SocketIOShutdownTask(mImpl));
|
||||
mImpl->GetIOLoop()->PostTask(MakeAndAddRef<SocketIOShutdownTask>(mImpl));
|
||||
mImpl = nullptr;
|
||||
|
||||
mSocketInterface = nullptr;
|
||||
|
|
|
@ -277,10 +277,11 @@ SocketMessageWatcherTask::SocketMessageWatcherTask(
|
|||
MOZ_ASSERT(mWatcher);
|
||||
}
|
||||
|
||||
void
|
||||
NS_IMETHODIMP
|
||||
SocketMessageWatcherTask::Run()
|
||||
{
|
||||
mWatcher->Watch();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -294,19 +295,20 @@ DeleteSocketMessageWatcherTask::DeleteSocketMessageWatcherTask(
|
|||
MOZ_ASSERT(mRes);
|
||||
}
|
||||
|
||||
void
|
||||
NS_IMETHODIMP
|
||||
DeleteSocketMessageWatcherTask::Run()
|
||||
{
|
||||
// look up hash table for the watcher corresponding to |mRes|
|
||||
SocketMessageWatcherWrapper* wrapper = sWatcherHashtable.Get(mRes);
|
||||
if (!wrapper) {
|
||||
return;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// stop the watcher if it exists
|
||||
SocketMessageWatcher* watcher = wrapper->GetSocketMessageWatcher();
|
||||
watcher->StopWatching();
|
||||
watcher->Proceed(STATUS_DONE);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
END_BLUETOOTH_NAMESPACE
|
||||
|
|
|
@ -84,12 +84,12 @@ private:
|
|||
/* |SocketMessageWatcherTask| starts a SocketMessageWatcher
|
||||
* on the I/O task
|
||||
*/
|
||||
class SocketMessageWatcherTask final : public Task
|
||||
class SocketMessageWatcherTask final : public Runnable
|
||||
{
|
||||
public:
|
||||
SocketMessageWatcherTask(SocketMessageWatcher* aWatcher);
|
||||
|
||||
void Run() override;
|
||||
NS_IMETHOD Run() override;
|
||||
|
||||
private:
|
||||
SocketMessageWatcher* mWatcher;
|
||||
|
@ -98,12 +98,12 @@ private:
|
|||
/* |DeleteSocketMessageWatcherTask| deletes a watching SocketMessageWatcher
|
||||
* on the I/O task
|
||||
*/
|
||||
class DeleteSocketMessageWatcherTask final : public Task
|
||||
class DeleteSocketMessageWatcherTask final : public Runnable
|
||||
{
|
||||
public:
|
||||
DeleteSocketMessageWatcherTask(BluetoothSocketResultHandler* aRes);
|
||||
|
||||
void Run() override;
|
||||
NS_IMETHOD Run() override;
|
||||
|
||||
private:
|
||||
BluetoothSocketResultHandler* mRes;
|
||||
|
|
|
@ -108,13 +108,14 @@ protected:
|
|||
~GetVolumeTask() { }
|
||||
};
|
||||
|
||||
class BluetoothHfpManager::CloseScoTask : public Task
|
||||
class BluetoothHfpManager::CloseScoTask : public Runnable
|
||||
{
|
||||
private:
|
||||
void Run() override
|
||||
NS_IMETHOD Run() override
|
||||
{
|
||||
MOZ_ASSERT(sBluetoothHfpManager);
|
||||
sBluetoothHfpManager->DisconnectSco();
|
||||
return NS_OK;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -126,16 +127,16 @@ public:
|
|||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
MessageLoop::current()->PostDelayedTask(
|
||||
FROM_HERE, new CloseScoTask(), sBusyToneInterval);
|
||||
MakeAndAddRef<CloseScoTask>(), sBusyToneInterval);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
};
|
||||
|
||||
class BluetoothHfpManager::RespondToBLDNTask : public Task
|
||||
class BluetoothHfpManager::RespondToBLDNTask : public Runnable
|
||||
{
|
||||
private:
|
||||
void Run() override
|
||||
NS_IMETHOD Run() override
|
||||
{
|
||||
MOZ_ASSERT(sBluetoothHfpManager);
|
||||
|
||||
|
@ -143,6 +144,7 @@ private:
|
|||
sBluetoothHfpManager->mDialingRequestProcessed = true;
|
||||
sBluetoothHfpManager->SendResponse(HFP_AT_RESPONSE_ERROR);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -1597,8 +1599,7 @@ void BluetoothHfpManager::DialCallNotification(const nsAString& aNumber,
|
|||
mDialingRequestProcessed = false;
|
||||
NotifyDialer(NS_LITERAL_STRING("BLDN"));
|
||||
|
||||
MessageLoop::current()->PostDelayedTask(FROM_HERE,
|
||||
new RespondToBLDNTask(),
|
||||
MessageLoop::current()->PostDelayedTask(MakeAndAddRef<RespondToBLDNTask>(),
|
||||
sWaitingForDialingInterval);
|
||||
} else if (message[0] == '>') {
|
||||
mDialingRequestProcessed = false;
|
||||
|
@ -1607,8 +1608,7 @@ void BluetoothHfpManager::DialCallNotification(const nsAString& aNumber,
|
|||
newMsg += StringHead(message, message.Length() - 1);
|
||||
NotifyDialer(NS_ConvertUTF8toUTF16(newMsg));
|
||||
|
||||
MessageLoop::current()->PostDelayedTask(FROM_HERE,
|
||||
new RespondToBLDNTask(),
|
||||
MessageLoop::current()->PostDelayedTask(MakeAndAddRef<RespondToBLDNTask>(),
|
||||
sWaitingForDialingInterval);
|
||||
} else {
|
||||
SendResponse(HFP_AT_RESPONSE_OK);
|
||||
|
@ -1766,8 +1766,7 @@ BluetoothHfpManager::KeyPressedNotification(const BluetoothAddress& aBdAddress)
|
|||
|
||||
NotifyDialer(NS_LITERAL_STRING("BLDN"));
|
||||
|
||||
MessageLoop::current()->PostDelayedTask(FROM_HERE,
|
||||
new RespondToBLDNTask(),
|
||||
MessageLoop::current()->PostDelayedTask(MakeAndAddRef<RespondToBLDNTask>(),
|
||||
sWaitingForDialingInterval);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -384,9 +384,9 @@ typedef void (*UnpackFunc)(DBusMessage*, DBusError*,
|
|||
typedef bool (*FilterFunc)(const BluetoothValue&);
|
||||
|
||||
static void
|
||||
DispatchToDBusThread(Task* task)
|
||||
DispatchToDBusThread(already_AddRefed<Runnable> task)
|
||||
{
|
||||
XRE_GetIOMessageLoop()->PostTask(FROM_HERE, task);
|
||||
XRE_GetIOMessageLoop()->PostTask(Move(task));
|
||||
}
|
||||
|
||||
static nsresult
|
||||
|
@ -628,12 +628,13 @@ private:
|
|||
BluetoothSignal mSignal;
|
||||
};
|
||||
|
||||
class TryFiringAdapterAddedTask : public Task
|
||||
class TryFiringAdapterAddedTask : public Runnable
|
||||
{
|
||||
public:
|
||||
void Run() override
|
||||
NS_IMETHOD Run() override
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
return NS_OK;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -650,11 +651,11 @@ public:
|
|||
|
||||
if (mDelay) {
|
||||
MessageLoop::current()->
|
||||
PostDelayedTask(FROM_HERE, new TryFiringAdapterAddedTask(),
|
||||
PostDelayedTask(MakeAndAddRef<TryFiringAdapterAddedTask>(),
|
||||
sWaitingForAdapterNameInterval);
|
||||
} else {
|
||||
MessageLoop::current()->
|
||||
PostTask(FROM_HERE, new TryFiringAdapterAddedTask());
|
||||
PostTask(MakeAndAddRef<TryFiringAdapterAddedTask>());
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
|
@ -1256,7 +1257,7 @@ AppendDeviceName(BluetoothSignal& aSignal)
|
|||
Unused << handler.forget(); // picked up by callback handler
|
||||
}
|
||||
|
||||
class SetPairingConfirmationTask : public Task
|
||||
class SetPairingConfirmationTask : public Runnable
|
||||
{
|
||||
public:
|
||||
SetPairingConfirmationTask(const BluetoothAddress& aDeviceAddress,
|
||||
|
@ -1269,7 +1270,7 @@ public:
|
|||
MOZ_ASSERT(!mDeviceAddress.IsCleared());
|
||||
}
|
||||
|
||||
void Run() override
|
||||
NS_IMETHOD Run() override
|
||||
{
|
||||
MOZ_ASSERT(!NS_IsMainThread()); // I/O thread
|
||||
MOZ_ASSERT(sDBusConnection);
|
||||
|
@ -1283,7 +1284,7 @@ public:
|
|||
errorStr.AssignLiteral("Couldn't get original request message.");
|
||||
DispatchBluetoothReply(mRunnable, v, errorStr);
|
||||
|
||||
return;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
DBusMessage *reply;
|
||||
|
@ -1302,7 +1303,7 @@ public:
|
|||
if (mRunnable) {
|
||||
DispatchBluetoothReply(mRunnable, v, errorStr);
|
||||
}
|
||||
return;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
bool result = sDBusConnection->Send(reply);
|
||||
|
@ -1316,6 +1317,7 @@ public:
|
|||
if (mRunnable) {
|
||||
DispatchBluetoothReply(mRunnable, v, errorStr);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -1509,8 +1511,8 @@ AgentEventFilter(DBusConnection *conn, DBusMessage *msg, void *data)
|
|||
GetAddressFromObjectPath(NS_ConvertUTF8toUTF16(objectPath), address);
|
||||
|
||||
sPairingReqTable->Put(address, msg);
|
||||
Task* task = new SetPairingConfirmationTask(address, true, nullptr);
|
||||
DispatchToDBusThread(task);
|
||||
DispatchToDBusThread(
|
||||
MakeAndAddRef<SetPairingConfirmationTask>(address, true, nullptr));
|
||||
// Increase dbus message reference counts, it will be decreased in
|
||||
// SetPairingConfirmationTask
|
||||
dbus_message_ref(msg);
|
||||
|
@ -1689,13 +1691,13 @@ private:
|
|||
}
|
||||
};
|
||||
|
||||
class AddReservedServiceRecordsTask : public Task
|
||||
class AddReservedServiceRecordsTask : public Runnable
|
||||
{
|
||||
public:
|
||||
AddReservedServiceRecordsTask()
|
||||
{ }
|
||||
|
||||
void Run()
|
||||
NS_IMETHOD Run() override
|
||||
{
|
||||
static const dbus_uint32_t sServices[] = {
|
||||
BluetoothServiceClass::HANDSFREE_AG,
|
||||
|
@ -1720,9 +1722,11 @@ public:
|
|||
DBUS_TYPE_ARRAY, DBUS_TYPE_UINT32,
|
||||
&services, ArrayLength(sServices), DBUS_TYPE_INVALID);
|
||||
|
||||
NS_ENSURE_TRUE_VOID(success);
|
||||
NS_ENSURE_TRUE(success, NS_OK);
|
||||
|
||||
Unused << handler.forget(); /* picked up by callback handler */
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -1736,8 +1740,7 @@ public:
|
|||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
Task* task = new AddReservedServiceRecordsTask();
|
||||
DispatchToDBusThread(task);
|
||||
DispatchToDBusThread(MakeAndAddRef<AddReservedServiceRecordsTask>());
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -2071,7 +2074,7 @@ BluetoothDBusService::IsReady()
|
|||
return true;
|
||||
}
|
||||
|
||||
class StartDBusConnectionTask : public Task
|
||||
class StartDBusConnectionTask : public Runnable
|
||||
{
|
||||
public:
|
||||
StartDBusConnectionTask(RawDBusConnection* aConnection)
|
||||
|
@ -2080,7 +2083,7 @@ public:
|
|||
MOZ_ASSERT(mConnection);
|
||||
}
|
||||
|
||||
void Run()
|
||||
NS_IMETHOD Run() override
|
||||
{
|
||||
MOZ_ASSERT(!NS_IsMainThread()); // I/O thread
|
||||
|
||||
|
@ -2090,7 +2093,7 @@ public:
|
|||
if (NS_FAILED(NS_DispatchToMainThread(runnable))) {
|
||||
BT_WARNING("Failed to dispatch to main thread!");
|
||||
}
|
||||
return;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Add a filter for all incoming messages_base
|
||||
|
@ -2101,7 +2104,7 @@ public:
|
|||
if (NS_FAILED(NS_DispatchToMainThread(runnable))) {
|
||||
BT_WARNING("Failed to dispatch to main thread!");
|
||||
}
|
||||
return;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
mConnection->Watch();
|
||||
|
@ -2114,9 +2117,9 @@ public:
|
|||
|
||||
RefPtr<Runnable> runnable =
|
||||
new BluetoothService::ToggleBtAck(true);
|
||||
if (NS_FAILED(NS_DispatchToMainThread(runnable))) {
|
||||
if (NS_FAILED(NS_DispatchToMainThread(runnable.forget()))) {
|
||||
BT_WARNING("Failed to dispatch to main thread!");
|
||||
return;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* Normally we'll receive the signal 'AdapterAdded' with the adapter object
|
||||
|
@ -2136,6 +2139,7 @@ public:
|
|||
BT_WARNING("Failed to query default adapter!");
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -2190,8 +2194,7 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
Task* task = new StartDBusConnectionTask(connection);
|
||||
DispatchToDBusThread(task);
|
||||
DispatchToDBusThread(MakeAndAddRef<StartDBusConnectionTask>(connection));
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -2240,13 +2243,13 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
class DeleteDBusConnectionTask final : public Task
|
||||
class DeleteDBusConnectionTask final : public Runnable
|
||||
{
|
||||
public:
|
||||
DeleteDBusConnectionTask()
|
||||
{ }
|
||||
|
||||
void Run()
|
||||
NS_IMETHOD Run() override
|
||||
{
|
||||
MOZ_ASSERT(!NS_IsMainThread()); // I/O thread
|
||||
|
||||
|
@ -2256,7 +2259,7 @@ public:
|
|||
if (NS_FAILED(NS_DispatchToMainThread(runnable))) {
|
||||
BT_WARNING("Failed to dispatch to main thread!");
|
||||
}
|
||||
return;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
for (uint32_t i = 0; i < ArrayLength(sBluetoothDBusSignals); ++i) {
|
||||
|
@ -2299,6 +2302,7 @@ public:
|
|||
if (NS_FAILED(NS_DispatchToMainThread(runnable))) {
|
||||
BT_WARNING("Failed to dispatch to BT thread!");
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -2315,7 +2319,7 @@ public:
|
|||
lock.Wait(PR_SecondsToInterval(TIMEOUT_FORCE_TO_DISABLE_BT));
|
||||
}
|
||||
|
||||
DispatchToDBusThread(new DeleteDBusConnectionTask());
|
||||
DispatchToDBusThread(MakeAndAddRef<DeleteDBusConnectionTask>());
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -2443,7 +2447,7 @@ private:
|
|||
nsString mAdapterPath;
|
||||
};
|
||||
|
||||
class DefaultAdapterTask : public Task
|
||||
class DefaultAdapterTask : public Runnable
|
||||
{
|
||||
public:
|
||||
DefaultAdapterTask(BluetoothReplyRunnable* aRunnable)
|
||||
|
@ -2452,7 +2456,7 @@ public:
|
|||
MOZ_ASSERT(mRunnable);
|
||||
}
|
||||
|
||||
void Run() override
|
||||
NS_IMETHOD Run() override
|
||||
{
|
||||
MOZ_ASSERT(!NS_IsMainThread()); // I/O thread
|
||||
MOZ_ASSERT(sDBusConnection);
|
||||
|
@ -2465,9 +2469,11 @@ public:
|
|||
handler.get(), 1000, BLUEZ_DBUS_BASE_IFC,
|
||||
"/", DBUS_MANAGER_IFACE, "DefaultAdapter",
|
||||
DBUS_TYPE_INVALID);
|
||||
NS_ENSURE_TRUE_VOID(success);
|
||||
NS_ENSURE_TRUE(success, NS_OK);
|
||||
|
||||
Unused << handler.forget(); // picked up by callback handler
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -2489,8 +2495,7 @@ BluetoothDBusService::GetAdaptersInternal(BluetoothReplyRunnable* aRunnable)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
Task* task = new DefaultAdapterTask(aRunnable);
|
||||
DispatchToDBusThread(task);
|
||||
DispatchToDBusThread(MakeAndAddRef<DefaultAdapterTask>(aRunnable));
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -2513,7 +2518,7 @@ OnSendDiscoveryMessageReply(DBusMessage *aReply, void *aData)
|
|||
DispatchBluetoothReply(runnable.get(), BluetoothValue(true), errorStr);
|
||||
}
|
||||
|
||||
class SendDiscoveryMessageTask : public Task
|
||||
class SendDiscoveryMessageTask : public Runnable
|
||||
{
|
||||
public:
|
||||
SendDiscoveryMessageTask(const char* aMessageName,
|
||||
|
@ -2525,7 +2530,7 @@ public:
|
|||
MOZ_ASSERT(mRunnable);
|
||||
}
|
||||
|
||||
void Run() override
|
||||
NS_IMETHOD Run() override
|
||||
{
|
||||
MOZ_ASSERT(!NS_IsMainThread()); // I/O thread
|
||||
MOZ_ASSERT(sDBusConnection);
|
||||
|
@ -2538,9 +2543,11 @@ public:
|
|||
NS_ConvertUTF16toUTF8(sAdapterPath).get(),
|
||||
DBUS_ADAPTER_IFACE, mMessageName.get(),
|
||||
DBUS_TYPE_INVALID);
|
||||
NS_ENSURE_TRUE_VOID(success);
|
||||
NS_ENSURE_TRUE(success, NS_OK);
|
||||
|
||||
Unused << mRunnable.forget(); // picked up by callback handler
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -2562,8 +2569,8 @@ BluetoothDBusService::SendDiscoveryMessage(const char* aMessageName,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
Task* task = new SendDiscoveryMessageTask(aMessageName, aRunnable);
|
||||
DispatchToDBusThread(task);
|
||||
DispatchToDBusThread(
|
||||
MakeAndAddRef<SendDiscoveryMessageTask>(aMessageName, aRunnable));
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -2587,7 +2594,7 @@ BluetoothDBusService::SendInputMessage(const nsAString& aDeviceAddress,
|
|||
return SendAsyncDBusMessage(objectPath, DBUS_INPUT_IFACE, aMessage, callback);
|
||||
}
|
||||
|
||||
class SendAsyncDBusMessageTask : public Task
|
||||
class SendAsyncDBusMessageTask : public Runnable
|
||||
{
|
||||
public:
|
||||
SendAsyncDBusMessageTask(DBusReplyCallback aCallback,
|
||||
|
@ -2606,7 +2613,7 @@ public:
|
|||
MOZ_ASSERT(!mMessage.IsEmpty());
|
||||
}
|
||||
|
||||
void Run() override
|
||||
NS_IMETHOD Run() override
|
||||
{
|
||||
MOZ_ASSERT(!NS_IsMainThread()); // I/O thread
|
||||
MOZ_ASSERT(sDBusConnection);
|
||||
|
@ -2617,7 +2624,9 @@ public:
|
|||
mCallback, NS_INT32_TO_PTR(mServiceClass), -1,
|
||||
BLUEZ_DBUS_BASE_IFC, mObjectPath.get(), mInterface.get(),
|
||||
mMessage.get(), DBUS_TYPE_INVALID);
|
||||
NS_ENSURE_TRUE_VOID(success);
|
||||
NS_ENSURE_TRUE(success, NS_OK);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -2650,12 +2659,12 @@ BluetoothDBusService::SendAsyncDBusMessage(const nsAString& aObjectPath,
|
|||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
Task* task = new SendAsyncDBusMessageTask(aCallback,
|
||||
DispatchToDBusThread(
|
||||
MakeAndAddRef<SendAsyncDBusMessageTask>(aCallback,
|
||||
serviceClass,
|
||||
NS_ConvertUTF16toUTF8(aObjectPath),
|
||||
aInterface,
|
||||
NS_ConvertUTF16toUTF8(aMessage));
|
||||
DispatchToDBusThread(task);
|
||||
NS_ConvertUTF16toUTF8(aMessage)));
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -2824,7 +2833,7 @@ private:
|
|||
BluetoothValue mValues;
|
||||
};
|
||||
|
||||
class ProcessRemainingDeviceAddressesTask : public Task
|
||||
class ProcessRemainingDeviceAddressesTask : public Runnable
|
||||
{
|
||||
public:
|
||||
ProcessRemainingDeviceAddressesTask(
|
||||
|
@ -2837,11 +2846,13 @@ public:
|
|||
MOZ_ASSERT(mRunnable);
|
||||
}
|
||||
|
||||
void Run() override
|
||||
NS_IMETHOD Run() override
|
||||
{
|
||||
MOZ_ASSERT(!NS_IsMainThread()); // I/O thread
|
||||
|
||||
mHandler->ProcessRemainingDeviceAddresses();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -2883,8 +2894,8 @@ BluetoothDBusService::GetConnectedDevicePropertiesInternal(
|
|||
new BluetoothArrayOfDevicePropertiesReplyHandler(deviceAddresses,
|
||||
GetConnectedDevicesFilter,
|
||||
aRunnable);
|
||||
Task* task = new ProcessRemainingDeviceAddressesTask(handler, aRunnable);
|
||||
DispatchToDBusThread(task);
|
||||
DispatchToDBusThread(
|
||||
MakeAndAddRef<ProcessRemainingDeviceAddressesTask>(handler, aRunnable));
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -2906,8 +2917,8 @@ BluetoothDBusService::GetPairedDevicePropertiesInternal(
|
|||
new BluetoothArrayOfDevicePropertiesReplyHandler(aDeviceAddresses,
|
||||
GetPairedDevicesFilter,
|
||||
aRunnable);
|
||||
Task* task = new ProcessRemainingDeviceAddressesTask(handler, aRunnable);
|
||||
DispatchToDBusThread(task);
|
||||
DispatchToDBusThread(
|
||||
MakeAndAddRef<ProcessRemainingDeviceAddressesTask>(handler, aRunnable));
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -2919,7 +2930,7 @@ BluetoothDBusService::FetchUuidsInternal(const BluetoothAddress& aDeviceAddress,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
class SetPropertyTask : public Task
|
||||
class SetPropertyTask : public Runnable
|
||||
{
|
||||
public:
|
||||
SetPropertyTask(BluetoothObjectType aType,
|
||||
|
@ -2994,9 +3005,11 @@ public:
|
|||
, mValue(aValue)
|
||||
{ }
|
||||
|
||||
void Run() override
|
||||
NS_IMETHOD Run() override
|
||||
{
|
||||
Send(DBUS_TYPE_UINT32, &mValue);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -3014,10 +3027,12 @@ public:
|
|||
, mValue(aValue)
|
||||
{ }
|
||||
|
||||
void Run() override
|
||||
NS_IMETHOD Run() override
|
||||
{
|
||||
const char* value = mValue.get();
|
||||
Send(DBUS_TYPE_STRING, &value);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -3036,9 +3051,11 @@ public:
|
|||
{
|
||||
}
|
||||
|
||||
void Run() override
|
||||
NS_IMETHOD Run() override
|
||||
{
|
||||
Send(DBUS_TYPE_BOOLEAN, &mValue);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -3058,30 +3075,30 @@ BluetoothDBusService::SetProperty(BluetoothObjectType aType,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
Task* task;
|
||||
RefPtr<Runnable> task;
|
||||
|
||||
if (aValue.value().type() == BluetoothValue::Tuint32_t) {
|
||||
task = new SetUInt32PropertyTask(aType,
|
||||
task = MakeAndAddRef<SetUInt32PropertyTask>(aType,
|
||||
NS_ConvertUTF16toUTF8(aValue.name()),
|
||||
aValue.value().get_uint32_t(), aRunnable);
|
||||
} else if (aValue.value().type() == BluetoothValue::TnsString) {
|
||||
task = new SetStringPropertyTask(aType,
|
||||
task = MakeAndAddRef<SetStringPropertyTask>(aType,
|
||||
NS_ConvertUTF16toUTF8(aValue.name()),
|
||||
NS_ConvertUTF16toUTF8(aValue.value().get_nsString()), aRunnable);
|
||||
} else if (aValue.value().type() == BluetoothValue::Tbool) {
|
||||
task = new SetBooleanPropertyTask(aType,
|
||||
task = MakeAndAddRef<SetBooleanPropertyTask>(aType,
|
||||
NS_ConvertUTF16toUTF8(aValue.name()),
|
||||
aValue.value().get_bool(), aRunnable);
|
||||
} else {
|
||||
BT_WARNING("Property type not handled!");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
DispatchToDBusThread(task);
|
||||
DispatchToDBusThread(task.forget());
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
class CreatePairedDeviceInternalTask : public Task
|
||||
class CreatePairedDeviceInternalTask : public Runnable
|
||||
{
|
||||
public:
|
||||
CreatePairedDeviceInternalTask(const BluetoothAddress& aDeviceAddress,
|
||||
|
@ -3095,7 +3112,7 @@ public:
|
|||
MOZ_ASSERT(mRunnable);
|
||||
}
|
||||
|
||||
void Run() override
|
||||
NS_IMETHOD Run() override
|
||||
{
|
||||
MOZ_ASSERT(!NS_IsMainThread()); // I/O thread
|
||||
MOZ_ASSERT(sDBusConnection);
|
||||
|
@ -3121,7 +3138,7 @@ public:
|
|||
DBUS_TYPE_OBJECT_PATH, &deviceAgentPath,
|
||||
DBUS_TYPE_STRING, &capabilities,
|
||||
DBUS_TYPE_INVALID);
|
||||
NS_ENSURE_TRUE_VOID(success);
|
||||
NS_ENSURE_TRUE(success, NS_OK);
|
||||
|
||||
Unused << mRunnable.forget(); // picked up by callback handler
|
||||
|
||||
|
@ -3138,6 +3155,8 @@ public:
|
|||
* Please see Bug 818696 for more information.
|
||||
*/
|
||||
sIsPairing++;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -3152,15 +3171,15 @@ BluetoothDBusService::CreatePairedDeviceInternal(
|
|||
int aTimeout,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
Task* task = new CreatePairedDeviceInternalTask(aDeviceAddress,
|
||||
DispatchToDBusThread(
|
||||
MakeAndAddRef<CreatePairedDeviceInternalTask>(aDeviceAddress,
|
||||
aTimeout,
|
||||
aRunnable);
|
||||
DispatchToDBusThread(task);
|
||||
aRunnable));
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
class RemoveDeviceTask : public Task
|
||||
class RemoveDeviceTask : public Runnable
|
||||
{
|
||||
public:
|
||||
RemoveDeviceTask(const BluetoothAddress& aDeviceAddress,
|
||||
|
@ -3172,7 +3191,7 @@ public:
|
|||
MOZ_ASSERT(mRunnable);
|
||||
}
|
||||
|
||||
void Run() override
|
||||
NS_IMETHOD Run() override
|
||||
{
|
||||
MOZ_ASSERT(!NS_IsMainThread()); // I/O thread
|
||||
MOZ_ASSERT(sDBusConnection);
|
||||
|
@ -3190,9 +3209,11 @@ public:
|
|||
DBUS_ADAPTER_IFACE, "RemoveDevice",
|
||||
DBUS_TYPE_OBJECT_PATH, &cstrDeviceObjectPath,
|
||||
DBUS_TYPE_INVALID);
|
||||
NS_ENSURE_TRUE_VOID(success);
|
||||
NS_ENSURE_TRUE(success, NS_OK);
|
||||
|
||||
Unused << mRunnable.forget(); // picked up by callback handler
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
protected:
|
||||
|
@ -3229,13 +3250,13 @@ BluetoothDBusService::RemoveDeviceInternal(
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
Task* task = new RemoveDeviceTask(aDeviceAddress, aRunnable);
|
||||
DispatchToDBusThread(task);
|
||||
DispatchToDBusThread(
|
||||
MakeAndAddRef<RemoveDeviceTask>(aDeviceAddress, aRunnable));
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
class SetPinCodeTask : public Task
|
||||
class SetPinCodeTask : public Runnable
|
||||
{
|
||||
public:
|
||||
SetPinCodeTask(const BluetoothAddress& aDeviceAddress,
|
||||
|
@ -3249,7 +3270,7 @@ public:
|
|||
MOZ_ASSERT(mRunnable);
|
||||
}
|
||||
|
||||
void Run() override
|
||||
NS_IMETHOD Run() override
|
||||
{
|
||||
MOZ_ASSERT(!NS_IsMainThread()); // I/O thread
|
||||
|
||||
|
@ -3260,7 +3281,7 @@ public:
|
|||
BT_WARNING("%s: Couldn't get original request message.", __FUNCTION__);
|
||||
errorStr.AssignLiteral("Couldn't get original request message.");
|
||||
DispatchBluetoothReply(mRunnable, v, errorStr);
|
||||
return;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
DBusMessage *reply = dbus_message_new_method_return(msg);
|
||||
|
@ -3270,7 +3291,7 @@ public:
|
|||
dbus_message_unref(msg);
|
||||
errorStr.AssignLiteral("Memory can't be allocated for the message.");
|
||||
DispatchBluetoothReply(mRunnable, v, errorStr);
|
||||
return;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsAutoString pinCodeStr;
|
||||
|
@ -3280,7 +3301,7 @@ public:
|
|||
dbus_message_unref(reply);
|
||||
errorStr.AssignLiteral("Cannot convert pin code to string.");
|
||||
DispatchBluetoothReply(mRunnable, v, errorStr);
|
||||
return;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
auto utf8PinCodeStr = NS_ConvertUTF16toUTF8(pinCodeStr);
|
||||
|
@ -3302,6 +3323,8 @@ public:
|
|||
|
||||
sPairingReqTable->Remove(mDeviceAddress);
|
||||
DispatchBluetoothReply(mRunnable, v, errorStr);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -3331,11 +3354,11 @@ BluetoothDBusService::SetPinCodeInternal(const BluetoothAddress& aDeviceAddress,
|
|||
const BluetoothPinCode& aPinCode,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
Task* task = new SetPinCodeTask(aDeviceAddress, aPinCode, aRunnable);
|
||||
DispatchToDBusThread(task);
|
||||
DispatchToDBusThread(
|
||||
MakeAndAddRef<SetPinCodeTask>(aDeviceAddress, aPinCode, aRunnable));
|
||||
}
|
||||
|
||||
class SetPasskeyTask : public Task
|
||||
class SetPasskeyTask : public Runnable
|
||||
{
|
||||
public:
|
||||
SetPasskeyTask(const BluetoothAddress& aDeviceAddress,
|
||||
|
@ -3349,7 +3372,7 @@ public:
|
|||
MOZ_ASSERT(mRunnable);
|
||||
}
|
||||
|
||||
void Run() override
|
||||
NS_IMETHOD Run() override
|
||||
{
|
||||
MOZ_ASSERT(!NS_IsMainThread()); // I/O thread
|
||||
|
||||
|
@ -3360,7 +3383,7 @@ public:
|
|||
BT_WARNING("%s: Couldn't get original request message.", __FUNCTION__);
|
||||
errorStr.AssignLiteral("Couldn't get original request message.");
|
||||
DispatchBluetoothReply(mRunnable, v, errorStr);
|
||||
return;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
DBusMessage *reply = dbus_message_new_method_return(msg);
|
||||
|
@ -3370,7 +3393,7 @@ public:
|
|||
dbus_message_unref(msg);
|
||||
errorStr.AssignLiteral("Memory can't be allocated for the message.");
|
||||
DispatchBluetoothReply(mRunnable, v, errorStr);
|
||||
return;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
uint32_t passkey = mPasskey;
|
||||
|
@ -3390,6 +3413,8 @@ public:
|
|||
|
||||
sPairingReqTable->Remove(mDeviceAddress);
|
||||
DispatchBluetoothReply(mRunnable, v, errorStr);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -3404,10 +3429,10 @@ BluetoothDBusService::SetPasskeyInternal(
|
|||
uint32_t aPasskey,
|
||||
BluetoothReplyRunnable* aRunnable)
|
||||
{
|
||||
Task* task = new SetPasskeyTask(aDeviceAddress,
|
||||
DispatchToDBusThread(
|
||||
MakeAndAddRef<SetPasskeyTask>(aDeviceAddress,
|
||||
aPasskey,
|
||||
aRunnable);
|
||||
DispatchToDBusThread(task);
|
||||
aRunnable));
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -3418,10 +3443,10 @@ BluetoothDBusService::SetPairingConfirmationInternal(
|
|||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
Task* task = new SetPairingConfirmationTask(aDeviceAddress,
|
||||
DispatchToDBusThread(
|
||||
MakeAndAddRef<SetPairingConfirmationTask>(aDeviceAddress,
|
||||
aConfirm,
|
||||
aRunnable);
|
||||
DispatchToDBusThread(task);
|
||||
aRunnable));
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -3616,7 +3641,7 @@ private:
|
|||
BluetoothProfileManagerBase* mBluetoothProfileManager;
|
||||
};
|
||||
|
||||
class GetServiceChannelTask : public Task
|
||||
class GetServiceChannelTask : public Runnable
|
||||
{
|
||||
public:
|
||||
GetServiceChannelTask(const BluetoothAddress& aDeviceAddress,
|
||||
|
@ -3630,7 +3655,7 @@ public:
|
|||
MOZ_ASSERT(mBluetoothProfileManager);
|
||||
}
|
||||
|
||||
void Run() override
|
||||
NS_IMETHOD Run() override
|
||||
{
|
||||
static const int sProtocolDescriptorList = 0x0004;
|
||||
|
||||
|
@ -3659,9 +3684,11 @@ public:
|
|||
DBUS_TYPE_STRING, &cstrServiceUUID,
|
||||
DBUS_TYPE_UINT16, &sProtocolDescriptorList,
|
||||
DBUS_TYPE_INVALID);
|
||||
NS_ENSURE_TRUE_VOID(success);
|
||||
NS_ENSURE_TRUE(success, NS_OK);
|
||||
|
||||
Unused << handler.forget(); // picked up by callback handler
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -3685,10 +3712,10 @@ BluetoothDBusService::GetServiceChannel(const BluetoothAddress& aDeviceAddress,
|
|||
#ifdef MOZ_WIDGET_GONK
|
||||
// GetServiceAttributeValue only exists in android's bluez dbus binding
|
||||
// implementation
|
||||
Task* task = new GetServiceChannelTask(aDeviceAddress,
|
||||
DispatchToDBusThread(
|
||||
MakeAndAddRef<GetServiceChannelTask>(aDeviceAddress,
|
||||
aServiceUUID,
|
||||
aManager);
|
||||
DispatchToDBusThread(task);
|
||||
aManager));
|
||||
#else
|
||||
// FIXME/Bug 793977 qdot: Just set something for desktop, until we have a
|
||||
// parser for the GetServiceAttributes xml block
|
||||
|
@ -3706,7 +3733,7 @@ BluetoothDBusService::GetServiceChannel(const BluetoothAddress& aDeviceAddress,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
class UpdateSdpRecordsTask : public Task
|
||||
class UpdateSdpRecordsTask : public Runnable
|
||||
{
|
||||
public:
|
||||
UpdateSdpRecordsTask(const BluetoothAddress& aDeviceAddress,
|
||||
|
@ -3718,7 +3745,7 @@ public:
|
|||
MOZ_ASSERT(mBluetoothProfileManager);
|
||||
}
|
||||
|
||||
void Run() override
|
||||
NS_IMETHOD Run() override
|
||||
{
|
||||
MOZ_ASSERT(!NS_IsMainThread()); // I/O thread
|
||||
MOZ_ASSERT(sDBusConnection);
|
||||
|
@ -3740,6 +3767,7 @@ public:
|
|||
"DiscoverServices",
|
||||
DBUS_TYPE_STRING, &EmptyCString(),
|
||||
DBUS_TYPE_INVALID);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
protected:
|
||||
|
@ -3763,8 +3791,8 @@ BluetoothDBusService::UpdateSdpRecords(const BluetoothAddress& aDeviceAddress,
|
|||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
Task* task = new UpdateSdpRecordsTask(aDeviceAddress, aManager);
|
||||
DispatchToDBusThread(task);
|
||||
DispatchToDBusThread(
|
||||
MakeAndAddRef<UpdateSdpRecordsTask>(aDeviceAddress, aManager));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -3892,7 +3920,7 @@ BluetoothDBusService::IsScoConnected(BluetoothReplyRunnable* aRunnable)
|
|||
DispatchBluetoothReply(aRunnable, hfp->IsScoConnected(), EmptyString());
|
||||
}
|
||||
|
||||
class SendMetadataTask : public Task
|
||||
class SendMetadataTask : public Runnable
|
||||
{
|
||||
public:
|
||||
SendMetadataTask(const BluetoothAddress& aDeviceAddress,
|
||||
|
@ -3916,7 +3944,7 @@ public:
|
|||
MOZ_ASSERT(mRunnable);
|
||||
}
|
||||
|
||||
void Run() override
|
||||
NS_IMETHOD Run() override
|
||||
{
|
||||
MOZ_ASSERT(!NS_IsMainThread()); // I/O thread
|
||||
MOZ_ASSERT(sDBusConnection);
|
||||
|
@ -3965,9 +3993,11 @@ public:
|
|||
DBUS_TYPE_STRING, &duration,
|
||||
DBUS_TYPE_STRING, &genre,
|
||||
DBUS_TYPE_INVALID);
|
||||
NS_ENSURE_TRUE_VOID(success);
|
||||
NS_ENSURE_TRUE(success, NS_OK);
|
||||
|
||||
Unused << mRunnable.forget(); // picked up by callback handler
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -4021,22 +4051,22 @@ BluetoothDBusService::SendMetaData(const nsAString& aTitle,
|
|||
BluetoothAddress deviceAddress;
|
||||
avrcp->GetAddress(deviceAddress);
|
||||
|
||||
Task* task = new SendMetadataTask(
|
||||
deviceAddress,
|
||||
NS_ConvertUTF16toUTF8(aTitle),
|
||||
NS_ConvertUTF16toUTF8(aArtist),
|
||||
NS_ConvertUTF16toUTF8(aAlbum),
|
||||
aMediaNumber,
|
||||
aTotalMediaCount,
|
||||
aDuration,
|
||||
aRunnable);
|
||||
DispatchToDBusThread(task);
|
||||
DispatchToDBusThread(
|
||||
MakeAndAddRef<SendMetadataTask>(
|
||||
deviceAddress,
|
||||
NS_ConvertUTF16toUTF8(aTitle),
|
||||
NS_ConvertUTF16toUTF8(aArtist),
|
||||
NS_ConvertUTF16toUTF8(aAlbum),
|
||||
aMediaNumber,
|
||||
aTotalMediaCount,
|
||||
aDuration,
|
||||
aRunnable));
|
||||
|
||||
avrcp->UpdateMetaData(aTitle, aArtist, aAlbum,
|
||||
aMediaNumber, aTotalMediaCount, aDuration);
|
||||
}
|
||||
|
||||
class SendPlayStatusTask : public Task
|
||||
class SendPlayStatusTask : public Runnable
|
||||
{
|
||||
public:
|
||||
SendPlayStatusTask(const BluetoothAddress& aDeviceAddress,
|
||||
|
@ -4054,7 +4084,7 @@ public:
|
|||
MOZ_ASSERT(mRunnable);
|
||||
}
|
||||
|
||||
void Run() override
|
||||
NS_IMETHOD Run() override
|
||||
{
|
||||
MOZ_ASSERT(!NS_IsMainThread()); // I/O thread
|
||||
MOZ_ASSERT(sDBusConnection);
|
||||
|
@ -4074,9 +4104,11 @@ public:
|
|||
DBUS_TYPE_UINT32, &mPosition,
|
||||
DBUS_TYPE_UINT32, &tempPlayStatus,
|
||||
DBUS_TYPE_INVALID);
|
||||
NS_ENSURE_TRUE_VOID(success);
|
||||
NS_ENSURE_TRUE(success, NS_OK);
|
||||
|
||||
Unused << mRunnable.forget(); // picked up by callback handler
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -4134,12 +4166,12 @@ BluetoothDBusService::SendPlayStatus(int64_t aDuration,
|
|||
BluetoothAddress deviceAddress;
|
||||
avrcp->GetAddress(deviceAddress);
|
||||
|
||||
Task* task = new SendPlayStatusTask(deviceAddress,
|
||||
DispatchToDBusThread(
|
||||
MakeAndAddRef<SendPlayStatusTask>(deviceAddress,
|
||||
aDuration,
|
||||
aPosition,
|
||||
aPlayStatus,
|
||||
aRunnable);
|
||||
DispatchToDBusThread(task);
|
||||
aRunnable));
|
||||
|
||||
avrcp->UpdatePlayStatus(aDuration, aPosition, aPlayStatus);
|
||||
}
|
||||
|
@ -4157,7 +4189,7 @@ ControlCallback(DBusMessage* aMsg, void* aParam)
|
|||
}
|
||||
}
|
||||
|
||||
class UpdatePlayStatusTask : public Task
|
||||
class UpdatePlayStatusTask : public Runnable
|
||||
{
|
||||
public:
|
||||
UpdatePlayStatusTask(const BluetoothAddress& aDeviceAddress,
|
||||
|
@ -4172,7 +4204,7 @@ public:
|
|||
MOZ_ASSERT(!mDeviceAddress.IsCleared());
|
||||
}
|
||||
|
||||
void Run() override
|
||||
NS_IMETHOD Run() override
|
||||
{
|
||||
MOZ_ASSERT(!NS_IsMainThread()); // I/O thread
|
||||
MOZ_ASSERT(sDBusConnection);
|
||||
|
@ -4192,7 +4224,9 @@ public:
|
|||
DBUS_TYPE_UINT32, &mPosition,
|
||||
DBUS_TYPE_UINT32, &tempPlayStatus,
|
||||
DBUS_TYPE_INVALID);
|
||||
NS_ENSURE_TRUE_VOID(success);
|
||||
NS_ENSURE_TRUE(success, NS_OK);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -4218,14 +4252,14 @@ BluetoothDBusService::UpdatePlayStatus(uint32_t aDuration,
|
|||
BluetoothAddress deviceAddress;
|
||||
avrcp->GetAddress(deviceAddress);
|
||||
|
||||
Task* task = new UpdatePlayStatusTask(deviceAddress,
|
||||
DispatchToDBusThread(
|
||||
MakeAndAddRef<UpdatePlayStatusTask>(deviceAddress,
|
||||
aDuration,
|
||||
aPosition,
|
||||
aPlayStatus);
|
||||
DispatchToDBusThread(task);
|
||||
aPlayStatus));
|
||||
}
|
||||
|
||||
class UpdateNotificationTask : public Task
|
||||
class UpdateNotificationTask : public Runnable
|
||||
{
|
||||
public:
|
||||
UpdateNotificationTask(const BluetoothAddress& aDeviceAddress,
|
||||
|
@ -4238,7 +4272,7 @@ public:
|
|||
MOZ_ASSERT(!mDeviceAddress.IsCleared());
|
||||
}
|
||||
|
||||
void Run() override
|
||||
NS_IMETHOD Run() override
|
||||
{
|
||||
MOZ_ASSERT(!NS_IsMainThread()); // I/O thread
|
||||
MOZ_ASSERT(sDBusConnection);
|
||||
|
@ -4257,7 +4291,9 @@ public:
|
|||
DBUS_TYPE_UINT16, &eventId,
|
||||
DBUS_TYPE_UINT64, &mData,
|
||||
DBUS_TYPE_INVALID);
|
||||
NS_ENSURE_TRUE_VOID(success);
|
||||
NS_ENSURE_TRUE(success, NS_OK);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -4281,8 +4317,8 @@ BluetoothDBusService::UpdateNotification(ControlEventId aEventId,
|
|||
BluetoothAddress deviceAddress;
|
||||
avrcp->GetAddress(deviceAddress);
|
||||
|
||||
Task* task = new UpdateNotificationTask(deviceAddress, aEventId, aData);
|
||||
DispatchToDBusThread(task);
|
||||
DispatchToDBusThread(
|
||||
MakeAndAddRef<UpdateNotificationTask>(deviceAddress, aEventId, aData));
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -242,10 +242,10 @@ BluetoothHfpManager::Notify(const hal::BatteryInformation& aBatteryInfo)
|
|||
}
|
||||
|
||||
#ifdef MOZ_B2G_RIL
|
||||
class BluetoothHfpManager::RespondToBLDNTask : public Task
|
||||
class BluetoothHfpManager::RespondToBLDNTask : public Runnable
|
||||
{
|
||||
private:
|
||||
void Run() override
|
||||
NS_IMETHOD Run() override
|
||||
{
|
||||
MOZ_ASSERT(sBluetoothHfpManager);
|
||||
|
||||
|
@ -253,10 +253,11 @@ private:
|
|||
sBluetoothHfpManager->mDialingRequestProcessed = true;
|
||||
sBluetoothHfpManager->SendLine("ERROR");
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
};
|
||||
|
||||
class BluetoothHfpManager::SendRingIndicatorTask : public Task
|
||||
class BluetoothHfpManager::SendRingIndicatorTask : public Runnable
|
||||
{
|
||||
public:
|
||||
SendRingIndicatorTask(const nsAString& aNumber, int aType)
|
||||
|
@ -266,18 +267,18 @@ public:
|
|||
MOZ_ASSERT(NS_IsMainThread());
|
||||
}
|
||||
|
||||
void Run() override
|
||||
NS_IMETHOD Run() override
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
// Stop sending RING indicator
|
||||
if (sStopSendingRingFlag) {
|
||||
return;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
if (!sBluetoothHfpManager) {
|
||||
BT_WARNING("BluetoothHfpManager no longer exists, cannot send ring!");
|
||||
return;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsAutoCString ringMsg("RING");
|
||||
|
@ -291,10 +292,10 @@ public:
|
|||
sBluetoothHfpManager->SendLine(clipMsg.get());
|
||||
}
|
||||
|
||||
MessageLoop::current()->
|
||||
PostDelayedTask(FROM_HERE,
|
||||
new SendRingIndicatorTask(mNumber, mType),
|
||||
sRingInterval);
|
||||
MessageLoop::current()->PostDelayedTask(
|
||||
MakeAndAddRef<SendRingIndicatorTask>(mNumber, mType), sRingInterval);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -303,14 +304,16 @@ private:
|
|||
};
|
||||
#endif // MOZ_B2G_RIL
|
||||
|
||||
class BluetoothHfpManager::CloseScoTask : public Task
|
||||
class BluetoothHfpManager::CloseScoTask : public Runnable
|
||||
{
|
||||
private:
|
||||
void Run() override
|
||||
NS_IMETHOD Run() override
|
||||
{
|
||||
MOZ_ASSERT(sBluetoothHfpManager);
|
||||
|
||||
sBluetoothHfpManager->DisconnectSco();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -985,7 +988,7 @@ BluetoothHfpManager::ReceiveSocketData(BluetoothSocket* aSocket,
|
|||
}
|
||||
|
||||
MessageLoop::current()->
|
||||
PostDelayedTask(FROM_HERE, new RespondToBLDNTask(),
|
||||
PostDelayedTask(MakeAndAddRef<RespondToBLDNTask>(),
|
||||
sWaitingForDialingInterval);
|
||||
|
||||
// Don't send response 'OK' here because we'll respond later in either
|
||||
|
@ -1576,9 +1579,8 @@ BluetoothHfpManager::HandleCallStateChanged(uint32_t aCallIndex,
|
|||
}
|
||||
|
||||
MessageLoop::current()->PostDelayedTask(
|
||||
FROM_HERE,
|
||||
new SendRingIndicatorTask(number,
|
||||
mCurrentCallArray[aCallIndex].mType),
|
||||
MakeAndAddRef<SendRingIndicatorTask>(
|
||||
number, mCurrentCallArray[aCallIndex].mType),
|
||||
sRingInterval);
|
||||
}
|
||||
break;
|
||||
|
@ -1686,8 +1688,7 @@ BluetoothHfpManager::HandleCallStateChanged(uint32_t aCallIndex,
|
|||
DisconnectSco();
|
||||
} else {
|
||||
// Close Sco later since Dialer is still playing busy tone via HF.
|
||||
MessageLoop::current()->PostDelayedTask(FROM_HERE,
|
||||
new CloseScoTask(),
|
||||
MessageLoop::current()->PostDelayedTask(MakeAndAddRef<CloseScoTask>(),
|
||||
sBusyToneInterval);
|
||||
}
|
||||
|
||||
|
|
|
@ -167,7 +167,7 @@ private:
|
|||
uint32_t mAvailablePacketSize;
|
||||
};
|
||||
|
||||
class CloseSocketTask : public Task
|
||||
class CloseSocketTask : public Runnable
|
||||
{
|
||||
public:
|
||||
CloseSocketTask(BluetoothSocket* aSocket) : mSocket(aSocket)
|
||||
|
@ -175,7 +175,7 @@ public:
|
|||
MOZ_ASSERT(aSocket);
|
||||
}
|
||||
|
||||
void Run() override
|
||||
NS_IMETHOD Run() override
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
|
@ -183,6 +183,7 @@ public:
|
|||
SocketConnectionStatus::SOCKET_CONNECTED) {
|
||||
mSocket->Close();
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -1076,7 +1077,7 @@ BluetoothOppManager::ClientDataHandler(UnixSocketBuffer* aMessage)
|
|||
// disconnected, we will close it.
|
||||
if (mSocket) {
|
||||
MessageLoop::current()->
|
||||
PostDelayedTask(FROM_HERE, new CloseSocketTask(mSocket), 1000);
|
||||
PostDelayedTask(MakeAndAddRef<CloseSocketTask>(mSocket), 1000);
|
||||
}
|
||||
} else if (mLastCommand == ObexRequestCode::Connect) {
|
||||
MOZ_ASSERT(!mFileName.IsEmpty());
|
||||
|
|
|
@ -43,7 +43,7 @@ public:
|
|||
// Delayed-task handling
|
||||
//
|
||||
|
||||
void SetDelayedConnectTask(CancelableTask* aTask);
|
||||
void SetDelayedConnectTask(CancelableRunnable* aTask);
|
||||
void ClearDelayedConnectTask();
|
||||
void CancelDelayedConnectTask();
|
||||
|
||||
|
@ -126,7 +126,7 @@ private:
|
|||
* Task member for delayed connect task. Should only be access on consumer
|
||||
* thread.
|
||||
*/
|
||||
CancelableTask* mDelayedConnectTask;
|
||||
CancelableRunnable* mDelayedConnectTask;
|
||||
|
||||
/**
|
||||
* I/O buffer for received data
|
||||
|
@ -193,7 +193,7 @@ BluetoothSocket::BluetoothSocketIO::GetDataSocket()
|
|||
}
|
||||
|
||||
void
|
||||
BluetoothSocket::BluetoothSocketIO::SetDelayedConnectTask(CancelableTask* aTask)
|
||||
BluetoothSocket::BluetoothSocketIO::SetDelayedConnectTask(CancelableRunnable* aTask)
|
||||
{
|
||||
MOZ_ASSERT(IsConsumerThread());
|
||||
|
||||
|
@ -285,7 +285,7 @@ BluetoothSocket::BluetoothSocketIO::OnConnected()
|
|||
MOZ_ASSERT(GetConnectionStatus() == SOCKET_IS_CONNECTED);
|
||||
|
||||
GetConsumerThread()->PostTask(
|
||||
FROM_HERE, new SocketEventTask(this, SocketEventTask::CONNECT_SUCCESS));
|
||||
MakeAndAddRef<SocketEventTask>(this, SocketEventTask::CONNECT_SUCCESS));
|
||||
|
||||
AddWatchers(READ_WATCHER, true);
|
||||
if (HasPendingData()) {
|
||||
|
@ -334,7 +334,7 @@ BluetoothSocket::BluetoothSocketIO::OnSocketCanAcceptWithoutBlocking()
|
|||
SetSocket(fd, SOCKET_IS_CONNECTED);
|
||||
|
||||
GetConsumerThread()->PostTask(
|
||||
FROM_HERE, new SocketEventTask(this, SocketEventTask::CONNECT_SUCCESS));
|
||||
MakeAndAddRef<SocketEventTask>(this, SocketEventTask::CONNECT_SUCCESS));
|
||||
|
||||
AddWatchers(READ_WATCHER, true);
|
||||
if (HasPendingData()) {
|
||||
|
@ -384,7 +384,7 @@ BluetoothSocket::BluetoothSocketIO::FireSocketError()
|
|||
|
||||
// Tell the consumer thread we've errored
|
||||
GetConsumerThread()->PostTask(
|
||||
FROM_HERE, new SocketEventTask(this, SocketEventTask::CONNECT_ERROR));
|
||||
MakeAndAddRef<SocketEventTask>(this, SocketEventTask::CONNECT_ERROR));
|
||||
}
|
||||
|
||||
// |DataSocketIO|
|
||||
|
@ -416,7 +416,7 @@ public:
|
|||
, mBuffer(aBuffer)
|
||||
{ }
|
||||
|
||||
void Run() override
|
||||
NS_IMETHOD Run() override
|
||||
{
|
||||
BluetoothSocketIO* io = SocketTask<BluetoothSocketIO>::GetIO();
|
||||
|
||||
|
@ -425,13 +425,15 @@ public:
|
|||
if (NS_WARN_IF(io->IsShutdownOnConsumerThread())) {
|
||||
// Since we've already explicitly closed and the close
|
||||
// happened before this, this isn't really an error.
|
||||
return;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
BluetoothSocket* bluetoothSocket = io->GetBluetoothSocket();
|
||||
MOZ_ASSERT(bluetoothSocket);
|
||||
|
||||
bluetoothSocket->ReceiveSocketData(mBuffer);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -441,8 +443,8 @@ private:
|
|||
void
|
||||
BluetoothSocket::BluetoothSocketIO::ConsumeBuffer()
|
||||
{
|
||||
GetConsumerThread()->PostTask(FROM_HERE,
|
||||
new ReceiveTask(this, mBuffer.release()));
|
||||
GetConsumerThread()->PostTask(
|
||||
MakeAndAddRef<ReceiveTask>(this, mBuffer.release()));
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -505,13 +507,14 @@ public:
|
|||
: SocketIOTask<BluetoothSocketIO>(aIO)
|
||||
{ }
|
||||
|
||||
void Run() override
|
||||
NS_IMETHOD Run() override
|
||||
{
|
||||
MOZ_ASSERT(!GetIO()->IsConsumerThread());
|
||||
|
||||
if (!IsCanceled()) {
|
||||
GetIO()->Listen();
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -523,12 +526,14 @@ public:
|
|||
: SocketIOTask<BluetoothSocketIO>(aIO)
|
||||
{ }
|
||||
|
||||
void Run() override
|
||||
NS_IMETHOD Run() override
|
||||
{
|
||||
MOZ_ASSERT(!GetIO()->IsConsumerThread());
|
||||
MOZ_ASSERT(!IsCanceled());
|
||||
|
||||
GetIO()->Connect();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -540,21 +545,23 @@ public:
|
|||
: SocketIOTask<BluetoothSocketIO>(aIO)
|
||||
{ }
|
||||
|
||||
void Run() override
|
||||
NS_IMETHOD Run() override
|
||||
{
|
||||
MOZ_ASSERT(GetIO()->IsConsumerThread());
|
||||
|
||||
if (IsCanceled()) {
|
||||
return;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
BluetoothSocketIO* io = GetIO();
|
||||
if (io->IsShutdownOnConsumerThread()) {
|
||||
return;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
io->ClearDelayedConnectTask();
|
||||
io->GetIOLoop()->PostTask(FROM_HERE, new ConnectTask(io));
|
||||
io->GetIOLoop()->PostTask(MakeAndAddRef<ConnectTask>(io));
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -670,11 +677,12 @@ BluetoothSocket::Connect(BluetoothUnixSocketConnector* aConnector,
|
|||
SetConnectionStatus(SOCKET_CONNECTING);
|
||||
|
||||
if (aDelayMs > 0) {
|
||||
DelayedConnectTask* connectTask = new DelayedConnectTask(mIO);
|
||||
RefPtr<DelayedConnectTask> connectTask =
|
||||
MakeAndAddRef<DelayedConnectTask>(mIO);
|
||||
mIO->SetDelayedConnectTask(connectTask);
|
||||
MessageLoop::current()->PostDelayedTask(FROM_HERE, connectTask, aDelayMs);
|
||||
MessageLoop::current()->PostDelayedTask(connectTask.forget(), aDelayMs);
|
||||
} else {
|
||||
aIOLoop->PostTask(FROM_HERE, new ConnectTask(mIO));
|
||||
aIOLoop->PostTask(MakeAndAddRef<ConnectTask>(mIO));
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
|
@ -700,7 +708,7 @@ BluetoothSocket::Listen(BluetoothUnixSocketConnector* aConnector,
|
|||
mIO = new BluetoothSocketIO(aConsumerLoop, aIOLoop, this, aConnector);
|
||||
SetConnectionStatus(SOCKET_LISTENING);
|
||||
|
||||
aIOLoop->PostTask(FROM_HERE, new ListenTask(mIO));
|
||||
aIOLoop->PostTask(MakeAndAddRef<ListenTask>(mIO));
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -733,8 +741,7 @@ BluetoothSocket::SendSocketData(UnixSocketIOBuffer* aBuffer)
|
|||
MOZ_ASSERT(!mIO->IsShutdownOnConsumerThread());
|
||||
|
||||
mIO->GetIOLoop()->PostTask(
|
||||
FROM_HERE,
|
||||
new SocketIOSendTask<BluetoothSocketIO, UnixSocketIOBuffer>(mIO, aBuffer));
|
||||
MakeAndAddRef<SocketIOSendTask<BluetoothSocketIO, UnixSocketIOBuffer>>(mIO, aBuffer));
|
||||
}
|
||||
|
||||
// |SocketBase|
|
||||
|
@ -754,7 +761,7 @@ BluetoothSocket::Close()
|
|||
// We sever the relationship here so any future calls to listen or connect
|
||||
// will create a new implementation.
|
||||
mIO->ShutdownOnConsumerThread();
|
||||
mIO->GetIOLoop()->PostTask(FROM_HERE, new SocketIOShutdownTask(mIO));
|
||||
mIO->GetIOLoop()->PostTask(MakeAndAddRef<SocketIOShutdownTask>(mIO));
|
||||
mIO = nullptr;
|
||||
|
||||
NotifyDisconnect();
|
||||
|
|
|
@ -94,7 +94,7 @@ NuwaFork()
|
|||
sNuwaForking = true;
|
||||
|
||||
MessageLoop* ioloop = XRE_GetIOMessageLoop();
|
||||
ioloop->PostTask(FROM_HERE, NewRunnableFunction(RunNuwaFork));
|
||||
ioloop->PostTask(NewRunnableFunction(RunNuwaFork));
|
||||
}
|
||||
|
||||
} // Anonymous namespace.
|
||||
|
|
|
@ -68,7 +68,7 @@ private:
|
|||
void NuwaFork();
|
||||
|
||||
// initialization off the critical path of app startup.
|
||||
CancelableTask* mPreallocateAppProcessTask;
|
||||
CancelableRunnable* mPreallocateAppProcessTask;
|
||||
|
||||
// The array containing the preallocated processes. 4 as the inline storage size
|
||||
// should be enough so we don't need to grow the AutoTArray.
|
||||
|
@ -243,7 +243,7 @@ PreallocatedProcessManagerImpl::ScheduleDelayedNuwaFork()
|
|||
return;
|
||||
}
|
||||
|
||||
RefPtr<CancelableTask> task = NewRunnableMethod(
|
||||
RefPtr<CancelableRunnable> task = NewRunnableMethod(
|
||||
this, &PreallocatedProcessManagerImpl::DelayedNuwaFork);
|
||||
mPreallocateAppProcessTask = task;
|
||||
MessageLoop::current()->PostDelayedTask(task.forget(),
|
||||
|
|
|
@ -174,15 +174,15 @@ static const VolumeData gVolumeData[] = {
|
|||
{"audio.volume.bt_sco", AUDIO_STREAM_BLUETOOTH_SCO}
|
||||
};
|
||||
|
||||
class RunnableCallTask : public Task
|
||||
class RunnableCallTask : public Runnable
|
||||
{
|
||||
public:
|
||||
explicit RunnableCallTask(nsIRunnable* aRunnable)
|
||||
: mRunnable(aRunnable) {}
|
||||
|
||||
void Run() override
|
||||
NS_IMETHOD Run() override
|
||||
{
|
||||
mRunnable->Run();
|
||||
return mRunnable->Run();
|
||||
}
|
||||
protected:
|
||||
nsCOMPtr<nsIRunnable> mRunnable;
|
||||
|
@ -504,7 +504,7 @@ AudioManager::HandleBluetoothStatusChanged(nsISupports* aSubject,
|
|||
self->mA2dpSwitchDone = true;
|
||||
});
|
||||
MessageLoop::current()->PostDelayedTask(
|
||||
FROM_HERE, new RunnableCallTask(runnable), 1000);
|
||||
MakeAndAddRef<RunnableCallTask>(runnable), 1000);
|
||||
|
||||
mA2dpSwitchDone = false;
|
||||
} else {
|
||||
|
@ -663,7 +663,8 @@ AudioManager::HandleHeadphoneSwitchEvent(const hal::SwitchEvent& aEvent)
|
|||
self->UpdateHeadsetConnectionState(hal::SWITCH_STATE_OFF);
|
||||
self->mSwitchDone = true;
|
||||
});
|
||||
MessageLoop::current()->PostDelayedTask(FROM_HERE, new RunnableCallTask(runnable), 1000);
|
||||
MessageLoop::current()->PostDelayedTask(
|
||||
MakeAndAddRef<RunnableCallTask>(runnable), 1000);
|
||||
mSwitchDone = false;
|
||||
} else if (aEvent.status() != hal::SWITCH_STATE_OFF) {
|
||||
UpdateHeadsetConnectionState(aEvent.status());
|
||||
|
@ -1418,7 +1419,7 @@ AudioManager::VolumeStreamState::SetVolumeIndexToConsistentDeviceIfNeeded(uint32
|
|||
// No alias device
|
||||
rv = SetVolumeIndex(aIndex, aDevice);
|
||||
}
|
||||
return rv;
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult
|
||||
|
|
|
@ -962,8 +962,7 @@ AutoMounter::UpdateState()
|
|||
if (delay <= 4000) {
|
||||
LOG("UpdateState: Volume '%s' is inaccessible, checking again in %d msec", vol->NameStr(), delay);
|
||||
MessageLoopForIO::current()->
|
||||
PostDelayedTask(FROM_HERE,
|
||||
NewRunnableMethod(this, &AutoMounter::UpdateState),
|
||||
PostDelayedTask(NewRunnableMethod(this, &AutoMounter::UpdateState),
|
||||
delay);
|
||||
delay *= 2;
|
||||
} else {
|
||||
|
@ -1037,8 +1036,7 @@ AutoMounter::UpdateState()
|
|||
delay = 5000;
|
||||
}
|
||||
MessageLoopForIO::current()->
|
||||
PostDelayedTask(FROM_HERE,
|
||||
NewRunnableMethod(this, &AutoMounter::UpdateState),
|
||||
PostDelayedTask(NewRunnableMethod(this, &AutoMounter::UpdateState),
|
||||
delay);
|
||||
filesOpen = true;
|
||||
break;
|
||||
|
@ -1390,7 +1388,6 @@ public:
|
|||
DBG("UsbCable switch device: %d state: %s\n",
|
||||
aEvent.device(), SwitchStateStr(aEvent));
|
||||
XRE_GetIOMessageLoop()->PostTask(
|
||||
FROM_HERE,
|
||||
NewRunnableFunction(UsbCableEventIOThread));
|
||||
}
|
||||
};
|
||||
|
@ -1405,7 +1402,6 @@ InitAutoMounter()
|
|||
sAutoMounterSetting = new AutoMounterSetting();
|
||||
|
||||
XRE_GetIOMessageLoop()->PostTask(
|
||||
FROM_HERE,
|
||||
NewRunnableFunction(InitAutoMounterIOThread));
|
||||
|
||||
// Switch Observers need to run on the main thread, so we need to
|
||||
|
@ -1442,7 +1438,6 @@ void
|
|||
SetAutoMounterMode(int32_t aMode)
|
||||
{
|
||||
XRE_GetIOMessageLoop()->PostTask(
|
||||
FROM_HERE,
|
||||
NewRunnableFunction(SetAutoMounterModeIOThread, aMode));
|
||||
}
|
||||
|
||||
|
@ -1450,7 +1445,6 @@ void
|
|||
SetAutoMounterSharingMode(const nsCString& aVolumeName, bool aAllowSharing)
|
||||
{
|
||||
XRE_GetIOMessageLoop()->PostTask(
|
||||
FROM_HERE,
|
||||
NewRunnableFunction(SetAutoMounterSharingModeIOThread,
|
||||
aVolumeName, aAllowSharing));
|
||||
}
|
||||
|
@ -1459,7 +1453,6 @@ void
|
|||
AutoMounterFormatVolume(const nsCString& aVolumeName)
|
||||
{
|
||||
XRE_GetIOMessageLoop()->PostTask(
|
||||
FROM_HERE,
|
||||
NewRunnableFunction(AutoMounterFormatVolumeIOThread,
|
||||
aVolumeName));
|
||||
}
|
||||
|
@ -1468,7 +1461,6 @@ void
|
|||
AutoMounterMountVolume(const nsCString& aVolumeName)
|
||||
{
|
||||
XRE_GetIOMessageLoop()->PostTask(
|
||||
FROM_HERE,
|
||||
NewRunnableFunction(AutoMounterMountVolumeIOThread,
|
||||
aVolumeName));
|
||||
}
|
||||
|
@ -1477,7 +1469,6 @@ void
|
|||
AutoMounterUnmountVolume(const nsCString& aVolumeName)
|
||||
{
|
||||
XRE_GetIOMessageLoop()->PostTask(
|
||||
FROM_HERE,
|
||||
NewRunnableFunction(AutoMounterUnmountVolumeIOThread,
|
||||
aVolumeName));
|
||||
}
|
||||
|
@ -1498,7 +1489,6 @@ ShutdownAutoMounter()
|
|||
sUsbCableObserver = nullptr;
|
||||
|
||||
XRE_GetIOMessageLoop()->PostTask(
|
||||
FROM_HERE,
|
||||
NewRunnableFunction(ShutdownAutoMounterIOThread));
|
||||
}
|
||||
|
||||
|
|
|
@ -528,8 +528,7 @@ VolumeManager::Start()
|
|||
if (!sVolumeManager->OpenSocket()) {
|
||||
// Socket open failed, try again in a second.
|
||||
MessageLoopForIO::current()->
|
||||
PostDelayedTask(FROM_HERE,
|
||||
NewRunnableFunction(VolumeManager::Start),
|
||||
PostDelayedTask(NewRunnableFunction(VolumeManager::Start),
|
||||
1000);
|
||||
}
|
||||
}
|
||||
|
@ -575,7 +574,6 @@ void
|
|||
InitVolumeManager()
|
||||
{
|
||||
XRE_GetIOMessageLoop()->PostTask(
|
||||
FROM_HERE,
|
||||
NewRunnableFunction(InitVolumeManagerIOThread));
|
||||
}
|
||||
|
||||
|
@ -585,7 +583,6 @@ ShutdownVolumeManager()
|
|||
ShutdownVolumeServiceTest();
|
||||
|
||||
XRE_GetIOMessageLoop()->PostTask(
|
||||
FROM_HERE,
|
||||
NewRunnableFunction(ShutdownVolumeManagerIOThread));
|
||||
}
|
||||
|
||||
|
|
|
@ -265,7 +265,6 @@ NS_IMETHODIMP nsVolume::Format()
|
|||
MOZ_ASSERT(XRE_IsParentProcess());
|
||||
|
||||
XRE_GetIOMessageLoop()->PostTask(
|
||||
FROM_HERE,
|
||||
NewRunnableFunction(FormatVolumeIOThread, NameStr()));
|
||||
|
||||
return NS_OK;
|
||||
|
@ -289,7 +288,6 @@ NS_IMETHODIMP nsVolume::Mount()
|
|||
MOZ_ASSERT(XRE_IsParentProcess());
|
||||
|
||||
XRE_GetIOMessageLoop()->PostTask(
|
||||
FROM_HERE,
|
||||
NewRunnableFunction(MountVolumeIOThread, NameStr()));
|
||||
|
||||
return NS_OK;
|
||||
|
@ -313,7 +311,6 @@ NS_IMETHODIMP nsVolume::Unmount()
|
|||
MOZ_ASSERT(XRE_IsParentProcess());
|
||||
|
||||
XRE_GetIOMessageLoop()->PostTask(
|
||||
FROM_HERE,
|
||||
NewRunnableFunction(UnmountVolumeIOThread, NameStr()));
|
||||
|
||||
return NS_OK;
|
||||
|
@ -411,7 +408,6 @@ nsVolume::UpdateMountLock(bool aMountLocked)
|
|||
mMountLocked = aMountLocked;
|
||||
LogState();
|
||||
XRE_GetIOMessageLoop()->PostTask(
|
||||
FROM_HERE,
|
||||
NewRunnableFunction(Volume::UpdateMountLock,
|
||||
NS_LossyConvertUTF16toASCII(Name()),
|
||||
MountGeneration(), aMountLocked));
|
||||
|
|
|
@ -80,7 +80,6 @@ nsVolumeService::Shutdown()
|
|||
}
|
||||
|
||||
XRE_GetIOMessageLoop()->PostTask(
|
||||
FROM_HERE,
|
||||
NewRunnableFunction(ShutdownVolumeServiceIOThread));
|
||||
|
||||
sSingleton = nullptr;
|
||||
|
@ -101,7 +100,6 @@ nsVolumeService::nsVolumeService()
|
|||
// Startup the IOThread side of things. The actual volume changes
|
||||
// are captured by the IOThread and forwarded to main thread.
|
||||
XRE_GetIOMessageLoop()->PostTask(
|
||||
FROM_HERE,
|
||||
NewRunnableFunction(InitVolumeServiceIOThread, this));
|
||||
|
||||
nsCOMPtr<nsIPowerManagerService> pmService =
|
||||
|
|
|
@ -311,7 +311,6 @@ StartDiskSpaceWatcher()
|
|||
gHalDiskSpaceWatcher = new GonkDiskSpaceWatcher();
|
||||
|
||||
XRE_GetIOMessageLoop()->PostTask(
|
||||
FROM_HERE,
|
||||
NewRunnableMethod(gHalDiskSpaceWatcher, &GonkDiskSpaceWatcher::DoStart));
|
||||
}
|
||||
|
||||
|
@ -324,7 +323,6 @@ StopDiskSpaceWatcher()
|
|||
}
|
||||
|
||||
XRE_GetIOMessageLoop()->PostTask(
|
||||
FROM_HERE,
|
||||
NewRunnableMethod(gHalDiskSpaceWatcher, &GonkDiskSpaceWatcher::DoStop));
|
||||
}
|
||||
|
||||
|
|
|
@ -525,7 +525,6 @@ void
|
|||
EnableBatteryNotifications()
|
||||
{
|
||||
XRE_GetIOMessageLoop()->PostTask(
|
||||
FROM_HERE,
|
||||
NewRunnableFunction(RegisterBatteryObserverIOThread));
|
||||
}
|
||||
|
||||
|
@ -543,7 +542,6 @@ void
|
|||
DisableBatteryNotifications()
|
||||
{
|
||||
XRE_GetIOMessageLoop()->PostTask(
|
||||
FROM_HERE,
|
||||
NewRunnableFunction(UnregisterBatteryObserverIOThread));
|
||||
}
|
||||
|
||||
|
|
|
@ -323,8 +323,8 @@ EnableSensorNotificationsInternal(SensorType aSensor)
|
|||
MOZ_ASSERT(sPollingThread);
|
||||
// sPollingThread never terminates because poll may never return
|
||||
sPollingThread->Start();
|
||||
sPollingThread->message_loop()->PostTask(FROM_HERE,
|
||||
NewRunnableFunction(PollSensors));
|
||||
sPollingThread->message_loop()->PostTask(
|
||||
NewRunnableFunction(PollSensors));
|
||||
}
|
||||
|
||||
SetSensorState(aSensor, true);
|
||||
|
|
|
@ -67,13 +67,13 @@ public:
|
|||
strcmp(mDevPath, aEvent->findParam("DEVPATH"))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
mState = ConvertState(GetStateString(aEvent));
|
||||
return mState != SWITCH_STATE_UNKNOWN;
|
||||
}
|
||||
|
||||
SwitchState GetState()
|
||||
{
|
||||
{
|
||||
return mState;
|
||||
}
|
||||
|
||||
|
@ -115,7 +115,7 @@ protected:
|
|||
if (state[bytesRead - 1] == '\n') {
|
||||
bytesRead--;
|
||||
}
|
||||
|
||||
|
||||
state[bytesRead] = '\0';
|
||||
mState = ConvertState(state);
|
||||
}
|
||||
|
@ -264,10 +264,10 @@ public:
|
|||
void Notify(const NetlinkEvent& aEvent)
|
||||
{
|
||||
SwitchState currState;
|
||||
|
||||
|
||||
SwitchDevice device = GetEventInfo(aEvent, currState);
|
||||
if (device == SWITCH_DEVICE_UNKNOWN) {
|
||||
return;
|
||||
return;
|
||||
}
|
||||
|
||||
EventInfo& info = mEventInfo[device];
|
||||
|
@ -372,7 +372,7 @@ private:
|
|||
{
|
||||
//working around the android code not being const-correct
|
||||
NetlinkEvent *e = const_cast<NetlinkEvent*>(&aEvent);
|
||||
|
||||
|
||||
for (size_t i = 0; i < mHandler.Length(); i++) {
|
||||
if (mHandler[i]->CheckEvent(e)) {
|
||||
aState = mHandler[i]->GetState();
|
||||
|
@ -413,7 +413,7 @@ EnableSwitchNotificationsIOThread(SwitchDevice aDevice, Monitor *aMonitor)
|
|||
lock.Notify();
|
||||
}
|
||||
|
||||
// Notify the latest state if IO thread has the information.
|
||||
// Notify the latest state if IO thread has the information.
|
||||
if (sSwitchObserver->GetEnableCount() > 1) {
|
||||
sSwitchObserver->NotifyAnEvent(aDevice);
|
||||
}
|
||||
|
@ -426,7 +426,6 @@ EnableSwitchNotifications(SwitchDevice aDevice)
|
|||
{
|
||||
MonitorAutoLock lock(monitor);
|
||||
XRE_GetIOMessageLoop()->PostTask(
|
||||
FROM_HERE,
|
||||
NewRunnableFunction(EnableSwitchNotificationsIOThread, aDevice, &monitor));
|
||||
lock.Wait();
|
||||
}
|
||||
|
@ -444,7 +443,6 @@ void
|
|||
DisableSwitchNotifications(SwitchDevice aDevice)
|
||||
{
|
||||
XRE_GetIOMessageLoop()->PostTask(
|
||||
FROM_HERE,
|
||||
NewRunnableFunction(DisableSwitchNotificationsIOThread, aDevice));
|
||||
}
|
||||
|
||||
|
@ -465,7 +463,6 @@ NotifySwitchStateIOThread(SwitchDevice aDevice, SwitchState aState)
|
|||
void NotifySwitchStateFromInputDevice(SwitchDevice aDevice, SwitchState aState)
|
||||
{
|
||||
XRE_GetIOMessageLoop()->PostTask(
|
||||
FROM_HERE,
|
||||
NewRunnableFunction(NotifySwitchStateIOThread, aDevice, aState));
|
||||
}
|
||||
|
||||
|
|
|
@ -161,17 +161,19 @@ NetlinkPoller::OpenSocket()
|
|||
|
||||
static StaticAutoPtr<NetlinkPoller> sPoller;
|
||||
|
||||
class UeventInitTask : public Task
|
||||
class UeventInitTask : public Runnable
|
||||
{
|
||||
virtual void Run()
|
||||
NS_IMETHOD Run() override
|
||||
{
|
||||
if (!sPoller) {
|
||||
return;
|
||||
return NS_OK;
|
||||
}
|
||||
if (sPoller->OpenSocket()) {
|
||||
return;
|
||||
return NS_OK;
|
||||
}
|
||||
sPoller->GetIOLoop()->PostDelayedTask(FROM_HERE, new UeventInitTask(), 1000);
|
||||
sPoller->GetIOLoop()->PostDelayedTask(MakeAndAddRef<UeventInitTask>(),
|
||||
1000);
|
||||
return NS_OK;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -217,7 +219,6 @@ public:
|
|||
MonitorAutoLock lock(*sMonitor);
|
||||
|
||||
XRE_GetIOMessageLoop()->PostTask(
|
||||
FROM_HERE,
|
||||
NewRunnableFunction(ShutdownUeventIOThread));
|
||||
|
||||
while (!sShutdown) {
|
||||
|
@ -267,7 +268,7 @@ InitializeUevent()
|
|||
{
|
||||
MOZ_ASSERT(!sPoller);
|
||||
sPoller = new NetlinkPoller();
|
||||
sPoller->GetIOLoop()->PostTask(FROM_HERE, new UeventInitTask());
|
||||
sPoller->GetIOLoop()->PostTask(MakeAndAddRef<UeventInitTask>());
|
||||
|
||||
ShutdownNetlinkPoller::MaybeInit();
|
||||
}
|
||||
|
|
|
@ -250,8 +250,7 @@ ProcLoaderClientDeinit()
|
|||
sProcLoaderLoop = nullptr;
|
||||
|
||||
MessageLoop::current()->
|
||||
PostTask(FROM_HERE,
|
||||
NewRunnableFunction(&_ProcLoaderParentDestroy,
|
||||
PostTask(NewRunnableFunction(&_ProcLoaderParentDestroy,
|
||||
procLoaderParent));
|
||||
}
|
||||
|
||||
|
@ -314,8 +313,7 @@ ProcLoaderLoad(const char *aArgv[],
|
|||
*aProcessHandle = sProcLoaderPid;
|
||||
sProcLoaderPid = 0;
|
||||
|
||||
sProcLoaderLoop->PostTask(FROM_HERE,
|
||||
NewRunnableFunction(AsyncSendLoad, load));
|
||||
sProcLoaderLoop->PostTask(NewRunnableFunction(AsyncSendLoad, load));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -491,9 +489,8 @@ ProcLoaderChild::RecvLoad(InfallibleTArray<nsCString>&& aArgv,
|
|||
|
||||
SendLoadComplete(mPeerPid, aCookie);
|
||||
|
||||
MessageLoop::current()->PostTask(FROM_HERE,
|
||||
NewRunnableFunction(_ProcLoaderChildDestroy,
|
||||
this));
|
||||
MessageLoop::current()->PostTask(
|
||||
NewRunnableFunction(_ProcLoaderChildDestroy, this));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -510,9 +507,8 @@ ProcLoaderChild::OnChannelError()
|
|||
MOZ_ASSERT(sProcLoaderDispatchedTask == nullptr);
|
||||
sProcLoaderDispatchedTask = new ProcLoaderNoopRunner();
|
||||
|
||||
MessageLoop::current()->PostTask(FROM_HERE,
|
||||
NewRunnableFunction(_ProcLoaderChildDestroy,
|
||||
this));
|
||||
MessageLoop::current()->PostTask(
|
||||
NewRunnableFunction(_ProcLoaderChildDestroy, this));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -218,8 +218,8 @@ DaemonSocket::SendSocketData(UnixSocketIOBuffer* aBuffer)
|
|||
MOZ_ASSERT(mIO->IsConsumerThread());
|
||||
|
||||
mIO->GetIOLoop()->PostTask(
|
||||
FROM_HERE,
|
||||
new SocketIOSendTask<DaemonSocketIO, UnixSocketIOBuffer>(mIO, aBuffer));
|
||||
MakeAndAddRef<SocketIOSendTask<DaemonSocketIO, UnixSocketIOBuffer>>(
|
||||
mIO, aBuffer));
|
||||
}
|
||||
|
||||
// |SocketBase|
|
||||
|
@ -235,7 +235,7 @@ DaemonSocket::Close()
|
|||
MOZ_ASSERT(mIO->IsConsumerThread());
|
||||
|
||||
mIO->ShutdownOnConsumerThread();
|
||||
mIO->GetIOLoop()->PostTask(FROM_HERE, new SocketIOShutdownTask(mIO));
|
||||
mIO->GetIOLoop()->PostTask(MakeAndAddRef<SocketIOShutdownTask>(mIO));
|
||||
mIO = nullptr;
|
||||
|
||||
NotifyDisconnect();
|
||||
|
|
|
@ -217,8 +217,7 @@ NetdClient::Start()
|
|||
}
|
||||
|
||||
MessageLoopForIO::current()->
|
||||
PostDelayedTask(FROM_HERE,
|
||||
NewRunnableFunction(NetdClient::Start),
|
||||
PostDelayedTask(NewRunnableFunction(NetdClient::Start),
|
||||
1000);
|
||||
return;
|
||||
}
|
||||
|
@ -334,7 +333,6 @@ StartNetd(NetdConsumer* aNetdConsumer)
|
|||
|
||||
gNetdConsumer = aNetdConsumer;
|
||||
XRE_GetIOMessageLoop()->PostTask(
|
||||
FROM_HERE,
|
||||
NewRunnableFunction(InitNetdIOThread));
|
||||
}
|
||||
|
||||
|
@ -347,7 +345,6 @@ StopNetd()
|
|||
NS_ASSERTION(currentThread, "This should never be null!");
|
||||
|
||||
XRE_GetIOMessageLoop()->PostTask(
|
||||
FROM_HERE,
|
||||
NewRunnableFunction(ShutdownNetdIOThread));
|
||||
|
||||
while (gNetdConsumer) {
|
||||
|
@ -370,7 +367,6 @@ SendNetdCommand(NetdCommand* aMessage)
|
|||
MOZ_ASSERT(aMessage);
|
||||
|
||||
XRE_GetIOMessageLoop()->PostTask(
|
||||
FROM_HERE,
|
||||
NewRunnableFunction(NetdClient::SendNetdCommandIOThread, aMessage));
|
||||
}
|
||||
|
||||
|
|
|
@ -37,9 +37,9 @@ public:
|
|||
virtual void MessageReceived(NetdCommand* aMessage) = 0;
|
||||
};
|
||||
|
||||
class NetdWriteTask : public Task
|
||||
class NetdWriteTask : public Runnable
|
||||
{
|
||||
virtual void Run();
|
||||
NS_IMETHOD Run();
|
||||
};
|
||||
|
||||
class NetdClient : public MessageLoopForIO::LineWatcher
|
||||
|
|
|
@ -44,7 +44,7 @@ public:
|
|||
// Delayed-task handling
|
||||
//
|
||||
|
||||
void SetDelayedConnectTask(CancelableTask* aTask);
|
||||
void SetDelayedConnectTask(CancelableRunnable* aTask);
|
||||
void ClearDelayedConnectTask();
|
||||
void CancelDelayedConnectTask();
|
||||
|
||||
|
@ -88,7 +88,7 @@ private:
|
|||
* Task member for delayed connect task. Should only be access on consumer
|
||||
* thread.
|
||||
*/
|
||||
CancelableTask* mDelayedConnectTask;
|
||||
CancelableRunnable* mDelayedConnectTask;
|
||||
|
||||
/**
|
||||
* I/O buffer for received data
|
||||
|
@ -134,7 +134,7 @@ RilSocketIO::GetDataSocket()
|
|||
}
|
||||
|
||||
void
|
||||
RilSocketIO::SetDelayedConnectTask(CancelableTask* aTask)
|
||||
RilSocketIO::SetDelayedConnectTask(CancelableRunnable* aTask)
|
||||
{
|
||||
MOZ_ASSERT(IsConsumerThread());
|
||||
|
||||
|
@ -281,12 +281,14 @@ public:
|
|||
: SocketIOTask<RilSocketIO>(aIO)
|
||||
{ }
|
||||
|
||||
void Run() override
|
||||
NS_IMETHOD Run() override
|
||||
{
|
||||
MOZ_ASSERT(!GetIO()->IsConsumerThread());
|
||||
MOZ_ASSERT(!IsCanceled());
|
||||
|
||||
GetIO()->Connect();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -298,21 +300,23 @@ public:
|
|||
: SocketIOTask<RilSocketIO>(aIO)
|
||||
{ }
|
||||
|
||||
void Run() override
|
||||
NS_IMETHOD Run() override
|
||||
{
|
||||
MOZ_ASSERT(GetIO()->IsConsumerThread());
|
||||
|
||||
if (IsCanceled()) {
|
||||
return;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
RilSocketIO* io = GetIO();
|
||||
if (io->IsShutdownOnConsumerThread()) {
|
||||
return;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
io->ClearDelayedConnectTask();
|
||||
io->GetIOLoop()->PostTask(FROM_HERE, new ConnectTask(io));
|
||||
io->GetIOLoop()->PostTask(MakeAndAddRef<ConnectTask>(io));
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -357,12 +361,12 @@ RilSocket::Connect(UnixSocketConnector* aConnector, int aDelayMs,
|
|||
SetConnectionStatus(SOCKET_CONNECTING);
|
||||
|
||||
if (aDelayMs > 0) {
|
||||
RilSocketIO::DelayedConnectTask* connectTask =
|
||||
new RilSocketIO::DelayedConnectTask(mIO);
|
||||
RefPtr<RilSocketIO::DelayedConnectTask> connectTask =
|
||||
MakeAndAddRef<RilSocketIO::DelayedConnectTask>(mIO);
|
||||
mIO->SetDelayedConnectTask(connectTask);
|
||||
MessageLoop::current()->PostDelayedTask(FROM_HERE, connectTask, aDelayMs);
|
||||
MessageLoop::current()->PostDelayedTask(connectTask.forget(), aDelayMs);
|
||||
} else {
|
||||
aIOLoop->PostTask(FROM_HERE, new RilSocketIO::ConnectTask(mIO));
|
||||
aIOLoop->PostTask(MakeAndAddRef<RilSocketIO::ConnectTask>(mIO));
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
|
@ -396,8 +400,7 @@ RilSocket::SendSocketData(UnixSocketIOBuffer* aBuffer)
|
|||
MOZ_ASSERT(!mIO->IsShutdownOnConsumerThread());
|
||||
|
||||
mIO->GetIOLoop()->PostTask(
|
||||
FROM_HERE,
|
||||
new SocketIOSendTask<RilSocketIO, UnixSocketIOBuffer>(mIO, aBuffer));
|
||||
MakeAndAddRef<SocketIOSendTask<RilSocketIO, UnixSocketIOBuffer>>(mIO, aBuffer));
|
||||
}
|
||||
|
||||
// |SocketBase|
|
||||
|
@ -414,7 +417,7 @@ RilSocket::Close()
|
|||
// the relationship here so any future calls to |Connect| will create
|
||||
// a new I/O object.
|
||||
mIO->ShutdownOnConsumerThread();
|
||||
mIO->GetIOLoop()->PostTask(FROM_HERE, new SocketIOShutdownTask(mIO));
|
||||
mIO->GetIOLoop()->PostTask(MakeAndAddRef<SocketIOShutdownTask>(mIO));
|
||||
mIO = nullptr;
|
||||
|
||||
NotifyDisconnect();
|
||||
|
|
|
@ -86,7 +86,7 @@ ConnectionOrientedSocketIO::Connect()
|
|||
if (NS_FAILED(rv)) {
|
||||
// Tell the consumer thread we've errored
|
||||
GetConsumerThread()->PostTask(
|
||||
FROM_HERE, new SocketEventTask(this, SocketEventTask::CONNECT_ERROR));
|
||||
MakeAndAddRef<SocketEventTask>(this, SocketEventTask::CONNECT_ERROR));
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
|
@ -153,7 +153,7 @@ ConnectionOrientedSocketIO::OnConnected()
|
|||
MOZ_ASSERT(GetConnectionStatus() == SOCKET_IS_CONNECTED);
|
||||
|
||||
GetConsumerThread()->PostTask(
|
||||
FROM_HERE, new SocketEventTask(this, SocketEventTask::CONNECT_SUCCESS));
|
||||
MakeAndAddRef<SocketEventTask>(this, SocketEventTask::CONNECT_SUCCESS));
|
||||
|
||||
AddWatchers(READ_WATCHER, true);
|
||||
if (HasPendingData()) {
|
||||
|
@ -181,7 +181,7 @@ ConnectionOrientedSocketIO::OnError(const char* aFunction, int aErrno)
|
|||
|
||||
// Tell the consumer thread we've errored
|
||||
GetConsumerThread()->PostTask(
|
||||
FROM_HERE, new SocketEventTask(this, SocketEventTask::CONNECT_ERROR));
|
||||
MakeAndAddRef<SocketEventTask>(this, SocketEventTask::CONNECT_ERROR));
|
||||
}
|
||||
|
||||
//
|
||||
|
|
|
@ -53,8 +53,8 @@ DataSocketIO::ReceiveData(int aFd)
|
|||
nsresult rv = QueryReceiveBuffer(&incoming);
|
||||
if (NS_FAILED(rv)) {
|
||||
/* an error occured */
|
||||
GetConsumerThread()->PostTask(FROM_HERE,
|
||||
new SocketRequestClosingTask(this));
|
||||
GetConsumerThread()->PostTask(
|
||||
MakeAndAddRef<SocketRequestClosingTask>(this));
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -62,14 +62,14 @@ DataSocketIO::ReceiveData(int aFd)
|
|||
if (res < 0) {
|
||||
/* an I/O error occured */
|
||||
DiscardBuffer();
|
||||
GetConsumerThread()->PostTask(FROM_HERE,
|
||||
new SocketRequestClosingTask(this));
|
||||
GetConsumerThread()->PostTask(
|
||||
MakeAndAddRef<SocketRequestClosingTask>(this));
|
||||
return -1;
|
||||
} else if (!res) {
|
||||
/* EOF or peer shut down sending */
|
||||
DiscardBuffer();
|
||||
GetConsumerThread()->PostTask(FROM_HERE,
|
||||
new SocketRequestClosingTask(this));
|
||||
GetConsumerThread()->PostTask(
|
||||
MakeAndAddRef<SocketRequestClosingTask>(this));
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -96,8 +96,8 @@ DataSocketIO::SendPendingData(int aFd)
|
|||
ssize_t res = outgoing->Send(aFd);
|
||||
if (res < 0) {
|
||||
/* an I/O error occured */
|
||||
GetConsumerThread()->PostTask(FROM_HERE,
|
||||
new SocketRequestClosingTask(this));
|
||||
GetConsumerThread()->PostTask(
|
||||
MakeAndAddRef<SocketRequestClosingTask>(this));
|
||||
return NS_ERROR_FAILURE;
|
||||
} else if (!res && outgoing->GetSize()) {
|
||||
/* I/O is currently blocked; try again later */
|
||||
|
|
|
@ -122,7 +122,7 @@ public:
|
|||
MOZ_ASSERT(aData);
|
||||
}
|
||||
|
||||
void Run() override
|
||||
NS_IMETHOD Run() override
|
||||
{
|
||||
MOZ_ASSERT(!SocketIOTask<Tio>::IsCanceled());
|
||||
|
||||
|
@ -131,6 +131,8 @@ public:
|
|||
MOZ_ASSERT(!io->IsShutdownOnIOThread());
|
||||
|
||||
io->Send(mData);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
private:
|
||||
|
|
|
@ -175,7 +175,7 @@ ListenSocketIO::OnListening()
|
|||
|
||||
/* We signal a successful 'connection' to a local address for listening. */
|
||||
GetConsumerThread()->PostTask(
|
||||
FROM_HERE, new SocketEventTask(this, SocketEventTask::CONNECT_SUCCESS));
|
||||
MakeAndAddRef<SocketEventTask>(this, SocketEventTask::CONNECT_SUCCESS));
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -197,7 +197,7 @@ ListenSocketIO::FireSocketError()
|
|||
|
||||
// Tell the consumer thread we've errored
|
||||
GetConsumerThread()->PostTask(
|
||||
FROM_HERE, new SocketEventTask(this, SocketEventTask::CONNECT_ERROR));
|
||||
MakeAndAddRef<SocketEventTask>(this, SocketEventTask::CONNECT_ERROR));
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -289,13 +289,14 @@ public:
|
|||
MOZ_COUNT_DTOR(ListenTask);
|
||||
}
|
||||
|
||||
void Run() override
|
||||
NS_IMETHOD Run() override
|
||||
{
|
||||
MOZ_ASSERT(!GetIO()->IsConsumerThread());
|
||||
|
||||
if (!IsCanceled()) {
|
||||
GetIO()->Listen(mCOSocketIO);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -382,7 +383,7 @@ ListenSocket::Listen(ConnectionOrientedSocket* aCOSocket)
|
|||
SetConnectionStatus(SOCKET_LISTENING);
|
||||
|
||||
mIO->GetIOLoop()->PostTask(
|
||||
FROM_HERE, new ListenSocketIO::ListenTask(mIO, io));
|
||||
MakeAndAddRef<ListenSocketIO::ListenTask>(mIO, io));
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -402,7 +403,7 @@ ListenSocket::Close()
|
|||
// the relationship here so any future calls to listen or connect
|
||||
// will create a new implementation.
|
||||
mIO->ShutdownOnConsumerThread();
|
||||
mIO->GetIOLoop()->PostTask(FROM_HERE, new SocketIOShutdownTask(mIO));
|
||||
mIO->GetIOLoop()->PostTask(MakeAndAddRef<SocketIOShutdownTask>(mIO));
|
||||
mIO = nullptr;
|
||||
|
||||
NotifyDisconnect();
|
||||
|
|
|
@ -326,7 +326,7 @@ SocketEventTask::~SocketEventTask()
|
|||
MOZ_COUNT_DTOR(SocketEventTask);
|
||||
}
|
||||
|
||||
void
|
||||
NS_IMETHODIMP
|
||||
SocketEventTask::Run()
|
||||
{
|
||||
SocketIOBase* io = SocketTask<SocketIOBase>::GetIO();
|
||||
|
@ -336,7 +336,7 @@ SocketEventTask::Run()
|
|||
if (NS_WARN_IF(io->IsShutdownOnConsumerThread())) {
|
||||
// Since we've already explicitly closed and the close
|
||||
// happened before this, this isn't really an error.
|
||||
return;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
SocketBase* socketBase = io->GetSocketBase();
|
||||
|
@ -349,6 +349,8 @@ SocketEventTask::Run()
|
|||
} else if (mEvent == DISCONNECT) {
|
||||
socketBase->NotifyDisconnect();
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -366,7 +368,7 @@ SocketRequestClosingTask::~SocketRequestClosingTask()
|
|||
MOZ_COUNT_DTOR(SocketRequestClosingTask);
|
||||
}
|
||||
|
||||
void
|
||||
NS_IMETHODIMP
|
||||
SocketRequestClosingTask::Run()
|
||||
{
|
||||
SocketIOBase* io = SocketTask<SocketIOBase>::GetIO();
|
||||
|
@ -376,13 +378,15 @@ SocketRequestClosingTask::Run()
|
|||
if (NS_WARN_IF(io->IsShutdownOnConsumerThread())) {
|
||||
// Since we've already explicitly closed and the close
|
||||
// happened before this, this isn't really an error.
|
||||
return;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
SocketBase* socketBase = io->GetSocketBase();
|
||||
MOZ_ASSERT(socketBase);
|
||||
|
||||
socketBase->Close();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -400,10 +404,11 @@ SocketDeleteInstanceTask::~SocketDeleteInstanceTask()
|
|||
MOZ_COUNT_DTOR(SocketDeleteInstanceTask);
|
||||
}
|
||||
|
||||
void
|
||||
NS_IMETHODIMP
|
||||
SocketDeleteInstanceTask::Run()
|
||||
{
|
||||
mIO.reset(); // delete instance
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -421,7 +426,7 @@ SocketIOShutdownTask::~SocketIOShutdownTask()
|
|||
MOZ_COUNT_DTOR(SocketIOShutdownTask);
|
||||
}
|
||||
|
||||
void
|
||||
NS_IMETHODIMP
|
||||
SocketIOShutdownTask::Run()
|
||||
{
|
||||
SocketIOBase* io = SocketIOTask<SocketIOBase>::GetIO();
|
||||
|
@ -435,8 +440,9 @@ SocketIOShutdownTask::Run()
|
|||
// shut down, so we can send a message to the consumer thread to
|
||||
// delete |io| safely knowing that it's not reference any longer.
|
||||
io->ShutdownOnIOThread();
|
||||
io->GetConsumerThread()->PostTask(FROM_HERE,
|
||||
new SocketDeleteInstanceTask(io));
|
||||
io->GetConsumerThread()->PostTask(
|
||||
MakeAndAddRef<SocketDeleteInstanceTask>(io));
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -453,7 +453,7 @@ private:
|
|||
* the I/O thread to the consumer thread.
|
||||
*/
|
||||
template <typename T>
|
||||
class SocketTask : public Task
|
||||
class SocketTask : public Runnable
|
||||
{
|
||||
public:
|
||||
virtual ~SocketTask()
|
||||
|
@ -491,7 +491,7 @@ public:
|
|||
SocketEventTask(SocketIOBase* aIO, SocketEvent aEvent);
|
||||
~SocketEventTask();
|
||||
|
||||
void Run() override;
|
||||
NS_IMETHOD Run() override;
|
||||
|
||||
private:
|
||||
SocketEvent mEvent;
|
||||
|
@ -507,19 +507,19 @@ public:
|
|||
SocketRequestClosingTask(SocketIOBase* aIO);
|
||||
~SocketRequestClosingTask();
|
||||
|
||||
void Run() override;
|
||||
NS_IMETHOD Run() override;
|
||||
};
|
||||
|
||||
/**
|
||||
* |SocketDeleteInstanceTask| deletes an object on the consumer thread.
|
||||
*/
|
||||
class SocketDeleteInstanceTask final : public Task
|
||||
class SocketDeleteInstanceTask final : public Runnable
|
||||
{
|
||||
public:
|
||||
SocketDeleteInstanceTask(SocketIOBase* aIO);
|
||||
~SocketDeleteInstanceTask();
|
||||
|
||||
void Run() override;
|
||||
NS_IMETHOD Run() override;
|
||||
|
||||
private:
|
||||
UniquePtr<SocketIOBase> mIO;
|
||||
|
@ -533,7 +533,7 @@ private:
|
|||
* supposed to run on the I/O thread.
|
||||
*/
|
||||
template<typename Tio>
|
||||
class SocketIOTask : public CancelableTask
|
||||
class SocketIOTask : public CancelableRunnable
|
||||
{
|
||||
public:
|
||||
virtual ~SocketIOTask()
|
||||
|
@ -544,9 +544,10 @@ public:
|
|||
return mIO;
|
||||
}
|
||||
|
||||
void Cancel() override
|
||||
nsresult Cancel() override
|
||||
{
|
||||
mIO = nullptr;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
bool IsCanceled() const
|
||||
|
@ -575,7 +576,7 @@ public:
|
|||
SocketIOShutdownTask(SocketIOBase* aIO);
|
||||
~SocketIOShutdownTask();
|
||||
|
||||
void Run() override;
|
||||
NS_IMETHOD Run() override;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@ public:
|
|||
// Delayed-task handling
|
||||
//
|
||||
|
||||
void SetDelayedConnectTask(CancelableTask* aTask);
|
||||
void SetDelayedConnectTask(CancelableRunnable* aTask);
|
||||
void ClearDelayedConnectTask();
|
||||
void CancelDelayedConnectTask();
|
||||
|
||||
|
@ -84,7 +84,7 @@ private:
|
|||
* Task member for delayed connect task. Should only be access on consumer
|
||||
* thread.
|
||||
*/
|
||||
CancelableTask* mDelayedConnectTask;
|
||||
CancelableRunnable* mDelayedConnectTask;
|
||||
|
||||
/**
|
||||
* I/O buffer for received data
|
||||
|
@ -146,7 +146,7 @@ StreamSocketIO::GetDataSocket()
|
|||
}
|
||||
|
||||
void
|
||||
StreamSocketIO::SetDelayedConnectTask(CancelableTask* aTask)
|
||||
StreamSocketIO::SetDelayedConnectTask(CancelableRunnable* aTask)
|
||||
{
|
||||
MOZ_ASSERT(IsConsumerThread());
|
||||
|
||||
|
@ -208,7 +208,7 @@ public:
|
|||
MOZ_COUNT_DTOR(ReceiveTask);
|
||||
}
|
||||
|
||||
void Run() override
|
||||
NS_IMETHOD Run() override
|
||||
{
|
||||
StreamSocketIO* io = SocketTask<StreamSocketIO>::GetIO();
|
||||
|
||||
|
@ -217,13 +217,15 @@ public:
|
|||
if (NS_WARN_IF(io->IsShutdownOnConsumerThread())) {
|
||||
// Since we've already explicitly closed and the close
|
||||
// happened before this, this isn't really an error.
|
||||
return;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
StreamSocket* streamSocket = io->GetStreamSocket();
|
||||
MOZ_ASSERT(streamSocket);
|
||||
|
||||
streamSocket->ReceiveSocketData(mBuffer);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -233,8 +235,8 @@ private:
|
|||
void
|
||||
StreamSocketIO::ConsumeBuffer()
|
||||
{
|
||||
GetConsumerThread()->PostTask(FROM_HERE,
|
||||
new ReceiveTask(this, mBuffer.release()));
|
||||
GetConsumerThread()->PostTask(
|
||||
MakeAndAddRef<ReceiveTask>(this, mBuffer.release()));
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -302,12 +304,14 @@ public:
|
|||
MOZ_COUNT_DTOR(ReceiveTask);
|
||||
}
|
||||
|
||||
void Run() override
|
||||
NS_IMETHOD Run() override
|
||||
{
|
||||
MOZ_ASSERT(!GetIO()->IsConsumerThread());
|
||||
MOZ_ASSERT(!IsCanceled());
|
||||
|
||||
GetIO()->Connect();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -326,21 +330,23 @@ public:
|
|||
MOZ_COUNT_DTOR(DelayedConnectTask);
|
||||
}
|
||||
|
||||
void Run() override
|
||||
NS_IMETHOD Run() override
|
||||
{
|
||||
MOZ_ASSERT(GetIO()->IsConsumerThread());
|
||||
|
||||
if (IsCanceled()) {
|
||||
return;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
StreamSocketIO* io = GetIO();
|
||||
if (io->IsShutdownOnConsumerThread()) {
|
||||
return;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
io->ClearDelayedConnectTask();
|
||||
io->GetIOLoop()->PostTask(FROM_HERE, new ConnectTask(io));
|
||||
io->GetIOLoop()->PostTask(MakeAndAddRef<ConnectTask>(io));
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -381,12 +387,12 @@ StreamSocket::Connect(UnixSocketConnector* aConnector, int aDelayMs,
|
|||
SetConnectionStatus(SOCKET_CONNECTING);
|
||||
|
||||
if (aDelayMs > 0) {
|
||||
StreamSocketIO::DelayedConnectTask* connectTask =
|
||||
new StreamSocketIO::DelayedConnectTask(mIO);
|
||||
RefPtr<StreamSocketIO::DelayedConnectTask> connectTask =
|
||||
MakeAndAddRef<StreamSocketIO::DelayedConnectTask>(mIO);
|
||||
mIO->SetDelayedConnectTask(connectTask);
|
||||
MessageLoop::current()->PostDelayedTask(FROM_HERE, connectTask, aDelayMs);
|
||||
MessageLoop::current()->PostDelayedTask(connectTask.forget(), aDelayMs);
|
||||
} else {
|
||||
aIOLoop->PostTask(FROM_HERE, new StreamSocketIO::ConnectTask(mIO));
|
||||
aIOLoop->PostTask(MakeAndAddRef<StreamSocketIO::ConnectTask>(mIO));
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
|
@ -430,8 +436,8 @@ StreamSocket::SendSocketData(UnixSocketIOBuffer* aBuffer)
|
|||
MOZ_ASSERT(!mIO->IsShutdownOnConsumerThread());
|
||||
|
||||
mIO->GetIOLoop()->PostTask(
|
||||
FROM_HERE,
|
||||
new SocketIOSendTask<StreamSocketIO, UnixSocketIOBuffer>(mIO, aBuffer));
|
||||
MakeAndAddRef<SocketIOSendTask<StreamSocketIO, UnixSocketIOBuffer>>(
|
||||
mIO, aBuffer));
|
||||
}
|
||||
|
||||
// |SocketBase|
|
||||
|
@ -448,7 +454,7 @@ StreamSocket::Close()
|
|||
// the relationship here so any future calls to |Connect| will create
|
||||
// a new I/O object.
|
||||
mIO->ShutdownOnConsumerThread();
|
||||
mIO->GetIOLoop()->PostTask(FROM_HERE, new SocketIOShutdownTask(mIO));
|
||||
mIO->GetIOLoop()->PostTask(MakeAndAddRef<SocketIOShutdownTask>(mIO));
|
||||
mIO = nullptr;
|
||||
|
||||
NotifyDisconnect();
|
||||
|
|
|
@ -443,14 +443,15 @@ FakeSurfaceComposer::captureScreen(const sp<IBinder>& display
|
|||
return result;
|
||||
}
|
||||
|
||||
class RunnableCallTask : public Task {
|
||||
class RunnableCallTask final : public Runnable
|
||||
{
|
||||
public:
|
||||
explicit RunnableCallTask(nsIRunnable* aRunnable)
|
||||
: mRunnable(aRunnable) {}
|
||||
|
||||
void Run() override
|
||||
NS_IMETHOD Run() override
|
||||
{
|
||||
mRunnable->Run();
|
||||
return mRunnable->Run();
|
||||
}
|
||||
protected:
|
||||
nsCOMPtr<nsIRunnable> mRunnable;
|
||||
|
@ -525,7 +526,7 @@ FakeSurfaceComposer::captureScreenImp(const sp<IGraphicBufferProducer>& producer
|
|||
});
|
||||
|
||||
mozilla::layers::CompositorBridgeParent::CompositorLoop()->PostTask(
|
||||
FROM_HERE, new RunnableCallTask(runnable));
|
||||
MakeAndAddRef<RunnableCallTask>(runnable));
|
||||
}
|
||||
|
||||
#if ANDROID_VERSION >= 21
|
||||
|
|
|
@ -408,9 +408,10 @@ status_t GonkBufferQueue::dequeueBuffer(int *outBuf, sp<Fence>* outFence,
|
|||
if (mSlots[buf].mTextureClient) {
|
||||
mSlots[buf].mTextureClient->ClearRecycleCallback();
|
||||
// release TextureClient in ImageBridge thread
|
||||
TextureClientReleaseTask* task = new TextureClientReleaseTask(mSlots[buf].mTextureClient);
|
||||
RefPtr<TextureClientReleaseTask> task =
|
||||
MakeAndAddRef<TextureClientReleaseTask>(mSlots[buf].mTextureClient);
|
||||
mSlots[buf].mTextureClient = NULL;
|
||||
ImageBridgeChild::GetSingleton()->GetMessageLoop()->PostTask(FROM_HERE, task);
|
||||
ImageBridgeChild::GetSingleton()->GetMessageLoop()->PostTask(task.forget());
|
||||
}
|
||||
returnFlags |= IGraphicBufferProducer::BUFFER_NEEDS_REALLOCATION;
|
||||
}
|
||||
|
@ -782,9 +783,10 @@ void GonkBufferQueue::freeAllBuffersLocked()
|
|||
if (mSlots[i].mTextureClient) {
|
||||
mSlots[i].mTextureClient->ClearRecycleCallback();
|
||||
// release TextureClient in ImageBridge thread
|
||||
TextureClientReleaseTask* task = new TextureClientReleaseTask(mSlots[i].mTextureClient);
|
||||
RefPtr<TextureClientReleaseTask> task =
|
||||
MakeAndAddRef<TextureClientReleaseTask>(mSlots[i].mTextureClient);
|
||||
mSlots[i].mTextureClient = NULL;
|
||||
ImageBridgeChild::GetSingleton()->GetMessageLoop()->PostTask(FROM_HERE, task);
|
||||
ImageBridgeChild::GetSingleton()->GetMessageLoop()->PostTask(task.forget());
|
||||
}
|
||||
if (mSlots[i].mBufferState == BufferSlot::ACQUIRED) {
|
||||
mSlots[i].mNeedsCleanupOnRelease = true;
|
||||
|
|
|
@ -423,9 +423,10 @@ status_t GonkBufferQueue::dequeueBuffer(int *outBuf, sp<Fence>* outFence, bool a
|
|||
if (mSlots[buf].mTextureClient) {
|
||||
mSlots[buf].mTextureClient->ClearRecycleCallback();
|
||||
// release TextureClient in ImageBridge thread
|
||||
TextureClientReleaseTask* task = new TextureClientReleaseTask(mSlots[buf].mTextureClient);
|
||||
RefPtr<TextureClientReleaseTask> task =
|
||||
MakeAndAddRef<TextureClientReleaseTask>(mSlots[buf].mTextureClient);
|
||||
mSlots[buf].mTextureClient = NULL;
|
||||
ImageBridgeChild::GetSingleton()->GetMessageLoop()->PostTask(FROM_HERE, task);
|
||||
ImageBridgeChild::GetSingleton()->GetMessageLoop()->PostTask(task.forget());
|
||||
}
|
||||
returnFlags |= IGraphicBufferProducer::BUFFER_NEEDS_REALLOCATION;
|
||||
}
|
||||
|
@ -869,9 +870,10 @@ void GonkBufferQueue::freeAllBuffersLocked()
|
|||
if (mSlots[i].mTextureClient) {
|
||||
mSlots[i].mTextureClient->ClearRecycleCallback();
|
||||
// release TextureClient in ImageBridge thread
|
||||
TextureClientReleaseTask* task = new TextureClientReleaseTask(mSlots[i].mTextureClient);
|
||||
RefPtr<TextureClientReleaseTask> task =
|
||||
MakeAndAddRef<TextureClientReleaseTask>(mSlots[i].mTextureClient);
|
||||
mSlots[i].mTextureClient = NULL;
|
||||
ImageBridgeChild::GetSingleton()->GetMessageLoop()->PostTask(FROM_HERE, task);
|
||||
ImageBridgeChild::GetSingleton()->GetMessageLoop()->PostTask(task.forget());
|
||||
}
|
||||
if (mSlots[i].mBufferState == BufferSlot::ACQUIRED) {
|
||||
mSlots[i].mNeedsCleanupOnRelease = true;
|
||||
|
|
|
@ -190,9 +190,10 @@ void GonkBufferQueueCore::freeBufferLocked(int slot) {
|
|||
if (mSlots[slot].mTextureClient) {
|
||||
mSlots[slot].mTextureClient->ClearRecycleCallback();
|
||||
// release TextureClient in ImageBridge thread
|
||||
TextureClientReleaseTask* task = new TextureClientReleaseTask(mSlots[slot].mTextureClient);
|
||||
RefPtr<TextureClientReleaseTask> task =
|
||||
MakeAndAddRef<TextureClientReleaseTask>(mSlots[slot].mTextureClient);
|
||||
mSlots[slot].mTextureClient = NULL;
|
||||
ImageBridgeChild::GetSingleton()->GetMessageLoop()->PostTask(FROM_HERE, task);
|
||||
ImageBridgeChild::GetSingleton()->GetMessageLoop()->PostTask(task.forget());
|
||||
}
|
||||
mSlots[slot].mGraphicBuffer.clear();
|
||||
if (mSlots[slot].mBufferState == GonkBufferSlot::ACQUIRED) {
|
||||
|
|
|
@ -322,9 +322,10 @@ status_t GonkBufferQueueProducer::dequeueBuffer(int *outSlot,
|
|||
if (mSlots[found].mTextureClient) {
|
||||
mSlots[found].mTextureClient->ClearRecycleCallback();
|
||||
// release TextureClient in ImageBridge thread
|
||||
TextureClientReleaseTask* task = new TextureClientReleaseTask(mSlots[found].mTextureClient);
|
||||
RefPtr<TextureClientReleaseTask> task =
|
||||
MakeAndAddRef<TextureClientReleaseTask>(mSlots[found].mTextureClient);
|
||||
mSlots[found].mTextureClient = NULL;
|
||||
ImageBridgeChild::GetSingleton()->GetMessageLoop()->PostTask(FROM_HERE, task);
|
||||
ImageBridgeChild::GetSingleton()->GetMessageLoop()->PostTask(task.forget());
|
||||
}
|
||||
|
||||
returnFlags |= BUFFER_NEEDS_REALLOCATION;
|
||||
|
|
|
@ -72,9 +72,10 @@ void GonkNativeWindow::freeAllBuffersLocked()
|
|||
if (mSlots[i].mTextureClient) {
|
||||
mSlots[i].mTextureClient->ClearRecycleCallback();
|
||||
// release TextureClient in ImageBridge thread
|
||||
TextureClientReleaseTask* task = new TextureClientReleaseTask(mSlots[i].mTextureClient);
|
||||
RefPtr<TextureClientReleaseTask> task =
|
||||
MakeAndAddRef<TextureClientReleaseTask>(mSlots[i].mTextureClient);
|
||||
mSlots[i].mTextureClient = NULL;
|
||||
ImageBridgeChild::GetSingleton()->GetMessageLoop()->PostTask(FROM_HERE, task);
|
||||
ImageBridgeChild::GetSingleton()->GetMessageLoop()->PostTask(task.forget());
|
||||
}
|
||||
mSlots[i].mGraphicBuffer = NULL;
|
||||
mSlots[i].mBufferState = BufferSlot::FREE;
|
||||
|
@ -94,9 +95,10 @@ void GonkNativeWindow::clearRenderingStateBuffersLocked()
|
|||
if (mSlots[i].mTextureClient) {
|
||||
mSlots[i].mTextureClient->ClearRecycleCallback();
|
||||
// release TextureClient in ImageBridge thread
|
||||
TextureClientReleaseTask* task = new TextureClientReleaseTask(mSlots[i].mTextureClient);
|
||||
RefPtr<TextureClientReleaseTask> task =
|
||||
MakeAndAddRef<TextureClientReleaseTask>(mSlots[i].mTextureClient);
|
||||
mSlots[i].mTextureClient = NULL;
|
||||
ImageBridgeChild::GetSingleton()->GetMessageLoop()->PostTask(FROM_HERE, task);
|
||||
ImageBridgeChild::GetSingleton()->GetMessageLoop()->PostTask(task.forget());
|
||||
}
|
||||
mSlots[i].mGraphicBuffer = NULL;
|
||||
mSlots[i].mBufferState = BufferSlot::FREE;
|
||||
|
@ -310,9 +312,10 @@ status_t GonkNativeWindow::dequeueBuffer(int *outBuf, uint32_t w, uint32_t h,
|
|||
if (mSlots[buf].mTextureClient) {
|
||||
mSlots[buf].mTextureClient->ClearRecycleCallback();
|
||||
// release TextureClient in ImageBridge thread
|
||||
TextureClientReleaseTask* task = new TextureClientReleaseTask(mSlots[buf].mTextureClient);
|
||||
RefPtr<TextureClientReleaseTask> task =
|
||||
MakeAndAddRef<TextureClientReleaseTask>(mSlots[buf].mTextureClient);
|
||||
mSlots[buf].mTextureClient = NULL;
|
||||
ImageBridgeChild::GetSingleton()->GetMessageLoop()->PostTask(FROM_HERE, task);
|
||||
ImageBridgeChild::GetSingleton()->GetMessageLoop()->PostTask(task.forget());
|
||||
}
|
||||
alloc = true;
|
||||
}
|
||||
|
|
|
@ -162,7 +162,6 @@ nsScreenGonk::~nsScreenGonk()
|
|||
// Release GLContext on compositor thread
|
||||
if (mGLContext) {
|
||||
CompositorBridgeParent::CompositorLoop()->PostTask(
|
||||
FROM_HERE,
|
||||
NewRunnableFunction(&ReleaseGLContextSync,
|
||||
mGLContext.forget().take()));
|
||||
mGLContext = nullptr;
|
||||
|
@ -669,7 +668,6 @@ nsScreenGonk::EnableMirroring()
|
|||
nsMainThreadPtrHandle<nsScreenGonk> primary =
|
||||
nsMainThreadPtrHandle<nsScreenGonk>(new nsMainThreadPtrHolder<nsScreenGonk>(primaryScreen, false));
|
||||
CompositorBridgeParent::CompositorLoop()->PostTask(
|
||||
FROM_HERE,
|
||||
NewRunnableFunction(&UpdateMirroringWidgetSync,
|
||||
primary,
|
||||
window.forget().take()));
|
||||
|
@ -695,7 +693,6 @@ nsScreenGonk::DisableMirroring()
|
|||
nsMainThreadPtrHandle<nsScreenGonk> primary =
|
||||
nsMainThreadPtrHandle<nsScreenGonk>(new nsMainThreadPtrHolder<nsScreenGonk>(primaryScreen, false));
|
||||
CompositorBridgeParent::CompositorLoop()->PostTask(
|
||||
FROM_HERE,
|
||||
NewRunnableFunction(&UpdateMirroringWidgetSync,
|
||||
primary,
|
||||
nullptr));
|
||||
|
|
|
@ -235,18 +235,18 @@ nsWindow::DispatchTouchEventForAPZ(const MultiTouchInput& aInput,
|
|||
ProcessUntransformedAPZEvent(&event, aGuid, aInputBlockId, aApzResponse);
|
||||
}
|
||||
|
||||
class DispatchTouchInputOnControllerThread : public Task
|
||||
class DispatchTouchInputOnControllerThread : public Runnable
|
||||
{
|
||||
public:
|
||||
DispatchTouchInputOnControllerThread(const MultiTouchInput& aInput)
|
||||
: Task()
|
||||
, mInput(aInput)
|
||||
: mInput(aInput)
|
||||
{}
|
||||
|
||||
virtual void Run() override {
|
||||
NS_IMETHOD Run() override {
|
||||
if (gFocusedWindow) {
|
||||
gFocusedWindow->DispatchTouchInputViaAPZ(mInput);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -325,7 +325,8 @@ nsWindow::SynthesizeNativeTouchPoint(uint32_t aPointerId,
|
|||
// the function performs so this is fine. Also we can't pass |this| to the
|
||||
// task because nsWindow refcounting is not threadsafe. Instead we just use
|
||||
// the gFocusedWindow static ptr instead the task.
|
||||
APZThreadUtils::RunOnControllerThread(new DispatchTouchInputOnControllerThread(inputToDispatch));
|
||||
APZThreadUtils::RunOnControllerThread(
|
||||
MakeAndAddRef<DispatchTouchInputOnControllerThread>(inputToDispatch));
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче