diff --git a/dom/bluetooth/bluedroid/BluetoothDaemonAvrcpInterface.cpp b/dom/bluetooth/bluedroid/BluetoothDaemonAvrcpInterface.cpp index 442bd9ecbf1..a6f55c4ff96 100644 --- a/dom/bluetooth/bluedroid/BluetoothDaemonAvrcpInterface.cpp +++ b/dom/bluetooth/bluedroid/BluetoothDaemonAvrcpInterface.cpp @@ -550,7 +550,7 @@ public: nsresult operator () (uint8_t& aArg1, - nsAutoArrayPtr& aArg2) const + UniquePtr& aArg2) const { DaemonSocketPDU& pdu = GetPDU(); @@ -591,7 +591,7 @@ public: nsresult operator () (uint8_t& aArg1, - nsAutoArrayPtr& aArg2) const + UniquePtr& aArg2) const { DaemonSocketPDU& pdu = GetPDU(); @@ -632,7 +632,7 @@ public: nsresult operator () (uint8_t& aArg1, uint8_t& aArg2, - nsAutoArrayPtr& aArg3) const + UniquePtr& aArg3) const { DaemonSocketPDU& pdu = GetPDU(); @@ -687,7 +687,7 @@ public: nsresult operator () (uint8_t& aArg1, - nsAutoArrayPtr& aArg2) const + UniquePtr& aArg2) const { DaemonSocketPDU& pdu = GetPDU(); diff --git a/dom/bluetooth/bluedroid/BluetoothDaemonAvrcpInterface.h b/dom/bluetooth/bluedroid/BluetoothDaemonAvrcpInterface.h index cfad818e9c3..f4529a9a88c 100644 --- a/dom/bluetooth/bluedroid/BluetoothDaemonAvrcpInterface.h +++ b/dom/bluetooth/bluedroid/BluetoothDaemonAvrcpInterface.h @@ -199,19 +199,19 @@ protected: typedef mozilla::ipc::DaemonNotificationRunnable2< NotificationHandlerWrapper, void, uint8_t, - nsAutoArrayPtr, + UniquePtr, uint8_t, const BluetoothAvrcpPlayerAttribute*> GetPlayerAppValueNotification; typedef mozilla::ipc::DaemonNotificationRunnable2< NotificationHandlerWrapper, void, uint8_t, - nsAutoArrayPtr, + UniquePtr, uint8_t, const BluetoothAvrcpPlayerAttribute*> GetPlayerAppAttrsTextNotification; typedef mozilla::ipc::DaemonNotificationRunnable3< NotificationHandlerWrapper, void, uint8_t, uint8_t, - nsAutoArrayPtr, uint8_t, uint8_t, const uint8_t*> + UniquePtr, uint8_t, uint8_t, const uint8_t*> GetPlayerAppValuesTextNotification; typedef mozilla::ipc::DaemonNotificationRunnable1< @@ -221,7 +221,7 @@ protected: typedef mozilla::ipc::DaemonNotificationRunnable2< NotificationHandlerWrapper, void, uint8_t, - nsAutoArrayPtr, + UniquePtr, uint8_t, const BluetoothAvrcpMediaAttribute*> GetElementAttrNotification; diff --git a/dom/bluetooth/bluedroid/BluetoothDaemonCoreInterface.cpp b/dom/bluetooth/bluedroid/BluetoothDaemonCoreInterface.cpp index cd397d3c97b..2df03af555c 100644 --- a/dom/bluetooth/bluedroid/BluetoothDaemonCoreInterface.cpp +++ b/dom/bluetooth/bluedroid/BluetoothDaemonCoreInterface.cpp @@ -796,7 +796,7 @@ public: nsresult operator () (BluetoothStatus& aArg1, int& aArg2, - nsAutoArrayPtr& aArg3) const + UniquePtr& aArg3) const { DaemonSocketPDU& pdu = GetPDU(); @@ -845,7 +845,7 @@ public: nsresult operator () (BluetoothStatus& aArg1, BluetoothAddress& aArg2, int& aArg3, - nsAutoArrayPtr& aArg4) const + UniquePtr& aArg4) const { DaemonSocketPDU& pdu = GetPDU(); @@ -899,7 +899,7 @@ public: { } nsresult - operator () (int& aArg1, nsAutoArrayPtr& aArg2) const + operator () (int& aArg1, UniquePtr& aArg2) const { DaemonSocketPDU& pdu = GetPDU(); @@ -986,7 +986,7 @@ public: { } nsresult - operator () (uint16_t& aArg1, nsAutoArrayPtr& aArg2, + operator () (uint16_t& aArg1, UniquePtr& aArg2, uint8_t& aArg3) const { DaemonSocketPDU& pdu = GetPDU(); diff --git a/dom/bluetooth/bluedroid/BluetoothDaemonCoreInterface.h b/dom/bluetooth/bluedroid/BluetoothDaemonCoreInterface.h index 0d6f03d47ef..1cb6e021f12 100644 --- a/dom/bluetooth/bluedroid/BluetoothDaemonCoreInterface.h +++ b/dom/bluetooth/bluedroid/BluetoothDaemonCoreInterface.h @@ -244,18 +244,18 @@ private: typedef mozilla::ipc::DaemonNotificationRunnable3< NotificationHandlerWrapper, void, BluetoothStatus, int, - nsAutoArrayPtr, BluetoothStatus, int, + UniquePtr, BluetoothStatus, int, const BluetoothProperty*> AdapterPropertiesNotification; typedef mozilla::ipc::DaemonNotificationRunnable4< NotificationHandlerWrapper, void, BluetoothStatus, BluetoothAddress, int, - nsAutoArrayPtr, BluetoothStatus, + UniquePtr, BluetoothStatus, const BluetoothAddress&, int, const BluetoothProperty*> RemoteDevicePropertiesNotification; typedef mozilla::ipc::DaemonNotificationRunnable2< - NotificationHandlerWrapper, void, int, nsAutoArrayPtr, + NotificationHandlerWrapper, void, int, UniquePtr, int, const BluetoothProperty*> DeviceFoundNotification; @@ -288,7 +288,7 @@ private: AclStateChangedNotification; typedef mozilla::ipc::DaemonNotificationRunnable3< - NotificationHandlerWrapper, void, uint16_t, nsAutoArrayPtr, + NotificationHandlerWrapper, void, uint16_t, UniquePtr, uint8_t, uint16_t, const uint8_t*> DutModeRecvNotification; diff --git a/dom/bluetooth/bluedroid/BluetoothDaemonGattInterface.cpp b/dom/bluetooth/bluedroid/BluetoothDaemonGattInterface.cpp index e99f979d299..a2df2757cb1 100644 --- a/dom/bluetooth/bluedroid/BluetoothDaemonGattInterface.cpp +++ b/dom/bluetooth/bluedroid/BluetoothDaemonGattInterface.cpp @@ -1972,7 +1972,7 @@ public: BluetoothAttributeHandle& aArg4, int& aArg5, int& aArg6, - nsAutoArrayPtr& aArg7, + UniquePtr& aArg7, bool& aArg8, bool& aArg9) const { diff --git a/dom/bluetooth/bluedroid/BluetoothDaemonGattInterface.h b/dom/bluetooth/bluedroid/BluetoothDaemonGattInterface.h index b438d513694..84d23916418 100644 --- a/dom/bluetooth/bluedroid/BluetoothDaemonGattInterface.h +++ b/dom/bluetooth/bluedroid/BluetoothDaemonGattInterface.h @@ -653,7 +653,7 @@ protected: typedef mozilla::ipc::DaemonNotificationRunnable9< NotificationHandlerWrapper, void, int, int, BluetoothAddress, BluetoothAttributeHandle, - int, int, nsAutoArrayPtr, bool, bool, + int, int, UniquePtr, bool, bool, int, int, const BluetoothAddress&, const BluetoothAttributeHandle&, int, int, const uint8_t*, bool, bool> ServerRequestWriteNotification; diff --git a/ipc/hal/DaemonRunnables.h b/ipc/hal/DaemonRunnables.h index e067dd14119..d649ce303b5 100644 --- a/ipc/hal/DaemonRunnables.h +++ b/ipc/hal/DaemonRunnables.h @@ -8,11 +8,35 @@ #define mozilla_ipc_DaemonRunnables_h #include "mozilla/unused.h" +#include "mozilla/UniquePtr.h" #include "nsThreadUtils.h" namespace mozilla { namespace ipc { +namespace details { + +class DaemonRunnable : public nsRunnable +{ +protected: + DaemonRunnable() = default; + virtual ~DaemonRunnable() = default; + + template + static Out& ConvertArg(In& aArg) + { + return aArg; + } + + template + static Out ConvertArg(UniquePtr& aArg) + { + return aArg.get(); + } +}; + +} // namespace detail + // // Result handling // @@ -30,7 +54,7 @@ namespace ipc { // template -class DaemonResultRunnable0 final : public nsRunnable +class DaemonResultRunnable0 final : public details::DaemonRunnable { public: typedef DaemonResultRunnable0 SelfType; @@ -86,7 +110,7 @@ private: }; template -class DaemonResultRunnable1 final : public nsRunnable +class DaemonResultRunnable1 final : public details::DaemonRunnable { public: typedef DaemonResultRunnable1 SelfType; @@ -118,7 +142,7 @@ public: NS_IMETHODIMP Run() override { - ((*mObj).*mMethod)(mArg1); + ((*mObj).*mMethod)(ConvertArg(mArg1)); return NS_OK; } @@ -145,7 +169,7 @@ private: template -class DaemonResultRunnable3 final : public nsRunnable +class DaemonResultRunnable3 final : public details::DaemonRunnable { public: typedef DaemonResultRunnable3(mArg1), + ConvertArg(mArg2), + ConvertArg(mArg3)); return NS_OK; } @@ -226,7 +252,7 @@ private: // template -class DaemonNotificationRunnable0 final : public nsRunnable +class DaemonNotificationRunnable0 final : public details::DaemonRunnable { public: typedef typename ObjectWrapper::ObjectType ObjectType; @@ -285,7 +311,7 @@ private: template -class DaemonNotificationRunnable1 final : public nsRunnable +class DaemonNotificationRunnable1 final : public details::DaemonRunnable { public: typedef typename ObjectWrapper::ObjectType ObjectType; @@ -322,7 +348,7 @@ public: if (!obj) { NS_WARNING("Notification handler not initialized"); } else { - ((*obj).*mMethod)(mArg1); + ((*obj).*mMethod)(ConvertArg(mArg1)); } return NS_OK; } @@ -351,7 +377,7 @@ private: template -class DaemonNotificationRunnable2 final : public nsRunnable +class DaemonNotificationRunnable2 final : public details::DaemonRunnable { public: typedef typename ObjectWrapper::ObjectType ObjectType; @@ -389,7 +415,8 @@ public: if (!obj) { NS_WARNING("Notification handler not initialized"); } else { - ((*obj).*mMethod)(mArg1, mArg2); + ((*obj).*mMethod)(ConvertArg(mArg1), + ConvertArg(mArg2)); } return NS_OK; } @@ -420,7 +447,7 @@ private: template -class DaemonNotificationRunnable3 final : public nsRunnable +class DaemonNotificationRunnable3 final : public details::DaemonRunnable { public: typedef typename ObjectWrapper::ObjectType ObjectType; @@ -459,7 +486,9 @@ public: if (!obj) { NS_WARNING("Notification handler not initialized"); } else { - ((*obj).*mMethod)(mArg1, mArg2, mArg3); + ((*obj).*mMethod)(ConvertArg(mArg1), + ConvertArg(mArg2), + ConvertArg(mArg3)); } return NS_OK; } @@ -492,7 +521,7 @@ template -class DaemonNotificationRunnable4 final : public nsRunnable +class DaemonNotificationRunnable4 final : public details::DaemonRunnable { public: typedef typename ObjectWrapper::ObjectType ObjectType; @@ -531,7 +560,10 @@ public: if (!obj) { NS_WARNING("Notification handler not initialized"); } else { - ((*obj).*mMethod)(mArg1, mArg2, mArg3, mArg4); + ((*obj).*mMethod)(ConvertArg(mArg1), + ConvertArg(mArg2), + ConvertArg(mArg3), + ConvertArg(mArg4)); } return NS_OK; } @@ -566,7 +598,7 @@ template -class DaemonNotificationRunnable5 final : public nsRunnable +class DaemonNotificationRunnable5 final : public details::DaemonRunnable { public: typedef typename ObjectWrapper::ObjectType ObjectType; @@ -605,7 +637,11 @@ public: if (!obj) { NS_WARNING("Notification handler not initialized"); } else { - ((*obj).*mMethod)(mArg1, mArg2, mArg3, mArg4, mArg5); + ((*obj).*mMethod)(ConvertArg(mArg1), + ConvertArg(mArg2), + ConvertArg(mArg3), + ConvertArg(mArg4), + ConvertArg(mArg5)); } return NS_OK; } @@ -641,7 +677,7 @@ template -class DaemonNotificationRunnable6 final : public nsRunnable +class DaemonNotificationRunnable6 final : public details::DaemonRunnable { public: typedef typename ObjectWrapper::ObjectType ObjectType; @@ -681,7 +717,12 @@ public: if (!obj) { NS_WARNING("Notification handler not initialized"); } else { - ((*obj).*mMethod)(mArg1, mArg2, mArg3, mArg4, mArg5, mArg6); + ((*obj).*mMethod)(ConvertArg(mArg1), + ConvertArg(mArg2), + ConvertArg(mArg3), + ConvertArg(mArg4), + ConvertArg(mArg5), + ConvertArg(mArg6)); } return NS_OK; } @@ -720,7 +761,7 @@ template -class DaemonNotificationRunnable8 final : public nsRunnable +class DaemonNotificationRunnable8 final : public details::DaemonRunnable { public: typedef typename ObjectWrapper::ObjectType ObjectType; @@ -763,8 +804,14 @@ public: if (!obj) { NS_WARNING("Notification handler not initialized"); } else { - ((*obj).*mMethod)(mArg1, mArg2, mArg3, mArg4, - mArg5, mArg6, mArg7, mArg8); + ((*obj).*mMethod)(ConvertArg(mArg1), + ConvertArg(mArg2), + ConvertArg(mArg3), + ConvertArg(mArg4), + ConvertArg(mArg5), + ConvertArg(mArg6), + ConvertArg(mArg7), + ConvertArg(mArg8)); } return NS_OK; } @@ -808,7 +855,7 @@ template -class DaemonNotificationRunnable9 final : public nsRunnable +class DaemonNotificationRunnable9 final : public details::DaemonRunnable { public: typedef typename ObjectWrapper::ObjectType ObjectType; @@ -851,8 +898,15 @@ public: if (!obj) { NS_WARNING("Notification handler not initialized"); } else { - ((*obj).*mMethod)(mArg1, mArg2, mArg3, mArg4, - mArg5, mArg6, mArg7, mArg8, mArg9); + ((*obj).*mMethod)(ConvertArg(mArg1), + ConvertArg(mArg2), + ConvertArg(mArg3), + ConvertArg(mArg4), + ConvertArg(mArg5), + ConvertArg(mArg6), + ConvertArg(mArg7), + ConvertArg(mArg8), + ConvertArg(mArg9)); } return NS_OK; } diff --git a/ipc/hal/DaemonSocketPDUHelpers.h b/ipc/hal/DaemonSocketPDUHelpers.h index 02f672f0ed5..38a848e461f 100644 --- a/ipc/hal/DaemonSocketPDUHelpers.h +++ b/ipc/hal/DaemonSocketPDUHelpers.h @@ -9,6 +9,7 @@ #include #include "mozilla/ipc/DaemonSocketPDU.h" +#include "mozilla/UniquePtr.h" #include "nsString.h" namespace mozilla { @@ -786,19 +787,19 @@ struct UnpackArray , mLength(aLength) { } - UnpackArray(nsAutoArrayPtr& aData, size_t aLength) + UnpackArray(UniquePtr& aData, size_t aLength) : mData(nullptr) , mLength(aLength) { - aData = new T[mLength]; + aData.reset(new T[mLength]); mData = aData.get(); } - UnpackArray(nsAutoArrayPtr& aData, size_t aSize, size_t aElemSize) + UnpackArray(UniquePtr& aData, size_t aSize, size_t aElemSize) : mData(nullptr) , mLength(aSize / aElemSize) { - aData = new T[mLength]; + aData.reset(new T[mLength]); mData = aData.get(); }