Bug 1206686: Use |BluetoothUuid| throughout Bluetooth backend interfaces, r=btian
authorThomas Zimmermann <tdz@users.sourceforge.net>
Tue, 22 Sep 2015 13:04:05 +0200
changeset 263814 1c7ed97b5d611e620782da2e68a77634c5fb1e17
parent 263813 bd660fbaa412aafae28d0e85e51ea2d3583b9c43
child 263815 edecd2b4e214cb9450664fef24c1e4a3bfb82818
push id65448
push userkwierso@gmail.com
push dateTue, 22 Sep 2015 23:46:56 +0000
treeherdermozilla-inbound@eb9c01341845 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbtian
bugs1206686
milestone44.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1206686: Use |BluetoothUuid| throughout Bluetooth backend interfaces, r=btian This patch converts all public interfaces of the Bluetooth backend code to take UUIDs as |BluetoothUuid|. The code currently uses a mixture of |BluetoothUuid| and arrays/pointers.
dom/bluetooth/bluedroid/BluetoothDaemonCoreInterface.cpp
dom/bluetooth/bluedroid/BluetoothDaemonCoreInterface.h
dom/bluetooth/bluedroid/BluetoothDaemonInterface.cpp
dom/bluetooth/bluedroid/BluetoothDaemonInterface.h
dom/bluetooth/bluedroid/BluetoothDaemonSocketInterface.cpp
dom/bluetooth/bluedroid/BluetoothDaemonSocketInterface.h
dom/bluetooth/bluedroid/BluetoothServiceBluedroid.cpp
dom/bluetooth/bluedroid/BluetoothSocket.cpp
dom/bluetooth/common/BluetoothInterface.h
--- a/dom/bluetooth/bluedroid/BluetoothDaemonCoreInterface.cpp
+++ b/dom/bluetooth/bluedroid/BluetoothDaemonCoreInterface.cpp
@@ -221,28 +221,28 @@ BluetoothDaemonCoreModule::SetRemoteDevi
     return rv;
   }
   unused << pdu.forget();
   return rv;
 }
 
 nsresult
 BluetoothDaemonCoreModule::GetRemoteServiceRecordCmd(
-  const nsAString& aRemoteAddr, const uint8_t aUuid[16],
+  const nsAString& aRemoteAddr, const BluetoothUuid& aUuid,
   BluetoothResultHandler* aRes)
 {
   MOZ_ASSERT(NS_IsMainThread());
 
   nsAutoPtr<DaemonSocketPDU> pdu(
     new DaemonSocketPDU(SERVICE_ID, OPCODE_GET_REMOTE_SERVICE_RECORD,
                         0));
 
   nsresult rv = PackPDU(
     PackConversion<nsAString, BluetoothAddress>(aRemoteAddr),
-    PackArray<uint8_t>(aUuid, 16), *pdu);
+    aUuid, *pdu);
   if (NS_FAILED(rv)) {
     return rv;
   }
   rv = Send(pdu, aRes);
   if (NS_FAILED(rv)) {
     return rv;
   }
   unused << pdu.forget();
--- a/dom/bluetooth/bluedroid/BluetoothDaemonCoreInterface.h
+++ b/dom/bluetooth/bluedroid/BluetoothDaemonCoreInterface.h
@@ -92,17 +92,17 @@ public:
                                       const nsAString& aName,
                                       BluetoothResultHandler* aRes);
 
   nsresult SetRemoteDevicePropertyCmd(const nsAString& aRemoteAddr,
                                       const BluetoothNamedValue& aProperty,
                                       BluetoothResultHandler* aRes);
 
   nsresult GetRemoteServiceRecordCmd(const nsAString& aRemoteAddr,
-                                     const uint8_t aUuid[16],
+                                     const BluetoothUuid& aUuid,
                                      BluetoothResultHandler* aRes);
 
   nsresult GetRemoteServicesCmd(const nsAString& aRemoteAddr,
                                 BluetoothResultHandler* aRes);
 
   nsresult StartDiscoveryCmd(BluetoothResultHandler* aRes);
 
   nsresult CancelDiscoveryCmd(BluetoothResultHandler* aRes);
--- a/dom/bluetooth/bluedroid/BluetoothDaemonInterface.cpp
+++ b/dom/bluetooth/bluedroid/BluetoothDaemonInterface.cpp
@@ -699,17 +699,17 @@ BluetoothDaemonInterface::SetRemoteDevic
     DispatchError(aRes, rv);
   }
 }
 
 /* Remote Services */
 
 void
 BluetoothDaemonInterface::GetRemoteServiceRecord(const nsAString& aRemoteAddr,
-                                                 const uint8_t aUuid[16],
+                                                 const BluetoothUuid& aUuid,
                                                  BluetoothResultHandler* aRes)
 {
   nsresult rv = static_cast<BluetoothDaemonCoreModule*>
     (mProtocol)->GetRemoteServiceRecordCmd(aRemoteAddr, aUuid, aRes);
   if (NS_FAILED(rv)) {
     DispatchError(aRes, rv);
   }
 }
--- a/dom/bluetooth/bluedroid/BluetoothDaemonInterface.h
+++ b/dom/bluetooth/bluedroid/BluetoothDaemonInterface.h
@@ -69,17 +69,17 @@ public:
                                BluetoothResultHandler* aRes) override;
   void SetRemoteDeviceProperty(const nsAString& aRemoteAddr,
                                const BluetoothNamedValue& aProperty,
                                BluetoothResultHandler* aRes) override;
 
   /* Remote Services */
 
   void GetRemoteServiceRecord(const nsAString& aRemoteAddr,
-                              const uint8_t aUuid[16],
+                              const BluetoothUuid& aUuid,
                               BluetoothResultHandler* aRes) override;
   void GetRemoteServices(const nsAString& aRemoteAddr,
                          BluetoothResultHandler* aRes) override;
 
   /* Discovery */
 
   void StartDiscovery(BluetoothResultHandler* aRes) override;
   void CancelDiscovery(BluetoothResultHandler* aRes) override;
--- a/dom/bluetooth/bluedroid/BluetoothDaemonSocketInterface.cpp
+++ b/dom/bluetooth/bluedroid/BluetoothDaemonSocketInterface.cpp
@@ -20,62 +20,62 @@ using namespace mozilla::ipc;
 const int BluetoothDaemonSocketModule::MAX_NUM_CLIENTS = 1;
 
 // Commands
 //
 
 nsresult
 BluetoothDaemonSocketModule::ListenCmd(BluetoothSocketType aType,
                                        const nsAString& aServiceName,
-                                       const uint8_t aServiceUuid[16],
+                                       const BluetoothUuid& aServiceUuid,
                                        int aChannel, bool aEncrypt,
                                        bool aAuth,
                                        BluetoothSocketResultHandler* aRes)
 {
   MOZ_ASSERT(NS_IsMainThread());
 
   nsAutoPtr<DaemonSocketPDU> pdu(
     new DaemonSocketPDU(SERVICE_ID, OPCODE_LISTEN,
                         0));
 
   nsresult rv = PackPDU(
     aType,
     PackConversion<nsAString, BluetoothServiceName>(aServiceName),
-    PackArray<uint8_t>(aServiceUuid, 16),
+    aServiceUuid,
     PackConversion<int, int32_t>(aChannel),
     SocketFlags(aEncrypt, aAuth), *pdu);
   if (NS_FAILED(rv)) {
     return rv;
   }
   rv = Send(pdu, aRes);
   if (NS_FAILED(rv)) {
     return rv;
   }
   unused << pdu.forget();
   return rv;
 }
 
 nsresult
 BluetoothDaemonSocketModule::ConnectCmd(const nsAString& aBdAddr,
                                         BluetoothSocketType aType,
-                                        const uint8_t aUuid[16],
+                                        const BluetoothUuid& aServiceUuid,
                                         int aChannel, bool aEncrypt,
                                         bool aAuth,
                                         BluetoothSocketResultHandler* aRes)
 {
   MOZ_ASSERT(NS_IsMainThread());
 
   nsAutoPtr<DaemonSocketPDU> pdu(
     new DaemonSocketPDU(SERVICE_ID, OPCODE_CONNECT,
                         0));
 
   nsresult rv = PackPDU(
     PackConversion<nsAString, BluetoothAddress>(aBdAddr),
     aType,
-    PackArray<uint8_t>(aUuid, 16),
+    aServiceUuid,
     PackConversion<int, int32_t>(aChannel),
     SocketFlags(aEncrypt, aAuth), *pdu);
   if (NS_FAILED(rv)) {
     return rv;
   }
   rv = Send(pdu, aRes);
   if (NS_FAILED(rv)) {
     return rv;
@@ -300,41 +300,41 @@ BluetoothDaemonSocketInterface::Bluetoot
 }
 
 BluetoothDaemonSocketInterface::~BluetoothDaemonSocketInterface()
 { }
 
 void
 BluetoothDaemonSocketInterface::Listen(BluetoothSocketType aType,
                                        const nsAString& aServiceName,
-                                       const uint8_t aServiceUuid[16],
+                                       const BluetoothUuid& aServiceUuid,
                                        int aChannel, bool aEncrypt,
                                        bool aAuth,
                                        BluetoothSocketResultHandler* aRes)
 {
   MOZ_ASSERT(mModule);
 
   nsresult rv = mModule->ListenCmd(aType, aServiceName, aServiceUuid,
                                    aChannel, aEncrypt, aAuth, aRes);
   if (NS_FAILED(rv))  {
     DispatchError(aRes, rv);
   }
 }
 
 void
 BluetoothDaemonSocketInterface::Connect(const nsAString& aBdAddr,
                                         BluetoothSocketType aType,
-                                        const uint8_t aUuid[16],
+                                        const BluetoothUuid& aServiceUuid,
                                         int aChannel, bool aEncrypt,
                                         bool aAuth,
                                         BluetoothSocketResultHandler* aRes)
 {
   MOZ_ASSERT(mModule);
 
-  nsresult rv = mModule->ConnectCmd(aBdAddr, aType, aUuid, aChannel,
+  nsresult rv = mModule->ConnectCmd(aBdAddr, aType, aServiceUuid, aChannel,
                                     aEncrypt, aAuth, aRes);
   if (NS_FAILED(rv))  {
     DispatchError(aRes, rv);
   }
 }
 
 void
 BluetoothDaemonSocketInterface::Accept(int aFd,
--- a/dom/bluetooth/bluedroid/BluetoothDaemonSocketInterface.h
+++ b/dom/bluetooth/bluedroid/BluetoothDaemonSocketInterface.h
@@ -35,23 +35,23 @@ public:
   virtual nsresult Send(DaemonSocketPDU* aPDU,
                         DaemonSocketResultHandler* aRes) = 0;
 
   // Commands
   //
 
   nsresult ListenCmd(BluetoothSocketType aType,
                      const nsAString& aServiceName,
-                     const uint8_t aServiceUuid[16],
+                     const BluetoothUuid& aServiceUuid,
                      int aChannel, bool aEncrypt, bool aAuth,
                      BluetoothSocketResultHandler* aRes);
 
   nsresult ConnectCmd(const nsAString& aBdAddr,
                       BluetoothSocketType aType,
-                      const uint8_t aUuid[16],
+                      const BluetoothUuid& aServiceUuid,
                       int aChannel, bool aEncrypt, bool aAuth,
                       BluetoothSocketResultHandler* aRes);
 
   nsresult AcceptCmd(int aFd, BluetoothSocketResultHandler* aRes);
 
   nsresult CloseCmd(BluetoothSocketResultHandler* aRes);
 
 protected:
@@ -103,23 +103,23 @@ class BluetoothDaemonSocketInterface fin
   : public BluetoothSocketInterface
 {
 public:
   BluetoothDaemonSocketInterface(BluetoothDaemonSocketModule* aModule);
   ~BluetoothDaemonSocketInterface();
 
   void Listen(BluetoothSocketType aType,
               const nsAString& aServiceName,
-              const uint8_t aServiceUuid[16],
+              const BluetoothUuid& aServiceUuid,
               int aChannel, bool aEncrypt, bool aAuth,
               BluetoothSocketResultHandler* aRes) override;
 
   void Connect(const nsAString& aBdAddr,
                BluetoothSocketType aType,
-               const uint8_t aUuid[16],
+               const BluetoothUuid& aServiceUuid,
                int aChannel, bool aEncrypt, bool aAuth,
                BluetoothSocketResultHandler* aRes) override;
 
   void Accept(int aFd, BluetoothSocketResultHandler* aRes) override;
 
   void Close(BluetoothSocketResultHandler* aRes) override;
 
 private:
--- a/dom/bluetooth/bluedroid/BluetoothServiceBluedroid.cpp
+++ b/dom/bluetooth/bluedroid/BluetoothServiceBluedroid.cpp
@@ -893,17 +893,17 @@ public:
     mGetRemoteServiceRecordArray[i].mManager->OnGetServiceChannel(
       mDeviceAddress, uuidStr, -1);
     mGetRemoteServiceRecordArray.RemoveElementAt(i);
   }
 
   void CancelDiscovery() override
   {
     // Disabled discovery mode, now perform SDP operation.
-    sBtInterface->GetRemoteServiceRecord(mDeviceAddress, mUuid.mUuid, this);
+    sBtInterface->GetRemoteServiceRecord(mDeviceAddress, mUuid, this);
   }
 
 private:
   ssize_t FindRequest() const
   {
     for (size_t i = 0; i < mGetRemoteServiceRecordArray.Length(); ++i) {
       if ((mGetRemoteServiceRecordArray[i].mDeviceAddress == mDeviceAddress) &&
           (mGetRemoteServiceRecordArray[i].mUuid == mUuid)) {
@@ -936,17 +936,17 @@ BluetoothServiceBluedroid::GetServiceCha
 
   /* Stop discovery of remote devices here, because SDP operations
    * won't be performed while the adapter is in discovery mode.
    */
   if (mDiscovering) {
     sBtInterface->CancelDiscovery(res);
   } else {
     sBtInterface->GetRemoteServiceRecord(
-      aDeviceAddress, uuid.mUuid, res);
+      aDeviceAddress, uuid, res);
   }
 
   return NS_OK;
 }
 
 struct BluetoothServiceBluedroid::GetRemoteServicesRequest final
 {
   GetRemoteServicesRequest(const nsAString& aDeviceAddress,
--- a/dom/bluetooth/bluedroid/BluetoothSocket.cpp
+++ b/dom/bluetooth/bluedroid/BluetoothSocket.cpp
@@ -660,17 +660,17 @@ BluetoothSocket::Connect(const nsAString
 
   mImpl = new DroidSocketImpl(aConsumerLoop, aIOLoop, this);
 
   BluetoothSocketResultHandler* res = new ConnectSocketResultHandler(mImpl);
   SetCurrentResultHandler(res);
 
   sBluetoothSocketInterface->Connect(
     aDeviceAddress, aType,
-    aServiceUuid.mUuid, aChannel,
+    aServiceUuid, aChannel,
     aEncrypt, aAuth, res);
 
   return NS_OK;
 }
 
 nsresult
 BluetoothSocket::Connect(const nsAString& aDeviceAddress,
                          const BluetoothUuid& aServiceUuid,
@@ -724,17 +724,17 @@ BluetoothSocket::Listen(const nsAString&
 
   mImpl = new DroidSocketImpl(aConsumerLoop, aIOLoop, this);
 
   BluetoothSocketResultHandler* res = new ListenResultHandler(mImpl);
   SetCurrentResultHandler(res);
 
   sBluetoothSocketInterface->Listen(
     aType,
-    aServiceName, aServiceUuid.mUuid, aChannel,
+    aServiceName, aServiceUuid, aChannel,
     aEncrypt, aAuth, res);
 
   return NS_OK;
 }
 
 nsresult
 BluetoothSocket::Listen(const nsAString& aServiceName,
                         const BluetoothUuid& aServiceUuid,
--- a/dom/bluetooth/common/BluetoothInterface.h
+++ b/dom/bluetooth/common/BluetoothInterface.h
@@ -52,23 +52,23 @@ protected:
 
 class BluetoothSocketInterface
 {
 public:
   // Init and Cleanup is handled by BluetoothInterface
 
   virtual void Listen(BluetoothSocketType aType,
                       const nsAString& aServiceName,
-                      const uint8_t aServiceUuid[16],
+                      const BluetoothUuid& aServiceUuid,
                       int aChannel, bool aEncrypt, bool aAuth,
                       BluetoothSocketResultHandler* aRes) = 0;
 
   virtual void Connect(const nsAString& aBdAddr,
                        BluetoothSocketType aType,
-                       const uint8_t aUuid[16],
+                       const BluetoothUuid& aServiceUuid,
                        int aChannel, bool aEncrypt, bool aAuth,
                        BluetoothSocketResultHandler* aRes) = 0;
 
   virtual void Accept(int aFd, BluetoothSocketResultHandler* aRes) = 0;
 
   virtual void Close(BluetoothSocketResultHandler* aRes) = 0;
 
 protected:
@@ -1047,17 +1047,17 @@ public:
                                        BluetoothResultHandler* aRes) = 0;
   virtual void SetRemoteDeviceProperty(const nsAString& aRemoteAddr,
                                        const BluetoothNamedValue& aProperty,
                                        BluetoothResultHandler* aRes) = 0;
 
   /* Remote Services */
 
   virtual void GetRemoteServiceRecord(const nsAString& aRemoteAddr,
-                                      const uint8_t aUuid[16],
+                                      const BluetoothUuid& aUuid,
                                       BluetoothResultHandler* aRes) = 0;
   virtual void GetRemoteServices(const nsAString& aRemoteAddr,
                                  BluetoothResultHandler* aRes) = 0;
 
   /* Discovery */
 
   virtual void StartDiscovery(BluetoothResultHandler* aRes) = 0;
   virtual void CancelDiscovery(BluetoothResultHandler* aRes) = 0;