зеркало из https://github.com/mozilla/gecko-dev.git
Bug 904014 - [Bluetooth] [Cleanup] Revise macros in Bluetooth*Manager.cpp under dom/bluetooth, r=echou
This commit is contained in:
Родитель
9ddf2cea9c
Коммит
64d4f74c1f
|
@ -125,10 +125,7 @@ BluetoothA2dpManager::Get()
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we're in shutdown, don't create a new instance
|
// If we're in shutdown, don't create a new instance
|
||||||
if (sInShutdown) {
|
NS_ENSURE_FALSE(sInShutdown, nullptr);
|
||||||
NS_WARNING("BluetoothA2dpManager can't be created during shutdown");
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create a new instance, register, and return
|
// Create a new instance, register, and return
|
||||||
BluetoothA2dpManager* manager = new BluetoothA2dpManager();
|
BluetoothA2dpManager* manager = new BluetoothA2dpManager();
|
||||||
|
@ -153,15 +150,8 @@ BluetoothA2dpManager::Connect(const nsAString& aDeviceAddress)
|
||||||
MOZ_ASSERT(NS_IsMainThread());
|
MOZ_ASSERT(NS_IsMainThread());
|
||||||
MOZ_ASSERT(!aDeviceAddress.IsEmpty());
|
MOZ_ASSERT(!aDeviceAddress.IsEmpty());
|
||||||
|
|
||||||
if (sInShutdown) {
|
NS_ENSURE_FALSE(sInShutdown, false);
|
||||||
NS_WARNING("Connect called while in shutdown!");
|
NS_ENSURE_FALSE(mA2dpConnected, false);
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mA2dpConnected) {
|
|
||||||
NS_WARNING("BluetoothA2dpManager is connected");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
mDeviceAddress = aDeviceAddress;
|
mDeviceAddress = aDeviceAddress;
|
||||||
|
|
||||||
|
@ -176,10 +166,7 @@ BluetoothA2dpManager::Connect(const nsAString& aDeviceAddress)
|
||||||
void
|
void
|
||||||
BluetoothA2dpManager::Disconnect()
|
BluetoothA2dpManager::Disconnect()
|
||||||
{
|
{
|
||||||
if (!mA2dpConnected) {
|
NS_ENSURE_TRUE_VOID(mA2dpConnected);
|
||||||
NS_WARNING("BluetoothA2dpManager has been disconnected");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
MOZ_ASSERT(!mDeviceAddress.IsEmpty());
|
MOZ_ASSERT(!mDeviceAddress.IsEmpty());
|
||||||
|
|
||||||
|
@ -203,22 +190,28 @@ BluetoothA2dpManager::HandleSinkPropertyChanged(const BluetoothSignal& aSignal)
|
||||||
if (name.EqualsLiteral("Connected")) {
|
if (name.EqualsLiteral("Connected")) {
|
||||||
// Indicates if a stream is setup to a A2DP sink on the remote device.
|
// Indicates if a stream is setup to a A2DP sink on the remote device.
|
||||||
MOZ_ASSERT(value.type() == BluetoothValue::Tbool);
|
MOZ_ASSERT(value.type() == BluetoothValue::Tbool);
|
||||||
|
MOZ_ASSERT(mA2dpConnected != value.get_bool());
|
||||||
|
|
||||||
mA2dpConnected = value.get_bool();
|
mA2dpConnected = value.get_bool();
|
||||||
NotifyConnectionStatusChanged();
|
NotifyConnectionStatusChanged();
|
||||||
DispatchConnectionStatusChanged();
|
DispatchConnectionStatusChanged();
|
||||||
} else if (name.EqualsLiteral("Playing")) {
|
} else if (name.EqualsLiteral("Playing")) {
|
||||||
// Indicates if a stream is active to a A2DP sink on the remote device.
|
// Indicates if a stream is active to a A2DP sink on the remote device.
|
||||||
MOZ_ASSERT(value.type() == BluetoothValue::Tbool);
|
MOZ_ASSERT(value.type() == BluetoothValue::Tbool);
|
||||||
|
MOZ_ASSERT(mPlaying != value.get_bool());
|
||||||
|
|
||||||
mPlaying = value.get_bool();
|
mPlaying = value.get_bool();
|
||||||
} else if (name.EqualsLiteral("State")) {
|
} else if (name.EqualsLiteral("State")) {
|
||||||
MOZ_ASSERT(value.type() == BluetoothValue::TnsString);
|
MOZ_ASSERT(value.type() == BluetoothValue::TnsString);
|
||||||
|
MOZ_ASSERT(mSinkState != StatusStringToSinkState(value.get_nsString()));
|
||||||
|
|
||||||
HandleSinkStateChanged(StatusStringToSinkState(value.get_nsString()));
|
HandleSinkStateChanged(StatusStringToSinkState(value.get_nsString()));
|
||||||
} else {
|
} else {
|
||||||
NS_WARNING("Unknown sink property");
|
NS_WARNING("Unknown sink property");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* HandleSinkPropertyChanged update sink state in A2dp
|
/* HandleSinkStateChanged updates sink state in A2dp
|
||||||
*
|
*
|
||||||
* Possible values: "disconnected", "connecting", "connected", "playing"
|
* Possible values: "disconnected", "connecting", "connected", "playing"
|
||||||
*
|
*
|
||||||
|
|
|
@ -12,8 +12,6 @@
|
||||||
|
|
||||||
BEGIN_BLUETOOTH_NAMESPACE
|
BEGIN_BLUETOOTH_NAMESPACE
|
||||||
|
|
||||||
class BluetoothA2dpManagerObserver;
|
|
||||||
|
|
||||||
class BluetoothA2dpManager : public BluetoothProfileManagerBase
|
class BluetoothA2dpManager : public BluetoothProfileManagerBase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -440,10 +440,7 @@ BluetoothHfpManager::Get()
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we're in shutdown, don't create a new instance
|
// If we're in shutdown, don't create a new instance
|
||||||
if (sInShutdown) {
|
NS_ENSURE_FALSE(sInShutdown, nullptr);
|
||||||
NS_WARNING("BluetoothHfpManager can't be created during shutdown");
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create a new instance, register, and return
|
// Create a new instance, register, and return
|
||||||
BluetoothHfpManager* manager = new BluetoothHfpManager();
|
BluetoothHfpManager* manager = new BluetoothHfpManager();
|
||||||
|
|
|
@ -216,10 +216,7 @@ BluetoothOppManager::Get()
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we're in shutdown, don't create a new instance
|
// If we're in shutdown, don't create a new instance
|
||||||
if (sInShutdown) {
|
NS_ENSURE_FALSE(sInShutdown, nullptr);
|
||||||
NS_WARNING("BluetoothOppManager can't be created during shutdown");
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create a new instance, register, and return
|
// Create a new instance, register, and return
|
||||||
BluetoothOppManager *manager = new BluetoothOppManager();
|
BluetoothOppManager *manager = new BluetoothOppManager();
|
||||||
|
@ -515,10 +512,7 @@ BluetoothOppManager::CreateFile()
|
||||||
path.Append(mFileName);
|
path.Append(mFileName);
|
||||||
|
|
||||||
mDsFile = DeviceStorageFile::CreateUnique(path, nsIFile::NORMAL_FILE_TYPE, 0644);
|
mDsFile = DeviceStorageFile::CreateUnique(path, nsIFile::NORMAL_FILE_TYPE, 0644);
|
||||||
if (!mDsFile) {
|
NS_ENSURE_TRUE(mDsFile, false);
|
||||||
NS_WARNING("Couldn't create the file");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
nsCOMPtr<nsIFile> f;
|
nsCOMPtr<nsIFile> f;
|
||||||
mDsFile->mFile->Clone(getter_AddRefs(f));
|
mDsFile->mFile->Clone(getter_AddRefs(f));
|
||||||
|
|
|
@ -771,38 +771,6 @@ UnpackManagerPropertiesMessage(DBusMessage* aMsg, DBusError* aErr,
|
||||||
ArrayLength(sManagerProperties));
|
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
|
static void
|
||||||
ParsePropertyChange(DBusMessage* aMsg, BluetoothValue& aValue,
|
ParsePropertyChange(DBusMessage* aMsg, BluetoothValue& aValue,
|
||||||
nsAString& aErrorStr, Properties* aPropertyTypes,
|
nsAString& aErrorStr, Properties* aPropertyTypes,
|
||||||
|
|
Загрузка…
Ссылка в новой задаче