mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 05:11:16 +00:00
Backed out changeset bed325ace368 (bug 1203092)
This commit is contained in:
parent
22f375913e
commit
7a16edd7a4
@ -28,14 +28,25 @@ BluetoothDaemonA2dpModule::SetNotificationHandler(
|
||||
sNotificationHandler = aNotificationHandler;
|
||||
}
|
||||
|
||||
nsresult
|
||||
BluetoothDaemonA2dpModule::Send(DaemonSocketPDU* aPDU,
|
||||
BluetoothA2dpResultHandler* aRes)
|
||||
{
|
||||
nsRefPtr<BluetoothA2dpResultHandler> res(aRes);
|
||||
nsresult rv = Send(aPDU, static_cast<void*>(res.get()));
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
unused << res.forget(); // Keep reference for response
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothDaemonA2dpModule::HandleSvc(const DaemonSocketPDUHeader& aHeader,
|
||||
DaemonSocketPDU& aPDU,
|
||||
DaemonSocketResultHandler* aRes)
|
||||
DaemonSocketPDU& aPDU, void* aUserData)
|
||||
{
|
||||
static void (BluetoothDaemonA2dpModule::* const HandleOp[])(
|
||||
const DaemonSocketPDUHeader&, DaemonSocketPDU&,
|
||||
DaemonSocketResultHandler*) = {
|
||||
const DaemonSocketPDUHeader&, DaemonSocketPDU&, void*) = {
|
||||
[0] = &BluetoothDaemonA2dpModule::HandleRsp,
|
||||
[1] = &BluetoothDaemonA2dpModule::HandleNtf
|
||||
};
|
||||
@ -45,7 +56,7 @@ BluetoothDaemonA2dpModule::HandleSvc(const DaemonSocketPDUHeader& aHeader,
|
||||
// negate twice to map bit to 0/1
|
||||
unsigned int isNtf = !!(aHeader.mOpcode & 0x80);
|
||||
|
||||
(this->*(HandleOp[isNtf]))(aHeader, aPDU, aRes);
|
||||
(this->*(HandleOp[isNtf]))(aHeader, aPDU, aUserData);
|
||||
}
|
||||
|
||||
// Commands
|
||||
@ -128,7 +139,7 @@ BluetoothDaemonA2dpModule::DisconnectRsp(
|
||||
void
|
||||
BluetoothDaemonA2dpModule::HandleRsp(
|
||||
const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU,
|
||||
DaemonSocketResultHandler* aRes)
|
||||
void* aUserData)
|
||||
{
|
||||
static void (BluetoothDaemonA2dpModule::* const HandleRsp[])(
|
||||
const DaemonSocketPDUHeader&,
|
||||
@ -147,7 +158,8 @@ BluetoothDaemonA2dpModule::HandleRsp(
|
||||
}
|
||||
|
||||
nsRefPtr<BluetoothA2dpResultHandler> res =
|
||||
static_cast<BluetoothA2dpResultHandler*>(aRes);
|
||||
already_AddRefed<BluetoothA2dpResultHandler>(
|
||||
static_cast<BluetoothA2dpResultHandler*>(aUserData));
|
||||
|
||||
if (!res) {
|
||||
return; // Return early if no result handler has been set for response
|
||||
@ -303,7 +315,7 @@ BluetoothDaemonA2dpModule::AudioConfigNtf(
|
||||
void
|
||||
BluetoothDaemonA2dpModule::HandleNtf(
|
||||
const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU,
|
||||
DaemonSocketResultHandler* aRes)
|
||||
void* aUserData)
|
||||
{
|
||||
static void (BluetoothDaemonA2dpModule::* const HandleNtf[])(
|
||||
const DaemonSocketPDUHeader&, DaemonSocketPDU&) = {
|
||||
|
@ -15,7 +15,6 @@ BEGIN_BLUETOOTH_NAMESPACE
|
||||
|
||||
using mozilla::ipc::DaemonSocketPDU;
|
||||
using mozilla::ipc::DaemonSocketPDUHeader;
|
||||
using mozilla::ipc::DaemonSocketResultHandler;
|
||||
|
||||
class BluetoothSetupResultHandler;
|
||||
|
||||
@ -34,8 +33,7 @@ public:
|
||||
|
||||
static const int MAX_NUM_CLIENTS;
|
||||
|
||||
virtual nsresult Send(DaemonSocketPDU* aPDU,
|
||||
DaemonSocketResultHandler* aRes) = 0;
|
||||
virtual nsresult Send(DaemonSocketPDU* aPDU, void* aUserData) = 0;
|
||||
|
||||
virtual nsresult RegisterModule(uint8_t aId, uint8_t aMode,
|
||||
uint32_t aMaxNumClients,
|
||||
@ -57,8 +55,11 @@ public:
|
||||
BluetoothA2dpResultHandler* aRes);
|
||||
|
||||
protected:
|
||||
nsresult Send(DaemonSocketPDU* aPDU,
|
||||
BluetoothA2dpResultHandler* aRes);
|
||||
|
||||
void HandleSvc(const DaemonSocketPDUHeader& aHeader,
|
||||
DaemonSocketPDU& aPDU, DaemonSocketResultHandler* aRes);
|
||||
DaemonSocketPDU& aPDU, void* aUserData);
|
||||
|
||||
//
|
||||
// Responses
|
||||
@ -86,7 +87,7 @@ protected:
|
||||
|
||||
void HandleRsp(const DaemonSocketPDUHeader& aHeader,
|
||||
DaemonSocketPDU& aPDU,
|
||||
DaemonSocketResultHandler* aRes);
|
||||
void* aUserData);
|
||||
|
||||
//
|
||||
// Notifications
|
||||
@ -124,7 +125,7 @@ protected:
|
||||
|
||||
void HandleNtf(const DaemonSocketPDUHeader& aHeader,
|
||||
DaemonSocketPDU& aPDU,
|
||||
DaemonSocketResultHandler* aRes);
|
||||
void* aUserData);
|
||||
|
||||
static BluetoothA2dpNotificationHandler* sNotificationHandler;
|
||||
};
|
||||
|
@ -28,14 +28,25 @@ BluetoothDaemonAvrcpModule::SetNotificationHandler(
|
||||
sNotificationHandler = aNotificationHandler;
|
||||
}
|
||||
|
||||
nsresult
|
||||
BluetoothDaemonAvrcpModule::Send(DaemonSocketPDU* aPDU,
|
||||
BluetoothAvrcpResultHandler* aRes)
|
||||
{
|
||||
nsRefPtr<BluetoothAvrcpResultHandler> res(aRes);
|
||||
nsresult rv = Send(aPDU, static_cast<void*>(res.get()));
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
unused << res.forget(); // Keep reference for response
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothDaemonAvrcpModule::HandleSvc(const DaemonSocketPDUHeader& aHeader,
|
||||
DaemonSocketPDU& aPDU,
|
||||
DaemonSocketResultHandler* aRes)
|
||||
DaemonSocketPDU& aPDU, void* aUserData)
|
||||
{
|
||||
static void (BluetoothDaemonAvrcpModule::* const HandleOp[])(
|
||||
const DaemonSocketPDUHeader&, DaemonSocketPDU&,
|
||||
DaemonSocketResultHandler*) = {
|
||||
const DaemonSocketPDUHeader&, DaemonSocketPDU&, void*) = {
|
||||
[0] = &BluetoothDaemonAvrcpModule::HandleRsp,
|
||||
[1] = &BluetoothDaemonAvrcpModule::HandleNtf
|
||||
};
|
||||
@ -44,7 +55,7 @@ BluetoothDaemonAvrcpModule::HandleSvc(const DaemonSocketPDUHeader& aHeader,
|
||||
|
||||
unsigned int isNtf = !!(aHeader.mOpcode & 0x80);
|
||||
|
||||
(this->*(HandleOp[isNtf]))(aHeader, aPDU, aRes);
|
||||
(this->*(HandleOp[isNtf]))(aHeader, aPDU, aUserData);
|
||||
}
|
||||
|
||||
// Commands
|
||||
@ -410,7 +421,7 @@ BluetoothDaemonAvrcpModule::SetVolumeRsp(
|
||||
void
|
||||
BluetoothDaemonAvrcpModule::HandleRsp(
|
||||
const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU,
|
||||
DaemonSocketResultHandler* aRes)
|
||||
void* aUserData)
|
||||
{
|
||||
static void (BluetoothDaemonAvrcpModule::* const HandleRsp[])(
|
||||
const DaemonSocketPDUHeader&,
|
||||
@ -448,7 +459,8 @@ BluetoothDaemonAvrcpModule::HandleRsp(
|
||||
}
|
||||
|
||||
nsRefPtr<BluetoothAvrcpResultHandler> res =
|
||||
static_cast<BluetoothAvrcpResultHandler*>(aRes);
|
||||
already_AddRefed<BluetoothAvrcpResultHandler>(
|
||||
static_cast<BluetoothAvrcpResultHandler*>(aUserData));
|
||||
|
||||
if (!res) {
|
||||
return; // Return early if no result handler has been set for response
|
||||
@ -780,7 +792,7 @@ BluetoothDaemonAvrcpModule::PassthroughCmdNtf(
|
||||
void
|
||||
BluetoothDaemonAvrcpModule::HandleNtf(
|
||||
const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU,
|
||||
DaemonSocketResultHandler* aRes)
|
||||
void* aUserData)
|
||||
{
|
||||
static void (BluetoothDaemonAvrcpModule::* const HandleNtf[])(
|
||||
const DaemonSocketPDUHeader&, DaemonSocketPDU&) = {
|
||||
|
@ -15,7 +15,6 @@ BEGIN_BLUETOOTH_NAMESPACE
|
||||
|
||||
using mozilla::ipc::DaemonSocketPDU;
|
||||
using mozilla::ipc::DaemonSocketPDUHeader;
|
||||
using mozilla::ipc::DaemonSocketResultHandler;
|
||||
|
||||
class BluetoothSetupResultHandler;
|
||||
|
||||
@ -66,8 +65,7 @@ public:
|
||||
|
||||
static const int MAX_NUM_CLIENTS;
|
||||
|
||||
virtual nsresult Send(DaemonSocketPDU* aPDU,
|
||||
DaemonSocketResultHandler* aRes) = 0;
|
||||
virtual nsresult Send(DaemonSocketPDU* aPDU, void* aUserData) = 0;
|
||||
|
||||
virtual nsresult RegisterModule(uint8_t aId, uint8_t aMode,
|
||||
uint32_t aMaxNumClients,
|
||||
@ -121,8 +119,11 @@ public:
|
||||
nsresult SetVolumeCmd(uint8_t aVolume, BluetoothAvrcpResultHandler* aRes);
|
||||
|
||||
protected:
|
||||
nsresult Send(DaemonSocketPDU* aPDU,
|
||||
BluetoothAvrcpResultHandler* aRes);
|
||||
|
||||
void HandleSvc(const DaemonSocketPDUHeader& aHeader,
|
||||
DaemonSocketPDU& aPDU, DaemonSocketResultHandler* aRes);
|
||||
DaemonSocketPDU& aPDU, void* aUserData);
|
||||
|
||||
//
|
||||
// Responses
|
||||
@ -182,7 +183,7 @@ protected:
|
||||
|
||||
void HandleRsp(const DaemonSocketPDUHeader& aHeader,
|
||||
DaemonSocketPDU& aPDU,
|
||||
DaemonSocketResultHandler* aRes);
|
||||
void* aUserData);
|
||||
|
||||
//
|
||||
// Notifications
|
||||
@ -292,7 +293,7 @@ protected:
|
||||
|
||||
void HandleNtf(const DaemonSocketPDUHeader& aHeader,
|
||||
DaemonSocketPDU& aPDU,
|
||||
DaemonSocketResultHandler* aRes);
|
||||
void* aUserData);
|
||||
|
||||
static BluetoothAvrcpNotificationHandler* sNotificationHandler;
|
||||
};
|
||||
|
@ -28,14 +28,25 @@ BluetoothDaemonGattModule::SetNotificationHandler(
|
||||
sNotificationHandler = aNotificationHandler;
|
||||
}
|
||||
|
||||
nsresult
|
||||
BluetoothDaemonGattModule::Send(DaemonSocketPDU* aPDU,
|
||||
BluetoothGattResultHandler* aRes)
|
||||
{
|
||||
nsRefPtr<BluetoothGattResultHandler> res(aRes);
|
||||
nsresult rv = Send(aPDU, static_cast<void*>(res.get()));
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
unused << res.forget(); // Keep reference for response
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothDaemonGattModule::HandleSvc(const DaemonSocketPDUHeader& aHeader,
|
||||
DaemonSocketPDU& aPDU,
|
||||
DaemonSocketResultHandler* aRes)
|
||||
DaemonSocketPDU& aPDU, void* aUserData)
|
||||
{
|
||||
static void (BluetoothDaemonGattModule::* const HandleOp[])(
|
||||
const DaemonSocketPDUHeader&, DaemonSocketPDU&,
|
||||
DaemonSocketResultHandler*) = {
|
||||
const DaemonSocketPDUHeader&, DaemonSocketPDU&, void*) = {
|
||||
[0] = &BluetoothDaemonGattModule::HandleRsp,
|
||||
[1] = &BluetoothDaemonGattModule::HandleNtf
|
||||
};
|
||||
@ -45,7 +56,7 @@ BluetoothDaemonGattModule::HandleSvc(const DaemonSocketPDUHeader& aHeader,
|
||||
// Negate twice to map bit to 0/1
|
||||
unsigned long isNtf = !!(aHeader.mOpcode & 0x80);
|
||||
|
||||
(this->*(HandleOp[isNtf]))(aHeader, aPDU, aRes);
|
||||
(this->*(HandleOp[isNtf]))(aHeader, aPDU, aUserData);
|
||||
}
|
||||
|
||||
// Commands
|
||||
@ -1394,7 +1405,7 @@ BluetoothDaemonGattModule::ServerSendResponseRsp(
|
||||
void
|
||||
BluetoothDaemonGattModule::HandleRsp(
|
||||
const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU,
|
||||
DaemonSocketResultHandler* aRes)
|
||||
void* aUserData)
|
||||
{
|
||||
static void (BluetoothDaemonGattModule::* const HandleRsp[])(
|
||||
const DaemonSocketPDUHeader&,
|
||||
@ -1482,7 +1493,8 @@ BluetoothDaemonGattModule::HandleRsp(
|
||||
}
|
||||
|
||||
nsRefPtr<BluetoothGattResultHandler> res =
|
||||
static_cast<BluetoothGattResultHandler*>(aRes);
|
||||
already_AddRefed<BluetoothGattResultHandler>(
|
||||
static_cast<BluetoothGattResultHandler*>(aUserData));
|
||||
|
||||
if (!res) {
|
||||
return;
|
||||
@ -2140,7 +2152,7 @@ BluetoothDaemonGattModule::ServerResponseConfirmationNtf(
|
||||
void
|
||||
BluetoothDaemonGattModule::HandleNtf(
|
||||
const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU,
|
||||
DaemonSocketResultHandler* aRes)
|
||||
void* aUserData)
|
||||
{
|
||||
static void (BluetoothDaemonGattModule::* const HandleNtf[])(
|
||||
const DaemonSocketPDUHeader&, DaemonSocketPDU&) = {
|
||||
|
@ -15,7 +15,6 @@ BEGIN_BLUETOOTH_NAMESPACE
|
||||
|
||||
using mozilla::ipc::DaemonSocketPDU;
|
||||
using mozilla::ipc::DaemonSocketPDUHeader;
|
||||
using mozilla::ipc::DaemonSocketResultHandler;
|
||||
|
||||
class BluetoothSetupResultHandler;
|
||||
|
||||
@ -68,8 +67,7 @@ public:
|
||||
|
||||
static const int MAX_NUM_CLIENTS;
|
||||
|
||||
virtual nsresult Send(DaemonSocketPDU* aPDU,
|
||||
DaemonSocketResultHandler* aRes) = 0;
|
||||
virtual nsresult Send(DaemonSocketPDU* aPDU, void* aUserData) = 0;
|
||||
|
||||
virtual nsresult RegisterModule(uint8_t aId, uint8_t aMode,
|
||||
uint32_t aMaxNumClients,
|
||||
@ -302,8 +300,11 @@ public:
|
||||
// TODO: Add L support
|
||||
|
||||
protected:
|
||||
nsresult Send(DaemonSocketPDU* aPDU,
|
||||
BluetoothGattResultHandler* aRes);
|
||||
|
||||
void HandleSvc(const DaemonSocketPDUHeader& aHeader,
|
||||
DaemonSocketPDU& aPDU, DaemonSocketResultHandler* aRes);
|
||||
DaemonSocketPDU& aPDU, void* aUserData);
|
||||
|
||||
//
|
||||
// Responses
|
||||
@ -470,7 +471,7 @@ protected:
|
||||
|
||||
void HandleRsp(const DaemonSocketPDUHeader& aHeader,
|
||||
DaemonSocketPDU& aPDU,
|
||||
DaemonSocketResultHandler* aRes);
|
||||
void* aUserData);
|
||||
|
||||
//
|
||||
// Notifications
|
||||
@ -769,7 +770,7 @@ protected:
|
||||
|
||||
void HandleNtf(const DaemonSocketPDUHeader& aHeader,
|
||||
DaemonSocketPDU& aPDU,
|
||||
DaemonSocketResultHandler* aRes);
|
||||
void* aUserData);
|
||||
|
||||
static BluetoothGattNotificationHandler* sNotificationHandler;
|
||||
};
|
||||
|
@ -31,14 +31,25 @@ BluetoothDaemonHandsfreeModule::SetNotificationHandler(
|
||||
sNotificationHandler = aNotificationHandler;
|
||||
}
|
||||
|
||||
nsresult
|
||||
BluetoothDaemonHandsfreeModule::Send(DaemonSocketPDU* aPDU,
|
||||
BluetoothHandsfreeResultHandler* aRes)
|
||||
{
|
||||
nsRefPtr<BluetoothHandsfreeResultHandler> res(aRes);
|
||||
nsresult rv = Send(aPDU, static_cast<void*>(res.get()));
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
unused << res.forget(); // Keep reference for response
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothDaemonHandsfreeModule::HandleSvc(
|
||||
const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU,
|
||||
DaemonSocketResultHandler* aRes)
|
||||
const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU, void* aUserData)
|
||||
{
|
||||
static void (BluetoothDaemonHandsfreeModule::* const HandleOp[])(
|
||||
const DaemonSocketPDUHeader&, DaemonSocketPDU&,
|
||||
DaemonSocketResultHandler*) = {
|
||||
const DaemonSocketPDUHeader&, DaemonSocketPDU&, void*) = {
|
||||
[0] = &BluetoothDaemonHandsfreeModule::HandleRsp,
|
||||
[1] = &BluetoothDaemonHandsfreeModule::HandleNtf
|
||||
};
|
||||
@ -48,7 +59,7 @@ BluetoothDaemonHandsfreeModule::HandleSvc(
|
||||
// Negate twice to map bit to 0/1
|
||||
unsigned long isNtf = !!(aHeader.mOpcode & 0x80);
|
||||
|
||||
(this->*(HandleOp[isNtf]))(aHeader, aPDU, aRes);
|
||||
(this->*(HandleOp[isNtf]))(aHeader, aPDU, aUserData);
|
||||
}
|
||||
|
||||
// Commands
|
||||
@ -668,7 +679,7 @@ BluetoothDaemonHandsfreeModule::ConfigureWbsRsp(
|
||||
void
|
||||
BluetoothDaemonHandsfreeModule::HandleRsp(
|
||||
const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU,
|
||||
DaemonSocketResultHandler* aRes)
|
||||
void* aUserData)
|
||||
{
|
||||
static void (BluetoothDaemonHandsfreeModule::* const HandleRsp[])(
|
||||
const DaemonSocketPDUHeader&,
|
||||
@ -716,7 +727,8 @@ BluetoothDaemonHandsfreeModule::HandleRsp(
|
||||
}
|
||||
|
||||
nsRefPtr<BluetoothHandsfreeResultHandler> res =
|
||||
static_cast<BluetoothHandsfreeResultHandler*>(aRes);
|
||||
already_AddRefed<BluetoothHandsfreeResultHandler>(
|
||||
static_cast<BluetoothHandsfreeResultHandler*>(aUserData));
|
||||
|
||||
if (!res) {
|
||||
return; // Return early if no result handler has been set for response
|
||||
@ -1451,7 +1463,7 @@ BluetoothDaemonHandsfreeModule::WbsNtf(
|
||||
void
|
||||
BluetoothDaemonHandsfreeModule::HandleNtf(
|
||||
const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU,
|
||||
DaemonSocketResultHandler* aRes)
|
||||
void* aUserData)
|
||||
{
|
||||
static void (BluetoothDaemonHandsfreeModule::* const HandleNtf[])(
|
||||
const DaemonSocketPDUHeader&, DaemonSocketPDU&) = {
|
||||
|
@ -15,7 +15,6 @@ BEGIN_BLUETOOTH_NAMESPACE
|
||||
|
||||
using mozilla::ipc::DaemonSocketPDU;
|
||||
using mozilla::ipc::DaemonSocketPDUHeader;
|
||||
using mozilla::ipc::DaemonSocketResultHandler;
|
||||
|
||||
class BluetoothSetupResultHandler;
|
||||
|
||||
@ -45,8 +44,7 @@ public:
|
||||
OPCODE_CONFIGURE_WBS = 0x0f
|
||||
};
|
||||
|
||||
virtual nsresult Send(DaemonSocketPDU* aPDU,
|
||||
DaemonSocketResultHandler* aRes) = 0;
|
||||
virtual nsresult Send(DaemonSocketPDU* aPDU, void* aUserData) = 0;
|
||||
|
||||
virtual nsresult RegisterModule(uint8_t aId, uint8_t aMode,
|
||||
uint32_t aMaxNumClients,
|
||||
@ -130,9 +128,11 @@ public:
|
||||
BluetoothHandsfreeResultHandler* aRes);
|
||||
|
||||
protected:
|
||||
nsresult Send(DaemonSocketPDU* aPDU,
|
||||
BluetoothHandsfreeResultHandler* aRes);
|
||||
|
||||
void HandleSvc(const DaemonSocketPDUHeader& aHeader,
|
||||
DaemonSocketPDU& aPDU,
|
||||
DaemonSocketResultHandler* aRes);
|
||||
DaemonSocketPDU& aPDU, void* aUserData);
|
||||
|
||||
//
|
||||
// Responses
|
||||
@ -212,7 +212,7 @@ protected:
|
||||
|
||||
void HandleRsp(const DaemonSocketPDUHeader& aHeader,
|
||||
DaemonSocketPDU& aPDU,
|
||||
DaemonSocketResultHandler* aRes);
|
||||
void* aUserData);
|
||||
|
||||
//
|
||||
// Notifications
|
||||
@ -369,7 +369,7 @@ protected:
|
||||
|
||||
void HandleNtf(const DaemonSocketPDUHeader& aHeader,
|
||||
DaemonSocketPDU& aPDU,
|
||||
DaemonSocketResultHandler* aRes);
|
||||
void* aUserData);
|
||||
|
||||
static BluetoothHandsfreeNotificationHandler* sNotificationHandler;
|
||||
#if ANDROID_VERSION < 21
|
||||
|
@ -34,8 +34,7 @@ static const int sRetryInterval = 100; // ms
|
||||
class BluetoothDaemonSetupModule
|
||||
{
|
||||
public:
|
||||
virtual nsresult Send(DaemonSocketPDU* aPDU,
|
||||
DaemonSocketResultHandler* aRes) = 0;
|
||||
virtual nsresult Send(DaemonSocketPDU* aPDU, void* aUserData) = 0;
|
||||
|
||||
// Commands
|
||||
//
|
||||
@ -108,7 +107,7 @@ protected:
|
||||
// Called to handle PDUs with Service field equal to 0x00, which
|
||||
// contains internal operations for setup and configuration.
|
||||
void HandleSvc(const DaemonSocketPDUHeader& aHeader,
|
||||
DaemonSocketPDU& aPDU, DaemonSocketResultHandler* aRes)
|
||||
DaemonSocketPDU& aPDU, void* aUserData)
|
||||
{
|
||||
static void (BluetoothDaemonSetupModule::* const HandleRsp[])(
|
||||
const DaemonSocketPDUHeader&,
|
||||
@ -126,15 +125,27 @@ protected:
|
||||
}
|
||||
|
||||
nsRefPtr<BluetoothSetupResultHandler> res =
|
||||
static_cast<BluetoothSetupResultHandler*>(aRes);
|
||||
already_AddRefed<BluetoothSetupResultHandler>(
|
||||
static_cast<BluetoothSetupResultHandler*>(aUserData));
|
||||
|
||||
if (!aRes) {
|
||||
if (!res) {
|
||||
return; // Return early if no result handler has been set
|
||||
}
|
||||
|
||||
(this->*(HandleRsp[aHeader.mOpcode]))(aHeader, aPDU, res);
|
||||
}
|
||||
|
||||
nsresult Send(DaemonSocketPDU* aPDU, BluetoothSetupResultHandler* aRes)
|
||||
{
|
||||
nsRefPtr<BluetoothSetupResultHandler> res(aRes);
|
||||
nsresult rv = Send(aPDU, static_cast<void*>(res.get()));
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
unused << res.forget(); // Keep reference for response
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
// Responses
|
||||
@ -200,8 +211,7 @@ public:
|
||||
|
||||
static const int MAX_NUM_CLIENTS;
|
||||
|
||||
virtual nsresult Send(DaemonSocketPDU* aPDU,
|
||||
DaemonSocketResultHandler* aRes) = 0;
|
||||
virtual nsresult Send(DaemonSocketPDU* aPDU, void* aUserData) = 0;
|
||||
|
||||
nsresult EnableCmd(BluetoothResultHandler* aRes)
|
||||
{
|
||||
@ -590,18 +600,28 @@ public:
|
||||
protected:
|
||||
|
||||
void HandleSvc(const DaemonSocketPDUHeader& aHeader,
|
||||
DaemonSocketPDU& aPDU, DaemonSocketResultHandler* aRes)
|
||||
DaemonSocketPDU& aPDU, void* aUserData)
|
||||
{
|
||||
static void (BluetoothDaemonCoreModule::* const HandleOp[])(
|
||||
const DaemonSocketPDUHeader&, DaemonSocketPDU&,
|
||||
DaemonSocketResultHandler*) = {
|
||||
const DaemonSocketPDUHeader&, DaemonSocketPDU&, void*) = {
|
||||
[0] = &BluetoothDaemonCoreModule::HandleRsp,
|
||||
[1] = &BluetoothDaemonCoreModule::HandleNtf
|
||||
};
|
||||
|
||||
MOZ_ASSERT(!NS_IsMainThread());
|
||||
|
||||
(this->*(HandleOp[!!(aHeader.mOpcode & 0x80)]))(aHeader, aPDU, aRes);
|
||||
(this->*(HandleOp[!!(aHeader.mOpcode & 0x80)]))(aHeader, aPDU, aUserData);
|
||||
}
|
||||
|
||||
nsresult Send(DaemonSocketPDU* aPDU, BluetoothResultHandler* aRes)
|
||||
{
|
||||
nsRefPtr<BluetoothResultHandler> res(aRes);
|
||||
nsresult rv = Send(aPDU, static_cast<void*>(res.get()));
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
unused << res.forget(); // Keep reference for response
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
private:
|
||||
@ -805,7 +825,7 @@ private:
|
||||
}
|
||||
|
||||
void HandleRsp(const DaemonSocketPDUHeader& aHeader,
|
||||
DaemonSocketPDU& aPDU, DaemonSocketResultHandler* aRes)
|
||||
DaemonSocketPDU& aPDU, void* aUserData)
|
||||
{
|
||||
static void (BluetoothDaemonCoreModule::* const HandleRsp[])(
|
||||
const DaemonSocketPDUHeader&,
|
||||
@ -842,7 +862,8 @@ private:
|
||||
}
|
||||
|
||||
nsRefPtr<BluetoothResultHandler> res =
|
||||
static_cast<BluetoothResultHandler*>(aRes);
|
||||
already_AddRefed<BluetoothResultHandler>(
|
||||
static_cast<BluetoothResultHandler*>(aUserData));
|
||||
|
||||
if (!res) {
|
||||
return; // Return early if no result handler has been set for response
|
||||
@ -1324,7 +1345,7 @@ private:
|
||||
}
|
||||
|
||||
void HandleNtf(const DaemonSocketPDUHeader& aHeader,
|
||||
DaemonSocketPDU& aPDU, DaemonSocketResultHandler* aRes)
|
||||
DaemonSocketPDU& aPDU, void* aUserData)
|
||||
{
|
||||
static void (BluetoothDaemonCoreModule::* const HandleNtf[])(
|
||||
const DaemonSocketPDUHeader&, DaemonSocketPDU&) = {
|
||||
@ -1432,44 +1453,35 @@ public:
|
||||
// Outgoing PDUs
|
||||
//
|
||||
|
||||
nsresult Send(DaemonSocketPDU* aPDU,
|
||||
DaemonSocketResultHandler* aRes) override;
|
||||
nsresult Send(DaemonSocketPDU* aPDU, void* aUserData) override;
|
||||
|
||||
void StoreResultHandler(const DaemonSocketPDU& aPDU) override;
|
||||
void StoreUserData(const DaemonSocketPDU& aPDU) override;
|
||||
|
||||
// Incoming PUDs
|
||||
//
|
||||
|
||||
void Handle(DaemonSocketPDU& aPDU) override;
|
||||
|
||||
already_AddRefed<DaemonSocketResultHandler> FetchResultHandler(
|
||||
const DaemonSocketPDUHeader& aHeader);
|
||||
void* FetchUserData(const DaemonSocketPDUHeader& aHeader);
|
||||
|
||||
private:
|
||||
void HandleSetupSvc(const DaemonSocketPDUHeader& aHeader,
|
||||
DaemonSocketPDU& aPDU,
|
||||
DaemonSocketResultHandler* aRes);
|
||||
DaemonSocketPDU& aPDU, void* aUserData);
|
||||
void HandleCoreSvc(const DaemonSocketPDUHeader& aHeader,
|
||||
DaemonSocketPDU& aPDU,
|
||||
DaemonSocketResultHandler* aRes);
|
||||
DaemonSocketPDU& aPDU, void* aUserData);
|
||||
void HandleSocketSvc(const DaemonSocketPDUHeader& aHeader,
|
||||
DaemonSocketPDU& aPDU,
|
||||
DaemonSocketResultHandler* aRes);
|
||||
DaemonSocketPDU& aPDU, void* aUserData);
|
||||
void HandleHandsfreeSvc(const DaemonSocketPDUHeader& aHeader,
|
||||
DaemonSocketPDU& aPDU,
|
||||
DaemonSocketResultHandler* aRes);
|
||||
DaemonSocketPDU& aPDU, void* aUserData);
|
||||
void HandleA2dpSvc(const DaemonSocketPDUHeader& aHeader,
|
||||
DaemonSocketPDU& aPDU,
|
||||
DaemonSocketResultHandler* aUserData);
|
||||
DaemonSocketPDU& aPDU, void* aUserData);
|
||||
void HandleAvrcpSvc(const DaemonSocketPDUHeader& aHeader,
|
||||
DaemonSocketPDU& aPDU,
|
||||
DaemonSocketResultHandler* aRes);
|
||||
DaemonSocketPDU& aPDU, void* aUserData);
|
||||
void HandleGattSvc(const DaemonSocketPDUHeader& aHeader,
|
||||
DaemonSocketPDU& aPDU,
|
||||
DaemonSocketResultHandler* aRes);
|
||||
DaemonSocketPDU& aPDU, void* aUserData);
|
||||
|
||||
DaemonSocket* mConnection;
|
||||
nsTArray<nsRefPtr<DaemonSocketResultHandler>> mResQ;
|
||||
nsTArray<void*> mUserDataQ;
|
||||
};
|
||||
|
||||
BluetoothDaemonProtocol::BluetoothDaemonProtocol()
|
||||
@ -1498,14 +1510,13 @@ BluetoothDaemonProtocol::UnregisterModule(uint8_t aId,
|
||||
}
|
||||
|
||||
nsresult
|
||||
BluetoothDaemonProtocol::Send(DaemonSocketPDU* aPDU,
|
||||
DaemonSocketResultHandler* aRes)
|
||||
BluetoothDaemonProtocol::Send(DaemonSocketPDU* aPDU, void* aUserData)
|
||||
{
|
||||
MOZ_ASSERT(mConnection);
|
||||
MOZ_ASSERT(aPDU);
|
||||
|
||||
aPDU->SetConsumer(this);
|
||||
aPDU->SetResultHandler(aRes);
|
||||
aPDU->SetUserData(aUserData);
|
||||
aPDU->UpdateHeader();
|
||||
|
||||
if (mConnection->GetConnectionStatus() == SOCKET_DISCONNECTED) {
|
||||
@ -1521,65 +1532,64 @@ BluetoothDaemonProtocol::Send(DaemonSocketPDU* aPDU,
|
||||
void
|
||||
BluetoothDaemonProtocol::HandleSetupSvc(
|
||||
const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU,
|
||||
DaemonSocketResultHandler* aRes)
|
||||
void* aUserData)
|
||||
{
|
||||
BluetoothDaemonSetupModule::HandleSvc(aHeader, aPDU, aRes);
|
||||
BluetoothDaemonSetupModule::HandleSvc(aHeader, aPDU, aUserData);
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothDaemonProtocol::HandleCoreSvc(
|
||||
const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU,
|
||||
DaemonSocketResultHandler* aRes)
|
||||
void* aUserData)
|
||||
{
|
||||
BluetoothDaemonCoreModule::HandleSvc(aHeader, aPDU, aRes);
|
||||
BluetoothDaemonCoreModule::HandleSvc(aHeader, aPDU, aUserData);
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothDaemonProtocol::HandleSocketSvc(
|
||||
const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU,
|
||||
DaemonSocketResultHandler* aRes)
|
||||
void* aUserData)
|
||||
{
|
||||
BluetoothDaemonSocketModule::HandleSvc(aHeader, aPDU, aRes);
|
||||
BluetoothDaemonSocketModule::HandleSvc(aHeader, aPDU, aUserData);
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothDaemonProtocol::HandleHandsfreeSvc(
|
||||
const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU,
|
||||
DaemonSocketResultHandler* aRes)
|
||||
void* aUserData)
|
||||
{
|
||||
BluetoothDaemonHandsfreeModule::HandleSvc(aHeader, aPDU, aRes);
|
||||
BluetoothDaemonHandsfreeModule::HandleSvc(aHeader, aPDU, aUserData);
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothDaemonProtocol::HandleA2dpSvc(
|
||||
const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU,
|
||||
DaemonSocketResultHandler* aRes)
|
||||
void* aUserData)
|
||||
{
|
||||
BluetoothDaemonA2dpModule::HandleSvc(aHeader, aPDU, aRes);
|
||||
BluetoothDaemonA2dpModule::HandleSvc(aHeader, aPDU, aUserData);
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothDaemonProtocol::HandleAvrcpSvc(
|
||||
const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU,
|
||||
DaemonSocketResultHandler* aRes)
|
||||
void* aUserData)
|
||||
{
|
||||
BluetoothDaemonAvrcpModule::HandleSvc(aHeader, aPDU, aRes);
|
||||
BluetoothDaemonAvrcpModule::HandleSvc(aHeader, aPDU, aUserData);
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothDaemonProtocol::HandleGattSvc(
|
||||
const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU,
|
||||
DaemonSocketResultHandler* aRes)
|
||||
void* aUserData)
|
||||
{
|
||||
BluetoothDaemonGattModule::HandleSvc(aHeader, aPDU, aRes);
|
||||
BluetoothDaemonGattModule::HandleSvc(aHeader, aPDU, aUserData);
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothDaemonProtocol::Handle(DaemonSocketPDU& aPDU)
|
||||
{
|
||||
static void (BluetoothDaemonProtocol::* const HandleSvc[])(
|
||||
const DaemonSocketPDUHeader&, DaemonSocketPDU&,
|
||||
DaemonSocketResultHandler*) = {
|
||||
const DaemonSocketPDUHeader&, DaemonSocketPDU&, void*) = {
|
||||
[0x00] = &BluetoothDaemonProtocol::HandleSetupSvc,
|
||||
[0x01] = &BluetoothDaemonProtocol::HandleCoreSvc,
|
||||
[0x02] = &BluetoothDaemonProtocol::HandleSocketSvc,
|
||||
@ -1604,22 +1614,19 @@ BluetoothDaemonProtocol::Handle(DaemonSocketPDU& aPDU)
|
||||
return;
|
||||
}
|
||||
|
||||
nsRefPtr<DaemonSocketResultHandler> res = FetchResultHandler(header);
|
||||
|
||||
(this->*(HandleSvc[header.mService]))(header, aPDU, res);
|
||||
(this->*(HandleSvc[header.mService]))(header, aPDU, FetchUserData(header));
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothDaemonProtocol::StoreResultHandler(const DaemonSocketPDU& aPDU)
|
||||
BluetoothDaemonProtocol::StoreUserData(const DaemonSocketPDU& aPDU)
|
||||
{
|
||||
MOZ_ASSERT(!NS_IsMainThread());
|
||||
|
||||
mResQ.AppendElement(aPDU.GetResultHandler());
|
||||
mUserDataQ.AppendElement(aPDU.GetUserData());
|
||||
}
|
||||
|
||||
already_AddRefed<DaemonSocketResultHandler>
|
||||
BluetoothDaemonProtocol::FetchResultHandler(
|
||||
const DaemonSocketPDUHeader& aHeader)
|
||||
void*
|
||||
BluetoothDaemonProtocol::FetchUserData(const DaemonSocketPDUHeader& aHeader)
|
||||
{
|
||||
MOZ_ASSERT(!NS_IsMainThread());
|
||||
|
||||
@ -1627,10 +1634,10 @@ BluetoothDaemonProtocol::FetchResultHandler(
|
||||
return nullptr; // Ignore notifications
|
||||
}
|
||||
|
||||
nsRefPtr<DaemonSocketResultHandler> userData = mResQ.ElementAt(0);
|
||||
mResQ.RemoveElementAt(0);
|
||||
void* userData = mUserDataQ.ElementAt(0);
|
||||
mUserDataQ.RemoveElementAt(0);
|
||||
|
||||
return userData.forget();
|
||||
return userData;
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -160,7 +160,7 @@ BluetoothDaemonSocketModule::CloseCmd(BluetoothSocketResultHandler* aRes)
|
||||
void
|
||||
BluetoothDaemonSocketModule::HandleSvc(const DaemonSocketPDUHeader& aHeader,
|
||||
DaemonSocketPDU& aPDU,
|
||||
DaemonSocketResultHandler* aRes)
|
||||
void* aUserData)
|
||||
{
|
||||
static void (BluetoothDaemonSocketModule::* const HandleRsp[])(
|
||||
const DaemonSocketPDUHeader&,
|
||||
@ -177,7 +177,8 @@ BluetoothDaemonSocketModule::HandleSvc(const DaemonSocketPDUHeader& aHeader,
|
||||
}
|
||||
|
||||
nsRefPtr<BluetoothSocketResultHandler> res =
|
||||
static_cast<BluetoothSocketResultHandler*>(aRes);
|
||||
already_AddRefed<BluetoothSocketResultHandler>(
|
||||
static_cast<BluetoothSocketResultHandler*>(aUserData));
|
||||
|
||||
if (!res) {
|
||||
return; // Return early if no result handler has been set
|
||||
@ -186,6 +187,19 @@ BluetoothDaemonSocketModule::HandleSvc(const DaemonSocketPDUHeader& aHeader,
|
||||
(this->*(HandleRsp[aHeader.mOpcode]))(aHeader, aPDU, res);
|
||||
}
|
||||
|
||||
nsresult
|
||||
BluetoothDaemonSocketModule::Send(DaemonSocketPDU* aPDU,
|
||||
BluetoothSocketResultHandler* aRes)
|
||||
{
|
||||
nsRefPtr<BluetoothSocketResultHandler> res(aRes);
|
||||
nsresult rv = Send(aPDU, static_cast<void*>(res.get()));
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
unused << res.forget(); // Keep reference for response
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
uint8_t
|
||||
BluetoothDaemonSocketModule::SocketFlags(bool aEncrypt, bool aAuth)
|
||||
{
|
||||
|
@ -15,15 +15,13 @@ BEGIN_BLUETOOTH_NAMESPACE
|
||||
|
||||
using mozilla::ipc::DaemonSocketPDU;
|
||||
using mozilla::ipc::DaemonSocketPDUHeader;
|
||||
using mozilla::ipc::DaemonSocketResultHandler;
|
||||
|
||||
class BluetoothDaemonSocketModule
|
||||
{
|
||||
public:
|
||||
static const int MAX_NUM_CLIENTS;
|
||||
|
||||
virtual nsresult Send(DaemonSocketPDU* aPDU,
|
||||
DaemonSocketResultHandler* aRes) = 0;
|
||||
virtual nsresult Send(DaemonSocketPDU* aPDU, void* aUserData) = 0;
|
||||
|
||||
// Commands
|
||||
//
|
||||
@ -47,7 +45,9 @@ public:
|
||||
protected:
|
||||
|
||||
void HandleSvc(const DaemonSocketPDUHeader& aHeader,
|
||||
DaemonSocketPDU& aPDU, DaemonSocketResultHandler* aRes);
|
||||
DaemonSocketPDU& aPDU, void* aUserData);
|
||||
|
||||
nsresult Send(DaemonSocketPDU* aPDU, BluetoothSocketResultHandler* aRes);
|
||||
|
||||
private:
|
||||
class AcceptWatcher;
|
||||
|
@ -23,7 +23,7 @@ public:
|
||||
virtual ~DaemonSocketIOConsumer();
|
||||
|
||||
virtual void Handle(DaemonSocketPDU& aPDU) = 0;
|
||||
virtual void StoreResultHandler(const DaemonSocketPDU& aPDU) = 0;
|
||||
virtual void StoreUserData(const DaemonSocketPDU& aPDU) = 0;
|
||||
|
||||
protected:
|
||||
DaemonSocketIOConsumer();
|
||||
|
@ -29,8 +29,9 @@ namespace ipc {
|
||||
//
|
||||
|
||||
DaemonSocketPDU::DaemonSocketPDU(uint8_t aService, uint8_t aOpcode,
|
||||
uint16_t aPayloadSize)
|
||||
uint16_t aPayloadSize)
|
||||
: mConsumer(nullptr)
|
||||
, mUserData(nullptr)
|
||||
{
|
||||
MOZ_COUNT_CTOR_INHERITED(DaemonSocketPDU, UnixSocketIOBuffer);
|
||||
|
||||
@ -50,6 +51,7 @@ DaemonSocketPDU::DaemonSocketPDU(uint8_t aService, uint8_t aOpcode,
|
||||
|
||||
DaemonSocketPDU::DaemonSocketPDU(size_t aPayloadSize)
|
||||
: mConsumer(nullptr)
|
||||
, mUserData(nullptr)
|
||||
{
|
||||
MOZ_COUNT_CTOR_INHERITED(DaemonSocketPDU, UnixSocketIOBuffer);
|
||||
|
||||
@ -100,8 +102,8 @@ DaemonSocketPDU::Send(int aFd)
|
||||
|
||||
if (mConsumer) {
|
||||
// We successfully sent a PDU, now store the
|
||||
// result handler in the consumer.
|
||||
mConsumer->StoreResultHandler(*this);
|
||||
// result runnable in the consumer.
|
||||
mConsumer->StoreUserData(*this);
|
||||
}
|
||||
|
||||
return res;
|
||||
|
@ -9,7 +9,6 @@
|
||||
|
||||
#include "mozilla/FileUtils.h"
|
||||
#include "mozilla/ipc/SocketBase.h"
|
||||
#include "mozilla/ipc/DaemonSocketMessageHandlers.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace ipc {
|
||||
@ -56,14 +55,14 @@ public:
|
||||
mConsumer = aConsumer;
|
||||
}
|
||||
|
||||
void SetResultHandler(DaemonSocketResultHandler* aRes)
|
||||
void SetUserData(void* aUserData)
|
||||
{
|
||||
mRes = aRes;
|
||||
mUserData = aUserData;
|
||||
}
|
||||
|
||||
DaemonSocketResultHandler* GetResultHandler() const
|
||||
void* GetUserData() const
|
||||
{
|
||||
return mRes;
|
||||
return mUserData;
|
||||
}
|
||||
|
||||
void GetHeader(uint8_t& aService, uint8_t& aOpcode,
|
||||
@ -81,7 +80,7 @@ private:
|
||||
void OnError(const char* aFunction, int aErrno);
|
||||
|
||||
DaemonSocketIOConsumer* mConsumer;
|
||||
nsRefPtr<DaemonSocketResultHandler> mRes;
|
||||
void* mUserData;
|
||||
ScopedClose mReceivedFd;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user