From 9c1afc7d890e0b6362bc9a7c0943b899ef46fa4e Mon Sep 17 00:00:00 2001 From: Thomas Zimmermann Date: Tue, 6 Oct 2015 10:08:14 +0200 Subject: [PATCH] Bug 1209085: Replace simple init ops by |UnpackInitOp| in Bluetooth Core backend, r=joliu --- .../BluetoothDaemonCoreInterface.cpp | 169 +----------------- .../bluedroid/BluetoothDaemonCoreInterface.h | 4 - 2 files changed, 4 insertions(+), 169 deletions(-) diff --git a/dom/bluetooth/bluedroid/BluetoothDaemonCoreInterface.cpp b/dom/bluetooth/bluedroid/BluetoothDaemonCoreInterface.cpp index 986ef448ed6c..a0402802e173 100644 --- a/dom/bluetooth/bluedroid/BluetoothDaemonCoreInterface.cpp +++ b/dom/bluetooth/bluedroid/BluetoothDaemonCoreInterface.cpp @@ -945,201 +945,40 @@ BluetoothDaemonCoreModule::DiscoveryStateChangedNtf( 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 BluetoothDaemonCoreModule::PinRequestNtf( const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU) { PinRequestNotification::Dispatch( &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 BluetoothDaemonCoreModule::SspRequestNtf( const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU) { SspRequestNotification::Dispatch( &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 BluetoothDaemonCoreModule::BondStateChangedNtf( const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU) { BondStateChangedNotification::Dispatch( &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 BluetoothDaemonCoreModule::AclStateChangedNtf( const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU) { AclStateChangedNotification::Dispatch( &BluetoothNotificationHandler::AclStateChangedNotification, - AclStateChangedInitOp(aPDU)); + UnpackPDUInitOp(aPDU)); } // Init operator class for DutModeRecvNotification diff --git a/dom/bluetooth/bluedroid/BluetoothDaemonCoreInterface.h b/dom/bluetooth/bluedroid/BluetoothDaemonCoreInterface.h index aa24f889628e..f40506ca469f 100644 --- a/dom/bluetooth/bluedroid/BluetoothDaemonCoreInterface.h +++ b/dom/bluetooth/bluedroid/BluetoothDaemonCoreInterface.h @@ -298,14 +298,10 @@ private: NotificationHandlerWrapper, void, BluetoothStatus, uint16_t> LeTestModeNotification; - class AclStateChangedInitOp; class AdapterPropertiesInitOp; - class BondStateChangedInitOp; class DeviceFoundInitOp; class DutModeRecvInitOp; - class PinRequestInitOp; class RemoteDevicePropertiesInitOp; - class SspRequestInitOp; void AdapterStateChangedNtf(const DaemonSocketPDUHeader& aHeader, DaemonSocketPDU& aPDU);