зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1020300 - Dispatch part of AdapterStateChangedCallback to main thread. r=btian
This commit is contained in:
Родитель
bf153c74df
Коммит
eb8a5e3410
|
@ -50,12 +50,12 @@ USING_BLUETOOTH_NAMESPACE
|
||||||
static nsString sAdapterBdAddress;
|
static nsString sAdapterBdAddress;
|
||||||
static nsString sAdapterBdName;
|
static nsString sAdapterBdName;
|
||||||
static InfallibleTArray<nsString> sAdapterBondedAddressArray;
|
static InfallibleTArray<nsString> sAdapterBondedAddressArray;
|
||||||
static nsTArray<nsRefPtr<BluetoothReplyRunnable> > sChangeAdapterStateRunnableArray;
|
|
||||||
|
|
||||||
// Static variables below should only be used on *main thread*
|
// Static variables below should only be used on *main thread*
|
||||||
static const bt_interface_t* sBtInterface;
|
static const bt_interface_t* sBtInterface;
|
||||||
static nsTArray<nsRefPtr<BluetoothProfileController> > sControllerArray;
|
static nsTArray<nsRefPtr<BluetoothProfileController> > sControllerArray;
|
||||||
static nsTArray<int> sRequestedDeviceCountArray;
|
static nsTArray<int> sRequestedDeviceCountArray;
|
||||||
|
static nsTArray<nsRefPtr<BluetoothReplyRunnable> > sChangeAdapterStateRunnableArray;
|
||||||
static nsTArray<nsRefPtr<BluetoothReplyRunnable> > sChangeDiscoveryRunnableArray;
|
static nsTArray<nsRefPtr<BluetoothReplyRunnable> > sChangeDiscoveryRunnableArray;
|
||||||
static nsTArray<nsRefPtr<BluetoothReplyRunnable> > sSetPropertyRunnableArray;
|
static nsTArray<nsRefPtr<BluetoothReplyRunnable> > sSetPropertyRunnableArray;
|
||||||
static nsTArray<nsRefPtr<BluetoothReplyRunnable> > sGetDeviceRunnableArray;
|
static nsTArray<nsRefPtr<BluetoothReplyRunnable> > sGetDeviceRunnableArray;
|
||||||
|
@ -295,6 +295,27 @@ PlayStatusStringToControlPlayStatus(const nsAString& aPlayStatus)
|
||||||
return playStatus;
|
return playStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class AdapterStateChangedCallbackTask MOZ_FINAL : public nsRunnable
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
NS_IMETHOD
|
||||||
|
Run()
|
||||||
|
{
|
||||||
|
MOZ_ASSERT(NS_IsMainThread());
|
||||||
|
|
||||||
|
// Resolve promise if existed
|
||||||
|
if (!sChangeAdapterStateRunnableArray.IsEmpty()) {
|
||||||
|
BluetoothValue values(true);
|
||||||
|
DispatchBluetoothReply(sChangeAdapterStateRunnableArray[0],
|
||||||
|
values, EmptyString());
|
||||||
|
|
||||||
|
sChangeAdapterStateRunnableArray.RemoveElementAt(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Bluedroid HAL callback functions
|
* Bluedroid HAL callback functions
|
||||||
*
|
*
|
||||||
|
@ -327,13 +348,8 @@ AdapterStateChangeCallback(bt_state_t aStatus)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Resolve promise if existed
|
// Redirect to main thread to avoid racing problem
|
||||||
if(!sChangeAdapterStateRunnableArray.IsEmpty()) {
|
NS_DispatchToMainThread(new AdapterStateChangedCallbackTask());
|
||||||
DispatchBluetoothReply(sChangeAdapterStateRunnableArray[0],
|
|
||||||
BluetoothValue(true),
|
|
||||||
EmptyString());
|
|
||||||
sChangeAdapterStateRunnableArray.RemoveElementAt(0);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class AdapterPropertiesCallbackTask MOZ_FINAL : public nsRunnable
|
class AdapterPropertiesCallbackTask MOZ_FINAL : public nsRunnable
|
||||||
|
|
Загрузка…
Ссылка в новой задаче