Bug 1209085: Replace simple init ops by |UnpackInitOp| in Bluetooth Core backend, r=joliu

This commit is contained in:
Thomas Zimmermann 2015-10-06 10:08:14 +02:00
Родитель ec9f010e9f
Коммит 9c1afc7d89
2 изменённых файлов: 4 добавлений и 169 удалений

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

@ -945,201 +945,40 @@ BluetoothDaemonCoreModule::DiscoveryStateChangedNtf(
UnpackPDUInitOp(aPDU)); UnpackPDUInitOp(aPDU));
} }
// Init operator class for PinRequestNotification
class BluetoothDaemonCoreModule::PinRequestInitOp final
: private PDUInitOp
{
public:
PinRequestInitOp(DaemonSocketPDU& aPDU)
: PDUInitOp(aPDU)
{ }
nsresult
operator () (BluetoothAddress& aArg1, BluetoothRemoteName& aArg2,
uint32_t& aArg3) const
{
DaemonSocketPDU& pdu = GetPDU();
/* Read remote address */
nsresult rv = UnpackPDU(pdu, aArg1);
if (NS_FAILED(rv)) {
return rv;
}
/* Read remote name */
rv = UnpackPDU(pdu, aArg2);
if (NS_FAILED(rv)) {
return rv;
}
/* Read CoD */
rv = UnpackPDU(pdu, aArg3);
if (NS_FAILED(rv)) {
return rv;
}
WarnAboutTrailingData();
return NS_OK;
}
};
void void
BluetoothDaemonCoreModule::PinRequestNtf( BluetoothDaemonCoreModule::PinRequestNtf(
const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU) const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU)
{ {
PinRequestNotification::Dispatch( PinRequestNotification::Dispatch(
&BluetoothNotificationHandler::PinRequestNotification, &BluetoothNotificationHandler::PinRequestNotification,
PinRequestInitOp(aPDU)); UnpackPDUInitOp(aPDU));
} }
// Init operator class for SspRequestNotification
class BluetoothDaemonCoreModule::SspRequestInitOp final
: private PDUInitOp
{
public:
SspRequestInitOp(DaemonSocketPDU& aPDU)
: PDUInitOp(aPDU)
{ }
nsresult
operator () (BluetoothAddress& aArg1, BluetoothRemoteName& aArg2,
uint32_t& aArg3, BluetoothSspVariant& aArg4,
uint32_t& aArg5) const
{
DaemonSocketPDU& pdu = GetPDU();
/* Read remote address */
nsresult rv = UnpackPDU(pdu, aArg1);
if (NS_FAILED(rv)) {
return rv;
}
/* Read remote name */
rv = UnpackPDU(pdu, aArg2);
if (NS_FAILED(rv)) {
return rv;
}
/* Read CoD */
rv = UnpackPDU(pdu, aArg3);
if (NS_FAILED(rv)) {
return rv;
}
/* Read pairing variant */
rv = UnpackPDU(pdu, aArg4);
if (NS_FAILED(rv)) {
return rv;
}
/* Read passkey */
rv = UnpackPDU(pdu, aArg5);
if (NS_FAILED(rv)) {
return rv;
}
WarnAboutTrailingData();
return NS_OK;
}
};
void void
BluetoothDaemonCoreModule::SspRequestNtf( BluetoothDaemonCoreModule::SspRequestNtf(
const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU) const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU)
{ {
SspRequestNotification::Dispatch( SspRequestNotification::Dispatch(
&BluetoothNotificationHandler::SspRequestNotification, &BluetoothNotificationHandler::SspRequestNotification,
SspRequestInitOp(aPDU)); UnpackPDUInitOp(aPDU));
} }
// Init operator class for BondStateChangedNotification
class BluetoothDaemonCoreModule::BondStateChangedInitOp final
: private PDUInitOp
{
public:
BondStateChangedInitOp(DaemonSocketPDU& aPDU)
: PDUInitOp(aPDU)
{ }
nsresult
operator () (BluetoothStatus& aArg1, BluetoothAddress& aArg2,
BluetoothBondState& aArg3) const
{
DaemonSocketPDU& pdu = GetPDU();
/* Read status */
nsresult rv = UnpackPDU(pdu, aArg1);
if (NS_FAILED(rv)) {
return rv;
}
/* Read remote address */
rv = UnpackPDU(pdu, aArg2);
if (NS_FAILED(rv)) {
return rv;
}
/* Read bond state */
rv = UnpackPDU(pdu, aArg3);
if (NS_FAILED(rv)) {
return rv;
}
WarnAboutTrailingData();
return NS_OK;
}
};
void void
BluetoothDaemonCoreModule::BondStateChangedNtf( BluetoothDaemonCoreModule::BondStateChangedNtf(
const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU) const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU)
{ {
BondStateChangedNotification::Dispatch( BondStateChangedNotification::Dispatch(
&BluetoothNotificationHandler::BondStateChangedNotification, &BluetoothNotificationHandler::BondStateChangedNotification,
BondStateChangedInitOp(aPDU)); UnpackPDUInitOp(aPDU));
} }
// Init operator class for AclStateChangedNotification
class BluetoothDaemonCoreModule::AclStateChangedInitOp final
: private PDUInitOp
{
public:
AclStateChangedInitOp(DaemonSocketPDU& aPDU)
: PDUInitOp(aPDU)
{ }
nsresult
operator () (BluetoothStatus& aArg1, BluetoothAddress& aArg2,
BluetoothAclState& aArg3) const
{
DaemonSocketPDU& pdu = GetPDU();
/* Read status */
nsresult rv = UnpackPDU(pdu, aArg1);
if (NS_FAILED(rv)) {
return rv;
}
/* Read remote address */
rv = UnpackPDU(pdu, aArg2);
if (NS_FAILED(rv)) {
return rv;
}
/* Read ACL state */
rv = UnpackPDU(pdu, aArg3);
if (NS_FAILED(rv)) {
return rv;
}
WarnAboutTrailingData();
return NS_OK;
}
};
void void
BluetoothDaemonCoreModule::AclStateChangedNtf( BluetoothDaemonCoreModule::AclStateChangedNtf(
const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU) const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU)
{ {
AclStateChangedNotification::Dispatch( AclStateChangedNotification::Dispatch(
&BluetoothNotificationHandler::AclStateChangedNotification, &BluetoothNotificationHandler::AclStateChangedNotification,
AclStateChangedInitOp(aPDU)); UnpackPDUInitOp(aPDU));
} }
// Init operator class for DutModeRecvNotification // Init operator class for DutModeRecvNotification

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

@ -298,14 +298,10 @@ private:
NotificationHandlerWrapper, void, BluetoothStatus, uint16_t> NotificationHandlerWrapper, void, BluetoothStatus, uint16_t>
LeTestModeNotification; LeTestModeNotification;
class AclStateChangedInitOp;
class AdapterPropertiesInitOp; class AdapterPropertiesInitOp;
class BondStateChangedInitOp;
class DeviceFoundInitOp; class DeviceFoundInitOp;
class DutModeRecvInitOp; class DutModeRecvInitOp;
class PinRequestInitOp;
class RemoteDevicePropertiesInitOp; class RemoteDevicePropertiesInitOp;
class SspRequestInitOp;
void AdapterStateChangedNtf(const DaemonSocketPDUHeader& aHeader, void AdapterStateChangedNtf(const DaemonSocketPDUHeader& aHeader,
DaemonSocketPDU& aPDU); DaemonSocketPDU& aPDU);