Bug 876823 - Fire DOMRequest.onerror event when Bluetooth*Manager.Connect() fails, r=gyeh

This commit is contained in:
Eric Chou 2013-06-11 18:24:19 +08:00
parent a5fe50957e
commit 0adbf805bd
3 changed files with 25 additions and 8 deletions

View File

@ -1026,15 +1026,22 @@ BluetoothHfpManager::Connect(const nsAString& aDeviceAddress,
{
MOZ_ASSERT(NS_IsMainThread());
NS_ENSURE_FALSE_VOID(gInShutdown);
NS_ENSURE_FALSE_VOID(mSocket);
BluetoothService* bs = BluetoothService::Get();
if (!bs || gInShutdown) {
DispatchBluetoothReply(aRunnable, BluetoothValue(),
NS_LITERAL_STRING(ERR_NO_AVAILABLE_RESOURCE));
return;
}
if (mSocket) {
DispatchBluetoothReply(aRunnable, BluetoothValue(),
NS_LITERAL_STRING(ERR_REACHED_CONNECTION_LIMIT));
return;
}
mNeedsUpdatingSdpRecords = true;
mIsHandsfree = aIsHandsfree;
BluetoothService* bs = BluetoothService::Get();
NS_ENSURE_TRUE_VOID(bs);
nsString uuid;
if (aIsHandsfree) {
BluetoothUuidHelper::GetString(BluetoothServiceClass::HANDSFREE, uuid);

View File

@ -257,10 +257,18 @@ BluetoothOppManager::Connect(const nsAString& aDeviceAddress,
{
MOZ_ASSERT(NS_IsMainThread());
NS_ENSURE_FALSE_VOID(mSocket);
BluetoothService* bs = BluetoothService::Get();
NS_ENSURE_TRUE_VOID(bs);
if (!bs || sInShutdown) {
DispatchBluetoothReply(aRunnable, BluetoothValue(),
NS_LITERAL_STRING(ERR_NO_AVAILABLE_RESOURCE));
return;
}
if (mSocket) {
DispatchBluetoothReply(aRunnable, BluetoothValue(),
NS_LITERAL_STRING(ERR_REACHED_CONNECTION_LIMIT));
return;
}
mNeedsUpdatingSdpRecords = true;

View File

@ -8,6 +8,8 @@
#define mozilla_dom_bluetooth_bluetoothprofilemanagerbase_h__
#define ERR_SERVICE_CHANNEL_NOT_FOUND "DeviceChannelRetrievalError"
#define ERR_REACHED_CONNECTION_LIMIT "ReachedConnectionLimitError"
#define ERR_NO_AVAILABLE_RESOURCE "NoAvailableResourceError"
#include "BluetoothCommon.h"