Bug 1232941 - Register Observer and listen to NS_XPCOM_SHUTDOWN_OBSERVER_ID for GATT, r=shuang

--HG--
extra : rebase_source : 98094772547ab8c92498175d2dcef36c715a9ee8
This commit is contained in:
Tom Tung 2015-12-17 09:36:43 +08:00
parent 4f28efc5fe
commit 42f7e0fe4e
2 changed files with 18 additions and 0 deletions

View File

@ -385,10 +385,27 @@ BluetoothGattManager::Get()
// Create a new instance, register, and return
BluetoothGattManager* manager = new BluetoothGattManager();
NS_ENSURE_TRUE(manager->Init(), nullptr);
sBluetoothGattManager = manager;
return sBluetoothGattManager;
}
bool
BluetoothGattManager::Init()
{
MOZ_ASSERT(NS_IsMainThread());
nsCOMPtr<nsIObserverService> obs = services::GetObserverService();
NS_ENSURE_TRUE(obs, false);
if (NS_FAILED(obs->AddObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID, false))) {
BT_WARNING("Failed to add observers!");
return false;
}
return true;
}
class BluetoothGattManager::RegisterModuleResultHandler final
: public BluetoothSetupResultHandler
{

View File

@ -203,6 +203,7 @@ private:
class ServerSendIndicationResultHandler;
BluetoothGattManager();
bool Init();
void HandleShutdown();