mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-09 19:35:51 +00:00
Bug 1228946: Remove '#if 0' block from Bluetooth module, r=joliu
This is a cleanup patch for removing an '#if 0' that was landed in the Bluetooth code.
This commit is contained in:
parent
9b54cf6c5c
commit
63fd9969ce
@ -2008,114 +2008,6 @@ BluetoothDaemonGattInterface::BluetoothDaemonGattInterface(
|
||||
BluetoothDaemonGattInterface::~BluetoothDaemonGattInterface()
|
||||
{ }
|
||||
|
||||
#if 0
|
||||
class BluetoothDaemonGattInterface::InitResultHandler final
|
||||
: public BluetoothSetupResultHandler
|
||||
{
|
||||
public:
|
||||
InitResultHandler(BluetoothGattResultHandler* aRes)
|
||||
: mRes(aRes)
|
||||
{
|
||||
MOZ_ASSERT(mRes);
|
||||
}
|
||||
|
||||
void OnError(BluetoothStatus aStatus) override
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
mRes->OnError(aStatus);
|
||||
}
|
||||
|
||||
void RegisterModule() override
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
mRes->Init();
|
||||
}
|
||||
|
||||
private:
|
||||
RefPtr<BluetoothGattResultHandler> mRes;
|
||||
};
|
||||
|
||||
void
|
||||
BluetoothDaemonGattInterface::Init(
|
||||
BluetoothGattNotificationHandler* aNotificationHandler,
|
||||
BluetoothGattResultHandler* aRes)
|
||||
{
|
||||
// Set notification handler _before_ registering the module. It could
|
||||
// happen that we receive notifications, before the result handler runs.
|
||||
mModule->SetNotificationHandler(aNotificationHandler);
|
||||
|
||||
InitResultHandler* res;
|
||||
|
||||
if (aRes) {
|
||||
res = new InitResultHandler(aRes);
|
||||
} else {
|
||||
// We don't need a result handler if the caller is not interested.
|
||||
res = nullptr;
|
||||
}
|
||||
|
||||
nsresult rv = mModule->RegisterModule(
|
||||
SETUP_SERVICE_ID_GATT, 0x00, BluetoothDaemonGattModule::MAX_NUM_CLIENTS,
|
||||
res);
|
||||
|
||||
if (NS_FAILED(rv) && aRes) {
|
||||
DispatchError(aRes, rv);
|
||||
}
|
||||
}
|
||||
|
||||
class BluetoothDaemonGattInterface::CleanupResultHandler final
|
||||
: public BluetoothSetupResultHandler
|
||||
{
|
||||
public:
|
||||
CleanupResultHandler(BluetoothDaemonGattModule* aModule,
|
||||
BluetoothGattResultHandler* aRes)
|
||||
: mModule(aModule)
|
||||
, mRes(aRes)
|
||||
{
|
||||
MOZ_ASSERT(mModule);
|
||||
}
|
||||
|
||||
void OnError(BluetoothStatus aStatus) override
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
if (mRes) {
|
||||
mRes->OnError(aStatus);
|
||||
}
|
||||
}
|
||||
|
||||
void UnregisterModule() override
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
// Clear notification handler _after_ module has been
|
||||
// unregistered. While unregistering the module, we might
|
||||
// still receive notifications.
|
||||
mModule->SetNotificationHandler(nullptr);
|
||||
|
||||
if (mRes) {
|
||||
mRes->Cleanup();
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
BluetoothDaemonGattModule* mModule;
|
||||
RefPtr<BluetoothGattResultHandler> mRes;
|
||||
};
|
||||
|
||||
void
|
||||
BluetoothDaemonGattInterface::Cleanup(
|
||||
BluetoothGattResultHandler* aRes)
|
||||
{
|
||||
nsresult rv = mModule->UnregisterModule(
|
||||
SETUP_SERVICE_ID_GATT, new CleanupResultHandler(mModule, aRes));
|
||||
if (NS_FAILED(rv)) {
|
||||
DispatchError(aRes, rv);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
BluetoothDaemonGattInterface::SetNotificationHandler(
|
||||
BluetoothGattNotificationHandler* aNotificationHandler)
|
||||
|
Loading…
Reference in New Issue
Block a user