Bug 904014 - [Bluetooth] [Cleanup] Revise macros in Bluetooth*Manager.cpp under dom/bluetooth, r=echou

This commit is contained in:
Ben Tian 2013-08-13 15:04:34 +08:00
Родитель 9ddf2cea9c
Коммит 64d4f74c1f
5 изменённых файлов: 14 добавлений и 64 удалений

Просмотреть файл

@ -125,10 +125,7 @@ BluetoothA2dpManager::Get()
}
// If we're in shutdown, don't create a new instance
if (sInShutdown) {
NS_WARNING("BluetoothA2dpManager can't be created during shutdown");
return nullptr;
}
NS_ENSURE_FALSE(sInShutdown, nullptr);
// Create a new instance, register, and return
BluetoothA2dpManager* manager = new BluetoothA2dpManager();
@ -153,15 +150,8 @@ BluetoothA2dpManager::Connect(const nsAString& aDeviceAddress)
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(!aDeviceAddress.IsEmpty());
if (sInShutdown) {
NS_WARNING("Connect called while in shutdown!");
return false;
}
if (mA2dpConnected) {
NS_WARNING("BluetoothA2dpManager is connected");
return false;
}
NS_ENSURE_FALSE(sInShutdown, false);
NS_ENSURE_FALSE(mA2dpConnected, false);
mDeviceAddress = aDeviceAddress;
@ -176,10 +166,7 @@ BluetoothA2dpManager::Connect(const nsAString& aDeviceAddress)
void
BluetoothA2dpManager::Disconnect()
{
if (!mA2dpConnected) {
NS_WARNING("BluetoothA2dpManager has been disconnected");
return;
}
NS_ENSURE_TRUE_VOID(mA2dpConnected);
MOZ_ASSERT(!mDeviceAddress.IsEmpty());
@ -203,22 +190,28 @@ BluetoothA2dpManager::HandleSinkPropertyChanged(const BluetoothSignal& aSignal)
if (name.EqualsLiteral("Connected")) {
// Indicates if a stream is setup to a A2DP sink on the remote device.
MOZ_ASSERT(value.type() == BluetoothValue::Tbool);
MOZ_ASSERT(mA2dpConnected != value.get_bool());
mA2dpConnected = value.get_bool();
NotifyConnectionStatusChanged();
DispatchConnectionStatusChanged();
} else if (name.EqualsLiteral("Playing")) {
// Indicates if a stream is active to a A2DP sink on the remote device.
MOZ_ASSERT(value.type() == BluetoothValue::Tbool);
MOZ_ASSERT(mPlaying != value.get_bool());
mPlaying = value.get_bool();
} else if (name.EqualsLiteral("State")) {
MOZ_ASSERT(value.type() == BluetoothValue::TnsString);
MOZ_ASSERT(mSinkState != StatusStringToSinkState(value.get_nsString()));
HandleSinkStateChanged(StatusStringToSinkState(value.get_nsString()));
} else {
NS_WARNING("Unknown sink property");
}
}
/* HandleSinkPropertyChanged update sink state in A2dp
/* HandleSinkStateChanged updates sink state in A2dp
*
* Possible values: "disconnected", "connecting", "connected", "playing"
*

Просмотреть файл

@ -12,8 +12,6 @@
BEGIN_BLUETOOTH_NAMESPACE
class BluetoothA2dpManagerObserver;
class BluetoothA2dpManager : public BluetoothProfileManagerBase
{
public:

Просмотреть файл

@ -440,10 +440,7 @@ BluetoothHfpManager::Get()
}
// If we're in shutdown, don't create a new instance
if (sInShutdown) {
NS_WARNING("BluetoothHfpManager can't be created during shutdown");
return nullptr;
}
NS_ENSURE_FALSE(sInShutdown, nullptr);
// Create a new instance, register, and return
BluetoothHfpManager* manager = new BluetoothHfpManager();

Просмотреть файл

@ -216,10 +216,7 @@ BluetoothOppManager::Get()
}
// If we're in shutdown, don't create a new instance
if (sInShutdown) {
NS_WARNING("BluetoothOppManager can't be created during shutdown");
return nullptr;
}
NS_ENSURE_FALSE(sInShutdown, nullptr);
// Create a new instance, register, and return
BluetoothOppManager *manager = new BluetoothOppManager();
@ -515,10 +512,7 @@ BluetoothOppManager::CreateFile()
path.Append(mFileName);
mDsFile = DeviceStorageFile::CreateUnique(path, nsIFile::NORMAL_FILE_TYPE, 0644);
if (!mDsFile) {
NS_WARNING("Couldn't create the file");
return false;
}
NS_ENSURE_TRUE(mDsFile, false);
nsCOMPtr<nsIFile> f;
mDsFile->mFile->Clone(getter_AddRefs(f));

Просмотреть файл

@ -771,38 +771,6 @@ UnpackManagerPropertiesMessage(DBusMessage* aMsg, DBusError* aErr,
ArrayLength(sManagerProperties));
}
static void
GetManagerPropertiesCallback(DBusMessage* aMsg, void* aBluetoothReplyRunnable)
{
RunDBusCallback(aMsg, aBluetoothReplyRunnable,
UnpackManagerPropertiesMessage);
}
static void
GetAdapterPropertiesCallback(DBusMessage* aMsg, void* aBluetoothReplyRunnable)
{
RunDBusCallback(aMsg, aBluetoothReplyRunnable,
UnpackAdapterPropertiesMessage);
}
static void
GetDevicePropertiesCallback(DBusMessage* aMsg, void* aBluetoothReplyRunnable)
{
RunDBusCallback(aMsg, aBluetoothReplyRunnable,
UnpackDevicePropertiesMessage);
}
static DBusCallback sBluetoothDBusPropCallbacks[] =
{
GetManagerPropertiesCallback,
GetAdapterPropertiesCallback,
GetDevicePropertiesCallback
};
static_assert(
sizeof(sBluetoothDBusPropCallbacks) == sizeof(sBluetoothDBusIfaces),
"DBus Property callback array and DBus interface array must be same size");
static void
ParsePropertyChange(DBusMessage* aMsg, BluetoothValue& aValue,
nsAString& aErrorStr, Properties* aPropertyTypes,