mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-28 07:13:20 +00:00
Bug 1204497: Complete AVRCP connect/disconnect from separate runnables, r=shuang
A2DP connects and disconnects are completed from a separate result-handler runnable. Dispatching runnables to complete AVRCP (dis-)connects implements the same behavior for AVRCP.
This commit is contained in:
parent
48a8903713
commit
420a083cd5
@ -339,6 +339,23 @@ BluetoothAvrcpManager::HandleShutdown()
|
||||
sBluetoothAvrcpManager = nullptr;
|
||||
}
|
||||
|
||||
class BluetoothAvrcpManager::ConnectRunnable final : public nsRunnable
|
||||
{
|
||||
public:
|
||||
ConnectRunnable(BluetoothAvrcpManager* aManager)
|
||||
: mManager(aManager)
|
||||
{
|
||||
MOZ_ASSERT(mManager);
|
||||
}
|
||||
NS_METHOD Run() override
|
||||
{
|
||||
mManager->OnConnect(EmptyString());
|
||||
return NS_OK;
|
||||
}
|
||||
private:
|
||||
BluetoothAvrcpManager* mManager;
|
||||
};
|
||||
|
||||
void
|
||||
BluetoothAvrcpManager::Connect(const nsAString& aDeviceAddress,
|
||||
BluetoothProfileController* aController)
|
||||
@ -350,11 +367,28 @@ BluetoothAvrcpManager::Connect(const nsAString& aDeviceAddress,
|
||||
// AVRCP doesn't require connecting. We just set the remote address here.
|
||||
mDeviceAddress = aDeviceAddress;
|
||||
mController = aController;
|
||||
|
||||
SetConnected(true);
|
||||
OnConnect(EmptyString());
|
||||
|
||||
NS_DispatchToMainThread(new ConnectRunnable(this));
|
||||
}
|
||||
|
||||
class BluetoothAvrcpManager::DisconnectRunnable final : public nsRunnable
|
||||
{
|
||||
public:
|
||||
DisconnectRunnable(BluetoothAvrcpManager* aManager)
|
||||
: mManager(aManager)
|
||||
{
|
||||
MOZ_ASSERT(mManager);
|
||||
}
|
||||
NS_METHOD Run() override
|
||||
{
|
||||
mManager->OnDisconnect(EmptyString());
|
||||
return NS_OK;
|
||||
}
|
||||
private:
|
||||
BluetoothAvrcpManager* mManager;
|
||||
};
|
||||
|
||||
void
|
||||
BluetoothAvrcpManager::Disconnect(BluetoothProfileController* aController)
|
||||
{
|
||||
@ -362,11 +396,10 @@ BluetoothAvrcpManager::Disconnect(BluetoothProfileController* aController)
|
||||
MOZ_ASSERT(!mController);
|
||||
|
||||
mDeviceAddress.Truncate();
|
||||
|
||||
mController = aController;
|
||||
|
||||
SetConnected(false);
|
||||
OnDisconnect(EmptyString());
|
||||
|
||||
NS_DispatchToMainThread(new DisconnectRunnable(this));
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -62,8 +62,8 @@ protected:
|
||||
private:
|
||||
class CleanupAvrcpResultHandler;
|
||||
class CleanupAvrcpResultHandlerRunnable;
|
||||
class ConnectResultHandler;
|
||||
class DisconnectResultHandler;
|
||||
class ConnectRunnable;
|
||||
class DisconnectRunnable;
|
||||
class InitAvrcpResultHandler;
|
||||
class OnErrorProfileResultHandlerRunnable;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user