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:
Thomas Zimmermann 2015-11-30 12:46:09 +01:00
parent 9b54cf6c5c
commit 63fd9969ce

View File

@ -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)