Bug 913372 - Patch 2: Set mController to null before invoking callback function, r=echou

For each profile manager, we'd like to make sure that the data member of
mController is nulled out before invoking the callback function. Because, in the
callback function, we continue to handle the next connect/disconnect request,
and we'd like to null out mController of previous request before handling the
new one.
This commit is contained in:
Gina Yeh 2013-10-25 14:21:56 +08:00
parent 34ad62a42a
commit df457d5d1e
6 changed files with 19 additions and 26 deletions

View File

@ -207,8 +207,8 @@ BluetoothA2dpManager::OnConnect(const nsAString& aErrorStr)
*/
NS_ENSURE_TRUE_VOID(mController);
mController->OnConnect(aErrorStr);
mController = nullptr;
nsRefPtr<BluetoothProfileController> controller = mController.forget();
controller->OnConnect(aErrorStr);
}
void
@ -222,8 +222,8 @@ BluetoothA2dpManager::OnDisconnect(const nsAString& aErrorStr)
*/
NS_ENSURE_TRUE_VOID(mController);
mController->OnDisconnect(aErrorStr);
mController = nullptr;
nsRefPtr<BluetoothProfileController> controller = mController.forget();
controller->OnDisconnect(aErrorStr);
}
/* HandleSinkPropertyChanged update sink state in A2dp

View File

@ -342,7 +342,7 @@ Call::IsActive()
/**
* BluetoothHfpManager
*/
BluetoothHfpManager::BluetoothHfpManager()
BluetoothHfpManager::BluetoothHfpManager() : mController(nullptr)
{
Reset();
}
@ -392,11 +392,7 @@ BluetoothHfpManager::Reset()
//
// Please see Bug 878728 for more information.
mBSIR = false;
#endif
mController = nullptr;
#ifdef MOZ_B2G_RIL
ResetCallArray();
#endif
}
@ -1143,7 +1139,6 @@ BluetoothHfpManager::Disconnect(BluetoothProfileController* aController)
mController = aController;
mSocket->Disconnect();
mSocket = nullptr;
}
#ifdef MOZ_B2G_RIL
@ -1710,6 +1705,8 @@ BluetoothHfpManager::OnGetServiceChannel(const nsAString& aDeviceAddress,
return;
}
MOZ_ASSERT(mSocket);
if (!mSocket->Connect(NS_ConvertUTF16toUTF8(aDeviceAddress), aChannel)) {
OnConnect(NS_LITERAL_STRING("SocketConnectionError"));
}
@ -1872,8 +1869,8 @@ BluetoothHfpManager::OnConnect(const nsAString& aErrorStr)
*/
NS_ENSURE_TRUE_VOID(mController);
mController->OnConnect(aErrorStr);
mController = nullptr;
nsRefPtr<BluetoothProfileController> controller = mController.forget();
controller->OnConnect(aErrorStr);
}
void
@ -1891,8 +1888,8 @@ BluetoothHfpManager::OnDisconnect(const nsAString& aErrorStr)
*/
NS_ENSURE_TRUE_VOID(mController);
mController->OnDisconnect(aErrorStr);
mController = nullptr;
nsRefPtr<BluetoothProfileController> controller = mController.forget();
controller->OnDisconnect(aErrorStr);
}
NS_IMPL_ISUPPORTS1(BluetoothHfpManager, nsIObserver)

View File

@ -208,7 +208,6 @@ private:
nsTArray<Call> mCurrentCallArray;
nsAutoPtr<BluetoothRilListener> mListener;
#endif
nsRefPtr<BluetoothReplyRunnable> mRunnable;
nsRefPtr<BluetoothProfileController> mController;
nsRefPtr<BluetoothReplyRunnable> mScoRunnable;

View File

@ -167,8 +167,8 @@ BluetoothHidManager::OnConnect(const nsAString& aErrorStr)
*/
NS_ENSURE_TRUE_VOID(mController);
mController->OnConnect(aErrorStr);
mController = nullptr;
nsRefPtr<BluetoothProfileController> controller = mController.forget();
controller->OnConnect(aErrorStr);
}
void
@ -182,8 +182,8 @@ BluetoothHidManager::OnDisconnect(const nsAString& aErrorStr)
*/
NS_ENSURE_TRUE_VOID(mController);
mController->OnDisconnect(aErrorStr);
mController = nullptr;
nsRefPtr<BluetoothProfileController> controller = mController.forget();
controller->OnDisconnect(aErrorStr);
}
bool

View File

@ -291,7 +291,6 @@ BluetoothOppManager::Disconnect(BluetoothProfileController* aController)
mController = aController;
mSocket->Disconnect();
mSocket = nullptr;
}
void
@ -1483,8 +1482,8 @@ BluetoothOppManager::OnConnect(const nsAString& aErrorStr)
*/
NS_ENSURE_TRUE_VOID(mController);
mController->OnConnect(aErrorStr);
mController = nullptr;
nsRefPtr<BluetoothProfileController> controller = mController.forget();
controller->OnConnect(aErrorStr);
}
void
@ -1501,6 +1500,6 @@ BluetoothOppManager::OnDisconnect(const nsAString& aErrorStr)
*/
NS_ENSURE_TRUE_VOID(mController);
mController->OnDisconnect(aErrorStr);
mController = nullptr;
nsRefPtr<BluetoothProfileController> controller = mController.forget();
controller->OnDisconnect(aErrorStr);
}

View File

@ -21,7 +21,6 @@ class nsIVolumeMountLock;
BEGIN_BLUETOOTH_NAMESPACE
class BluetoothReplyRunnable;
class BluetoothSocket;
class ObexHeaderSet;
@ -218,7 +217,6 @@ private:
nsCOMPtr<nsIOutputStream> mOutputStream;
nsCOMPtr<nsIInputStream> mInputStream;
nsCOMPtr<nsIVolumeMountLock> mMountLock;
nsRefPtr<BluetoothReplyRunnable> mRunnable;
nsRefPtr<BluetoothProfileController> mController;
nsRefPtr<DeviceStorageFile> mDsFile;