Bug 1195685 - Transform macro |BT_APPEND_NAMED_VALUE| into function, r=shuang
authorBen Tian <btian@mozilla.com>
Wed, 09 Sep 2015 10:59:36 +0800
changeset 294093 b1a14f135d4474abad577f1016d7280b47481bc7
parent 293984 faedea6df4541cf44444a31c4ed36a9a845cd075
child 294094 288378746b475e75f43e3ab69abfae169764fe73
push id5245
push userraliiev@mozilla.com
push dateThu, 29 Oct 2015 11:30:51 +0000
treeherdermozilla-beta@dac831dc1bd0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersshuang
bugs1195685
milestone43.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 1195685 - Transform macro |BT_APPEND_NAMED_VALUE| into function, r=shuang
dom/bluetooth/bluedroid/BluetoothA2dpManager.cpp
dom/bluetooth/bluedroid/BluetoothGattManager.cpp
dom/bluetooth/bluedroid/BluetoothOppManager.cpp
dom/bluetooth/bluedroid/BluetoothPbapManager.cpp
dom/bluetooth/bluedroid/BluetoothPbapManager.h
dom/bluetooth/bluedroid/BluetoothServiceBluedroid.cpp
dom/bluetooth/bluedroid/hfp/BluetoothHfpManager.cpp
dom/bluetooth/common/BluetoothCommon.h
dom/bluetooth/common/BluetoothHidManager.cpp
dom/bluetooth/common/BluetoothService.cpp
dom/bluetooth/common/BluetoothUtils.cpp
dom/bluetooth/common/BluetoothUtils.h
dom/bluetooth/common/webapi/BluetoothAdapter.cpp
--- a/dom/bluetooth/bluedroid/BluetoothA2dpManager.cpp
+++ b/dom/bluetooth/bluedroid/BluetoothA2dpManager.cpp
@@ -626,17 +626,17 @@ BluetoothA2dpManager::ConnectionStateNot
   BluetoothA2dpConnectionState aState, const nsAString& aBdAddr)
 {
   MOZ_ASSERT(NS_IsMainThread());
 
   nsString a2dpState;
   AvStatusToSinkString(aState, a2dpState);
 
   InfallibleTArray<BluetoothNamedValue> props;
-  BT_APPEND_NAMED_VALUE(props, "State", a2dpState);
+  AppendNamedValue(props, "State", a2dpState);
 
   HandleSinkPropertyChanged(BluetoothSignal(NS_LITERAL_STRING("AudioSink"),
                                             nsString(aBdAddr), props));
 }
 
 void
 BluetoothA2dpManager::AudioStateNotification(BluetoothA2dpAudioState aState,
                                              const nsAString& aBdAddr)
@@ -651,15 +651,15 @@ BluetoothA2dpManager::AudioStateNotifica
     // for avdtp state stop stream
     a2dpState = NS_LITERAL_STRING("connected");
   } else if (aState == A2DP_AUDIO_STATE_REMOTE_SUSPEND) {
     // for avdtp state suspend stream from remote side
     a2dpState = NS_LITERAL_STRING("connected");
   }
 
   InfallibleTArray<BluetoothNamedValue> props;
-  BT_APPEND_NAMED_VALUE(props, "State", a2dpState);
+  AppendNamedValue(props, "State", a2dpState);
 
   HandleSinkPropertyChanged(BluetoothSignal(NS_LITERAL_STRING("AudioSink"),
                                             nsString(aBdAddr), props));
 }
 
 NS_IMPL_ISUPPORTS(BluetoothA2dpManager, nsIObserver)
--- a/dom/bluetooth/bluedroid/BluetoothGattManager.cpp
+++ b/dom/bluetooth/bluedroid/BluetoothGattManager.cpp
@@ -1752,20 +1752,20 @@ public:
 
 private:
   void DistributeSignalDeviceFound(BluetoothTypeOfDevice type)
   {
     MOZ_ASSERT(NS_IsMainThread());
 
     InfallibleTArray<BluetoothNamedValue> properties;
 
-    BT_APPEND_NAMED_VALUE(properties, "Address", mBdAddr);
-    BT_APPEND_NAMED_VALUE(properties, "Rssi", mRssi);
-    BT_APPEND_NAMED_VALUE(properties, "GattAdv", mAdvData);
-    BT_APPEND_NAMED_VALUE(properties, "Type", static_cast<uint32_t>(type));
+    AppendNamedValue(properties, "Address", mBdAddr);
+    AppendNamedValue(properties, "Rssi", mRssi);
+    AppendNamedValue(properties, "GattAdv", mAdvData);
+    AppendNamedValue(properties, "Type", static_cast<uint32_t>(type));
 
     BluetoothService* bs = BluetoothService::Get();
     NS_ENSURE_TRUE_VOID(bs);
 
     bs->DistributeSignal(NS_LITERAL_STRING("LeDeviceFound"),
                          NS_LITERAL_STRING(KEY_ADAPTER),
                          BluetoothValue(properties));
   }
@@ -1985,18 +1985,18 @@ BluetoothGattManager::GetCharacteristicN
       aServiceId,
       false,
       aCharId,
       new DiscoverResultHandler(client));
   } else { // all characteristics of this service are discovered
     // Notify BluetoothGatt to make BluetoothGattService create characteristics
     // then proceed
     nsTArray<BluetoothNamedValue> values;
-    BT_APPEND_NAMED_VALUE(values, "serviceId", aServiceId);
-    BT_APPEND_NAMED_VALUE(values, "characteristics", client->mCharacteristics);
+    AppendNamedValue(values, "serviceId", aServiceId);
+    AppendNamedValue(values, "characteristics", client->mCharacteristics);
 
     bs->DistributeSignal(NS_LITERAL_STRING("CharacteristicsDiscovered"),
                          client->mAppUuid,
                          BluetoothValue(values));
 
     ProceedDiscoverProcess(client, aServiceId);
   }
 }
@@ -2031,19 +2031,19 @@ BluetoothGattManager::GetDescriptorNotif
       aCharId,
       false,
       aDescriptorId,
       new DiscoverResultHandler(client));
   } else { // all descriptors of this characteristic are discovered
     // Notify BluetoothGatt to make BluetoothGattCharacteristic create
     // descriptors then proceed
     nsTArray<BluetoothNamedValue> values;
-    BT_APPEND_NAMED_VALUE(values, "serviceId", aServiceId);
-    BT_APPEND_NAMED_VALUE(values, "characteristicId", aCharId);
-    BT_APPEND_NAMED_VALUE(values, "descriptors", client->mDescriptors);
+    AppendNamedValue(values, "serviceId", aServiceId);
+    AppendNamedValue(values, "characteristicId", aCharId);
+    AppendNamedValue(values, "descriptors", client->mDescriptors);
 
     bs->DistributeSignal(NS_LITERAL_STRING("DescriptorsDiscovered"),
                          client->mAppUuid,
                          BluetoothValue(values));
     client->mDescriptors.Clear();
 
     ProceedDiscoverProcess(client, aServiceId);
   }
@@ -2077,19 +2077,18 @@ BluetoothGattManager::GetIncludedService
       aServiceId,
       false,
       aIncludedServId,
       new DiscoverResultHandler(client));
   } else { // all included services of this service are discovered
     // Notify BluetoothGatt to make BluetoothGattService create included
     // services
     nsTArray<BluetoothNamedValue> values;
-    BT_APPEND_NAMED_VALUE(values, "serviceId", aServiceId);
-    BT_APPEND_NAMED_VALUE(values, "includedServices",
-                          client->mIncludedServices);
+    AppendNamedValue(values, "serviceId", aServiceId);
+    AppendNamedValue(values, "includedServices", client->mIncludedServices);
 
     bs->DistributeSignal(NS_LITERAL_STRING("IncludedServicesDiscovered"),
                          client->mAppUuid,
                          BluetoothValue(values));
     client->mIncludedServices.Clear();
 
     // Start to discover characteristics of this service
     sBluetoothGattInterface->GetCharacteristic(
@@ -2486,18 +2485,18 @@ BluetoothGattManager::ConnectionNotifica
   if (aConnected) {
     server->mConnectionMap.Put(aBdAddr, aConnId);
   } else {
     server->mConnectionMap.Remove(aBdAddr);
   }
 
   // Notify BluetoothGattServer that connection status changed
   InfallibleTArray<BluetoothNamedValue> props;
-  BT_APPEND_NAMED_VALUE(props, "Connected", aConnected);
-  BT_APPEND_NAMED_VALUE(props, "Address", nsString(aBdAddr));
+  AppendNamedValue(props, "Connected", aConnected);
+  AppendNamedValue(props, "Address", nsString(aBdAddr));
   bs->DistributeSignal(
     NS_LITERAL_STRING(GATT_CONNECTION_STATE_CHANGED_ID),
     server->mAppUuid,
     BluetoothValue(props));
 
   // Resolve or reject connect/disconnect peripheral requests
   if (server->mConnectPeripheralRunnable) {
     if (aConnected) {
--- a/dom/bluetooth/bluedroid/BluetoothOppManager.cpp
+++ b/dom/bluetooth/bluedroid/BluetoothOppManager.cpp
@@ -1414,69 +1414,69 @@ BluetoothOppManager::FileTransferComplet
 {
   if (mSendTransferCompleteFlag) {
     return;
   }
 
   NS_NAMED_LITERAL_STRING(type, "bluetooth-opp-transfer-complete");
   InfallibleTArray<BluetoothNamedValue> parameters;
 
-  BT_APPEND_NAMED_VALUE(parameters, "address", mDeviceAddress);
-  BT_APPEND_NAMED_VALUE(parameters, "success", mSuccessFlag);
-  BT_APPEND_NAMED_VALUE(parameters, "received", mIsServer);
-  BT_APPEND_NAMED_VALUE(parameters, "fileName", mFileName);
-  BT_APPEND_NAMED_VALUE(parameters, "fileLength", mSentFileLength);
-  BT_APPEND_NAMED_VALUE(parameters, "contentType", mContentType);
+  AppendNamedValue(parameters, "address", mDeviceAddress);
+  AppendNamedValue(parameters, "success", mSuccessFlag);
+  AppendNamedValue(parameters, "received", mIsServer);
+  AppendNamedValue(parameters, "fileName", mFileName);
+  AppendNamedValue(parameters, "fileLength", mSentFileLength);
+  AppendNamedValue(parameters, "contentType", mContentType);
 
   BT_ENSURE_TRUE_VOID_BROADCAST_SYSMSG(type, parameters);
 
   mSendTransferCompleteFlag = true;
 }
 
 void
 BluetoothOppManager::StartFileTransfer()
 {
   NS_NAMED_LITERAL_STRING(type, "bluetooth-opp-transfer-start");
   InfallibleTArray<BluetoothNamedValue> parameters;
 
-  BT_APPEND_NAMED_VALUE(parameters, "address", mDeviceAddress);
-  BT_APPEND_NAMED_VALUE(parameters, "received", mIsServer);
-  BT_APPEND_NAMED_VALUE(parameters, "fileName", mFileName);
-  BT_APPEND_NAMED_VALUE(parameters, "fileLength", mFileLength);
-  BT_APPEND_NAMED_VALUE(parameters, "contentType", mContentType);
+  AppendNamedValue(parameters, "address", mDeviceAddress);
+  AppendNamedValue(parameters, "received", mIsServer);
+  AppendNamedValue(parameters, "fileName", mFileName);
+  AppendNamedValue(parameters, "fileLength", mFileLength);
+  AppendNamedValue(parameters, "contentType", mContentType);
 
   BT_ENSURE_TRUE_VOID_BROADCAST_SYSMSG(type, parameters);
 
   mSendTransferCompleteFlag = false;
 }
 
 void
 BluetoothOppManager::UpdateProgress()
 {
   NS_NAMED_LITERAL_STRING(type, "bluetooth-opp-update-progress");
   InfallibleTArray<BluetoothNamedValue> parameters;
 
-  BT_APPEND_NAMED_VALUE(parameters, "address", mDeviceAddress);
-  BT_APPEND_NAMED_VALUE(parameters, "received", mIsServer);
-  BT_APPEND_NAMED_VALUE(parameters, "processedLength", mSentFileLength);
-  BT_APPEND_NAMED_VALUE(parameters, "fileLength", mFileLength);
+  AppendNamedValue(parameters, "address", mDeviceAddress);
+  AppendNamedValue(parameters, "received", mIsServer);
+  AppendNamedValue(parameters, "processedLength", mSentFileLength);
+  AppendNamedValue(parameters, "fileLength", mFileLength);
 
   BT_ENSURE_TRUE_VOID_BROADCAST_SYSMSG(type, parameters);
 }
 
 void
 BluetoothOppManager::ReceivingFileConfirmation()
 {
   NS_NAMED_LITERAL_STRING(type, "bluetooth-opp-receiving-file-confirmation");
   InfallibleTArray<BluetoothNamedValue> parameters;
 
-  BT_APPEND_NAMED_VALUE(parameters, "address", mDeviceAddress);
-  BT_APPEND_NAMED_VALUE(parameters, "fileName", mFileName);
-  BT_APPEND_NAMED_VALUE(parameters, "fileLength", mFileLength);
-  BT_APPEND_NAMED_VALUE(parameters, "contentType", mContentType);
+  AppendNamedValue(parameters, "address", mDeviceAddress);
+  AppendNamedValue(parameters, "fileName", mFileName);
+  AppendNamedValue(parameters, "fileLength", mFileLength);
+  AppendNamedValue(parameters, "contentType", mContentType);
 
   BT_ENSURE_TRUE_VOID_BROADCAST_SYSMSG(type, parameters);
 }
 
 void
 BluetoothOppManager::NotifyAboutFileChange()
 {
   NS_NAMED_LITERAL_STRING(data, "modified");
--- a/dom/bluetooth/bluedroid/BluetoothPbapManager.cpp
+++ b/dom/bluetooth/bluedroid/BluetoothPbapManager.cpp
@@ -4,16 +4,17 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "base/basictypes.h"
 #include "BluetoothPbapManager.h"
 
 #include "BluetoothService.h"
 #include "BluetoothSocket.h"
+#include "BluetoothUtils.h"
 #include "BluetoothUuid.h"
 #include "ObexBase.h"
 
 #include "mozilla/dom/BluetoothPbapParametersBinding.h"
 #include "mozilla/dom/File.h"
 #include "mozilla/dom/ipc/BlobParent.h"
 #include "mozilla/RefPtr.h"
 #include "mozilla/Services.h"
@@ -424,34 +425,27 @@ BluetoothPbapManager::PullPhonebook(cons
   if (!bs) {
     return ObexResponseCode::PreconditionFailed;
   }
 
   InfallibleTArray<BluetoothNamedValue> data;
 
   nsString name;
   aHeader.GetName(name);
-  BT_APPEND_NAMED_VALUE(data, "name", name);
-
-  AppendBtNamedValueByTagId(aHeader, data, AppParameterTag::Format);
-  AppendBtNamedValueByTagId(aHeader, data, AppParameterTag::PropertySelector);
-  AppendBtNamedValueByTagId(aHeader, data, AppParameterTag::MaxListCount);
-  AppendBtNamedValueByTagId(aHeader, data, AppParameterTag::ListStartOffset);
-  AppendBtNamedValueByTagId(aHeader, data, AppParameterTag::vCardSelector);
+  AppendNamedValue(data, "name", name);
 
-  #ifdef MOZ_B2G_BT_API_V1
-    bs->DistributeSignal(
-      BluetoothSignal(NS_LITERAL_STRING(PULL_PHONEBOOK_REQ_ID),
-                      NS_LITERAL_STRING(KEY_ADAPTER),
-                      data));
-  #else
-    bs->DistributeSignal(NS_LITERAL_STRING(PULL_PHONEBOOK_REQ_ID),
-                         NS_LITERAL_STRING(KEY_ADAPTER),
-                         data);
-  #endif
+  AppendNamedValueByTagId(aHeader, data, AppParameterTag::Format);
+  AppendNamedValueByTagId(aHeader, data, AppParameterTag::PropertySelector);
+  AppendNamedValueByTagId(aHeader, data, AppParameterTag::MaxListCount);
+  AppendNamedValueByTagId(aHeader, data, AppParameterTag::ListStartOffset);
+  AppendNamedValueByTagId(aHeader, data, AppParameterTag::vCardSelector);
+
+  bs->DistributeSignal(NS_LITERAL_STRING(PULL_PHONEBOOK_REQ_ID),
+                       NS_LITERAL_STRING(KEY_ADAPTER),
+                       data);
 
   return ObexResponseCode::Success;
 }
 
 uint8_t
 BluetoothPbapManager::PullvCardListing(const ObexHeaderSet& aHeader)
 {
   MOZ_ASSERT(NS_IsMainThread());
@@ -460,35 +454,28 @@ BluetoothPbapManager::PullvCardListing(c
   if (!bs) {
     return ObexResponseCode::PreconditionFailed;
   }
 
   InfallibleTArray<BluetoothNamedValue> data;
 
   nsString name;
   aHeader.GetName(name);
-  BT_APPEND_NAMED_VALUE(data, "name", name);
-
-  AppendBtNamedValueByTagId(aHeader, data, AppParameterTag::Order);
-  AppendBtNamedValueByTagId(aHeader, data, AppParameterTag::SearchValue);
-  AppendBtNamedValueByTagId(aHeader, data, AppParameterTag::SearchProperty);
-  AppendBtNamedValueByTagId(aHeader, data, AppParameterTag::MaxListCount);
-  AppendBtNamedValueByTagId(aHeader, data, AppParameterTag::ListStartOffset);
-  AppendBtNamedValueByTagId(aHeader, data, AppParameterTag::vCardSelector);
+  AppendNamedValue(data, "name", name);
 
-  #ifdef MOZ_B2G_BT_API_V1
-    bs->DistributeSignal(
-      BluetoothSignal(NS_LITERAL_STRING(PULL_VCARD_LISTING_REQ_ID),
-                      NS_LITERAL_STRING(KEY_ADAPTER),
-                      data));
-  #else
-    bs->DistributeSignal(NS_LITERAL_STRING(PULL_VCARD_LISTING_REQ_ID),
-                         NS_LITERAL_STRING(KEY_ADAPTER),
-                         data);
-  #endif
+  AppendNamedValueByTagId(aHeader, data, AppParameterTag::Order);
+  AppendNamedValueByTagId(aHeader, data, AppParameterTag::SearchValue);
+  AppendNamedValueByTagId(aHeader, data, AppParameterTag::SearchProperty);
+  AppendNamedValueByTagId(aHeader, data, AppParameterTag::MaxListCount);
+  AppendNamedValueByTagId(aHeader, data, AppParameterTag::ListStartOffset);
+  AppendNamedValueByTagId(aHeader, data, AppParameterTag::vCardSelector);
+
+  bs->DistributeSignal(NS_LITERAL_STRING(PULL_VCARD_LISTING_REQ_ID),
+                       NS_LITERAL_STRING(KEY_ADAPTER),
+                       data);
 
   return ObexResponseCode::Success;
 }
 
 uint8_t
 BluetoothPbapManager::PullvCardEntry(const ObexHeaderSet& aHeader)
 {
   MOZ_ASSERT(NS_IsMainThread());
@@ -497,119 +484,113 @@ BluetoothPbapManager::PullvCardEntry(con
   if (!bs) {
     return ObexResponseCode::PreconditionFailed;
   }
 
   InfallibleTArray<BluetoothNamedValue> data;
 
   nsString name;
   aHeader.GetName(name);
-  BT_APPEND_NAMED_VALUE(data, "name", name);
-
-  AppendBtNamedValueByTagId(aHeader, data, AppParameterTag::Format);
-  AppendBtNamedValueByTagId(aHeader, data, AppParameterTag::PropertySelector);
+  AppendNamedValue(data, "name", name);
 
-  #ifdef MOZ_B2G_BT_API_V1
-    bs->DistributeSignal(
-      BluetoothSignal(NS_LITERAL_STRING(PULL_VCARD_ENTRY_REQ_ID),
-                      NS_LITERAL_STRING(KEY_ADAPTER),
-                      data));
-  #else
-    bs->DistributeSignal(NS_LITERAL_STRING(PULL_VCARD_ENTRY_REQ_ID),
-                         NS_LITERAL_STRING(KEY_ADAPTER),
-                         data);
-  #endif
+  AppendNamedValueByTagId(aHeader, data, AppParameterTag::Format);
+  AppendNamedValueByTagId(aHeader, data, AppParameterTag::PropertySelector);
+
+  bs->DistributeSignal(NS_LITERAL_STRING(PULL_VCARD_ENTRY_REQ_ID),
+                       NS_LITERAL_STRING(KEY_ADAPTER),
+                       data);
 
   return ObexResponseCode::Success;
 }
 
 void
-BluetoothPbapManager::AppendBtNamedValueByTagId(
+BluetoothPbapManager::AppendNamedValueByTagId(
   const ObexHeaderSet& aHeader,
   InfallibleTArray<BluetoothNamedValue>& aValues,
   const AppParameterTag aTagId)
 {
   uint8_t buf[64];
   if (!aHeader.GetAppParameter(aTagId, buf, 64)) {
     return;
   }
 
   switch (aTagId) {
     case AppParameterTag::Order: {
       using namespace mozilla::dom::vCardOrderTypeValues;
-      uint32_t order = buf[0] < ArrayLength(strings) ? (uint32_t) buf[0]
-                                                     : 0; // default: indexed
-      BT_APPEND_NAMED_VALUE(aValues, "order", order);
+      uint32_t order =
+        buf[0] < ArrayLength(strings) ? static_cast<uint32_t>(buf[0])
+                                      : 0; // default: indexed
+      AppendNamedValue(aValues, "order", order);
       break;
     }
     case AppParameterTag::SearchProperty: {
       using namespace mozilla::dom::vCardSearchKeyTypeValues;
-      uint32_t searchKey = buf[0] < ArrayLength(strings) ? (uint32_t) buf[0]
-                                                         : 0; // default: name
-      BT_APPEND_NAMED_VALUE(aValues, "searchKey", searchKey);
+      uint32_t searchKey =
+        buf[0] < ArrayLength(strings) ? static_cast<uint32_t>(buf[0])
+                                      : 0; // default: name
+      AppendNamedValue(aValues, "searchKey", searchKey);
       break;
     }
     case AppParameterTag::SearchValue: {
       // Section 5.3.4.3 "SearchValue {<text string>}", PBAP 1.2
       // The UTF-8 character set shall be used for <text string>.
 
       // Use nsCString to store UTF-8 string here to follow the suggestion of
       // 'MDN:Internal_strings'.
       nsCString text((char *) buf);
 
-      BT_APPEND_NAMED_VALUE(aValues, "searchText", text);
+      AppendNamedValue(aValues, "searchText", text);
       break;
     }
     case AppParameterTag::MaxListCount: {
       uint16_t maxListCount = *((uint16_t *)buf);
 
       // convert big endian to little endian
       maxListCount = (maxListCount >> 8) | (maxListCount << 8);
 
       // Section 5 "Phone Book Access Profile Functions", PBAP 1.2
       // Replying 'PhonebookSize' is mandatory if 'MaxListCount' parameter is
       // present in the request with a value of 0, else it is excluded.
       mPhonebookSizeRequired = !maxListCount;
 
-      BT_APPEND_NAMED_VALUE(aValues, "maxListCount", (uint32_t) maxListCount);
+      AppendNamedValue(aValues, "maxListCount",
+                       static_cast<uint32_t>(maxListCount));
       break;
     }
     case AppParameterTag::ListStartOffset: {
       uint16_t listStartOffset = *((uint16_t *)buf);
 
       // convert big endian to little endian
       listStartOffset = (listStartOffset >> 8) | (listStartOffset << 8);
 
-      BT_APPEND_NAMED_VALUE(aValues, "listStartOffset",
-                           (uint32_t) listStartOffset);
+      AppendNamedValue(aValues, "listStartOffset",
+                       static_cast<uint32_t>(listStartOffset));
       break;
     }
     case AppParameterTag::PropertySelector: {
       InfallibleTArray<uint32_t> props = PackPropertiesMask(buf, 64);
 
-      BT_APPEND_NAMED_VALUE(aValues, "propSelector", props);
+      AppendNamedValue(aValues, "propSelector", props);
       break;
     }
     case AppParameterTag::Format: {
       bool usevCard3 = buf[0];
-      BT_APPEND_NAMED_VALUE(aValues, "format", usevCard3);
+      AppendNamedValue(aValues, "format", usevCard3);
       break;
     }
     case AppParameterTag::vCardSelector: {
       InfallibleTArray<uint32_t> props = PackPropertiesMask(buf, 64);
 
       bool hasVCardSelectorOperator = aHeader.GetAppParameter(
         AppParameterTag::vCardSelectorOperator, buf, 64);
 
       if (hasVCardSelectorOperator && buf[0]) {
-        BT_APPEND_NAMED_VALUE(aValues, "vCardSelector_AND",
-                              BluetoothValue(props));
+        AppendNamedValue(aValues, "vCardSelector_AND", BluetoothValue(props));
       } else {
-        BT_APPEND_NAMED_VALUE(aValues, "vCardSelector_OR",
-                              BluetoothValue(props));
+        AppendNamedValue(aValues, "vCardSelector_OR", BluetoothValue(props));
       }
       break;
     }
     default:
       BT_LOGR("Unsupported AppParameterTag: %x", aTagId);
       break;
   }
 }
--- a/dom/bluetooth/bluedroid/BluetoothPbapManager.h
+++ b/dom/bluetooth/bluedroid/BluetoothPbapManager.h
@@ -144,17 +144,17 @@ private:
   void ReplyError(uint8_t aError);
   void SendObexData(uint8_t* aData, uint8_t aOpcode, int aSize);
   bool ReplyToGet(uint16_t aPhonebookSize = 0);
 
   uint8_t SetPhoneBookPath(uint8_t flags, const ObexHeaderSet& aHeader);
   uint8_t PullPhonebook(const ObexHeaderSet& aHeader);
   uint8_t PullvCardListing(const ObexHeaderSet& aHeader);
   uint8_t PullvCardEntry(const ObexHeaderSet& aHeader);
-  void AppendBtNamedValueByTagId(
+  void AppendNamedValueByTagId(
     const ObexHeaderSet& aHeader,
     InfallibleTArray<BluetoothNamedValue>& aValues,
     const AppParameterTag aTagId);
 
   InfallibleTArray<uint32_t>  PackPropertiesMask(uint8_t* aData, int aSize);
   bool CompareHeaderTarget(const ObexHeaderSet& aHeader);
   bool IsLegalPath(const nsAString& aPath);
   bool GetInputStreamFromBlob(Blob* aBlob);
--- a/dom/bluetooth/bluedroid/BluetoothServiceBluedroid.cpp
+++ b/dom/bluetooth/bluedroid/BluetoothServiceBluedroid.cpp
@@ -614,37 +614,31 @@ BluetoothServiceBluedroid::GetAdaptersIn
    *     |
    *     |__ BluetoothNamedValue =
    *     |     {"Adapter", BluetoothValue = BluetoothNamedValue[]}
    *     |
    *     |__ BluetoothNamedValue =
    *     |     {"Adapter", BluetoothValue = BluetoothNamedValue[]}
    *     ...
    */
-  BluetoothValue adaptersProperties = InfallibleTArray<BluetoothNamedValue>();
+  InfallibleTArray<BluetoothNamedValue> adaptersProperties;
   uint32_t numAdapters = 1; // Bluedroid supports single adapter only
 
   for (uint32_t i = 0; i < numAdapters; i++) {
-    BluetoothValue properties = InfallibleTArray<BluetoothNamedValue>();
+    InfallibleTArray<BluetoothNamedValue> properties;
 
-    BT_APPEND_NAMED_VALUE(properties.get_ArrayOfBluetoothNamedValue(),
-                          "State", mEnabled);
-    BT_APPEND_NAMED_VALUE(properties.get_ArrayOfBluetoothNamedValue(),
-                          "Address", mBdAddress);
-    BT_APPEND_NAMED_VALUE(properties.get_ArrayOfBluetoothNamedValue(),
-                          "Name", mBdName);
-    BT_APPEND_NAMED_VALUE(properties.get_ArrayOfBluetoothNamedValue(),
-                          "Discoverable", mDiscoverable);
-    BT_APPEND_NAMED_VALUE(properties.get_ArrayOfBluetoothNamedValue(),
-                          "Discovering", mDiscovering);
-    BT_APPEND_NAMED_VALUE(properties.get_ArrayOfBluetoothNamedValue(),
-                          "PairedDevices", mBondedAddresses);
+    AppendNamedValue(properties, "State", mEnabled);
+    AppendNamedValue(properties, "Address", mBdAddress);
+    AppendNamedValue(properties, "Name", mBdName);
+    AppendNamedValue(properties, "Discoverable", mDiscoverable);
+    AppendNamedValue(properties, "Discovering", mDiscovering);
+    AppendNamedValue(properties, "PairedDevices", mBondedAddresses);
 
-    BT_APPEND_NAMED_VALUE(adaptersProperties.get_ArrayOfBluetoothNamedValue(),
-                          "Adapter", properties);
+    AppendNamedValue(adaptersProperties, "Adapter",
+                     BluetoothValue(properties));
   }
 
   DispatchReplySuccess(aRunnable, adaptersProperties);
   return NS_OK;
 }
 
 class BluetoothServiceBluedroid::GetDeviceRequest final
 {
@@ -1456,25 +1450,25 @@ BluetoothServiceBluedroid::AdapterStateC
     BluetoothService* bs = BluetoothService::Get();
     NS_ENSURE_TRUE_VOID(bs);
 
     // Cleanup static adapter properties and notify adapter.
     mBdAddress.Truncate();
     mBdName.Truncate();
 
     InfallibleTArray<BluetoothNamedValue> props;
-    BT_APPEND_NAMED_VALUE(props, "Name", mBdName);
-    BT_APPEND_NAMED_VALUE(props, "Address", mBdAddress);
+    AppendNamedValue(props, "Name", mBdName);
+    AppendNamedValue(props, "Address", mBdAddress);
     if (mDiscoverable) {
       mDiscoverable = false;
-      BT_APPEND_NAMED_VALUE(props, "Discoverable", false);
+      AppendNamedValue(props, "Discoverable", false);
     }
     if (mDiscovering) {
       mDiscovering = false;
-      BT_APPEND_NAMED_VALUE(props, "Discovering", false);
+      AppendNamedValue(props, "Discovering", false);
     }
 
     bs->DistributeSignal(NS_LITERAL_STRING("PropertyChanged"),
                          NS_LITERAL_STRING(KEY_ADAPTER),
                          BluetoothValue(props));
 
     // Cleanup Bluetooth interfaces after state becomes BT_STATE_OFF. This
     // will also stop the Bluetooth daemon and disable the adapter.
@@ -1557,44 +1551,43 @@ BluetoothServiceBluedroid::AdapterProper
   InfallibleTArray<BluetoothNamedValue> propertiesArray;
 
   for (int i = 0; i < aNumProperties; i++) {
 
     const BluetoothProperty& p = aProperties[i];
 
     if (p.mType == PROPERTY_BDADDR) {
       mBdAddress = p.mString;
-      BT_APPEND_NAMED_VALUE(propertiesArray, "Address", mBdAddress);
+      AppendNamedValue(propertiesArray, "Address", mBdAddress);
 
     } else if (p.mType == PROPERTY_BDNAME) {
       mBdName = p.mString;
-      BT_APPEND_NAMED_VALUE(propertiesArray, "Name", mBdName);
+      AppendNamedValue(propertiesArray, "Name", mBdName);
 
     } else if (p.mType == PROPERTY_ADAPTER_SCAN_MODE) {
 
       // If BT is not enabled, Bluetooth scan mode should be non-discoverable
       // by defalut. |AdapterStateChangedNotification| would set default
       // properties to bluetooth backend once Bluetooth is enabled.
       if (IsEnabled()) {
         mDiscoverable = (p.mScanMode == SCAN_MODE_CONNECTABLE_DISCOVERABLE);
-        BT_APPEND_NAMED_VALUE(propertiesArray, "Discoverable", mDiscoverable);
+        AppendNamedValue(propertiesArray, "Discoverable", mDiscoverable);
       }
     } else if (p.mType == PROPERTY_ADAPTER_BONDED_DEVICES) {
       // We have to cache addresses of bonded devices. Unlike BlueZ,
       // Bluedroid would not send another PROPERTY_ADAPTER_BONDED_DEVICES
       // event after bond completed.
       BT_LOGD("Adapter property: BONDED_DEVICES. Count: %d",
               p.mStringArray.Length());
 
       // Whenever reloading paired devices, force refresh
       mBondedAddresses.Clear();
       mBondedAddresses.AppendElements(p.mStringArray);
 
-      BT_APPEND_NAMED_VALUE(propertiesArray, "PairedDevices",
-                            mBondedAddresses);
+      AppendNamedValue(propertiesArray, "PairedDevices", mBondedAddresses);
     } else if (p.mType == PROPERTY_UNKNOWN) {
       /* Bug 1065999: working around unknown properties */
     } else {
       BT_LOGD("Unhandled adapter property type: %d", p.mType);
       continue;
     }
   }
 
@@ -1625,49 +1618,49 @@ BluetoothServiceBluedroid::RemoteDeviceP
   BluetoothStatus aStatus, const nsAString& aBdAddr,
   int aNumProperties, const BluetoothProperty* aProperties)
 {
   MOZ_ASSERT(NS_IsMainThread());
 
   InfallibleTArray<BluetoothNamedValue> propertiesArray;
 
   nsString bdAddr(aBdAddr);
-  BT_APPEND_NAMED_VALUE(propertiesArray, "Address", bdAddr);
+  AppendNamedValue(propertiesArray, "Address", bdAddr);
 
   for (int i = 0; i < aNumProperties; ++i) {
 
     const BluetoothProperty& p = aProperties[i];
 
     if (p.mType == PROPERTY_BDNAME) {
-      BT_APPEND_NAMED_VALUE(propertiesArray, "Name", p.mString);
+      AppendNamedValue(propertiesArray, "Name", p.mString);
 
       // Update <address, name> mapping
       mDeviceNameMap.Remove(bdAddr);
       mDeviceNameMap.Put(bdAddr, p.mString);
     } else if (p.mType == PROPERTY_CLASS_OF_DEVICE) {
       uint32_t cod = p.mUint32;
-      BT_APPEND_NAMED_VALUE(propertiesArray, "Cod", cod);
+      AppendNamedValue(propertiesArray, "Cod", cod);
 
     } else if (p.mType == PROPERTY_UUIDS) {
       nsTArray<nsString> uuids;
 
       // Construct a sorted uuid set
       for (uint32_t index = 0; index < p.mUuidArray.Length(); ++index) {
         nsAutoString uuid;
         UuidToString(p.mUuidArray[index], uuid);
 
         if (!uuids.Contains(uuid)) { // filter out duplicate uuids
           uuids.InsertElementSorted(uuid);
         }
       }
-      BT_APPEND_NAMED_VALUE(propertiesArray, "UUIDs", uuids);
+      AppendNamedValue(propertiesArray, "UUIDs", uuids);
 
     } else if (p.mType == PROPERTY_TYPE_OF_DEVICE) {
-      BT_APPEND_NAMED_VALUE(propertiesArray, "Type",
-                            static_cast<uint32_t>(p.mTypeOfDevice));
+      AppendNamedValue(propertiesArray, "Type",
+                       static_cast<uint32_t>(p.mTypeOfDevice));
 
     } else if (p.mType == PROPERTY_UNKNOWN) {
       /* Bug 1065999: working around unknown properties */
     } else {
       BT_LOGD("Other non-handled device properties. Type: %d", p.mType);
     }
   }
 
@@ -1727,41 +1720,41 @@ BluetoothServiceBluedroid::DeviceFoundNo
   InfallibleTArray<BluetoothNamedValue> propertiesArray;
 
   nsString bdAddr, bdName;
   for (int i = 0; i < aNumProperties; i++) {
 
     const BluetoothProperty& p = aProperties[i];
 
     if (p.mType == PROPERTY_BDADDR) {
-      BT_APPEND_NAMED_VALUE(propertiesArray, "Address", p.mString);
+      AppendNamedValue(propertiesArray, "Address", p.mString);
       bdAddr = p.mString;
     } else if (p.mType == PROPERTY_BDNAME) {
-      BT_APPEND_NAMED_VALUE(propertiesArray, "Name", p.mString);
+      AppendNamedValue(propertiesArray, "Name", p.mString);
       bdName = p.mString;
     } else if (p.mType == PROPERTY_CLASS_OF_DEVICE) {
-      BT_APPEND_NAMED_VALUE(propertiesArray, "Cod", p.mUint32);
+      AppendNamedValue(propertiesArray, "Cod", p.mUint32);
 
     } else if (p.mType == PROPERTY_UUIDS) {
       nsTArray<nsString> uuids;
 
       // Construct a sorted uuid set
       for (uint32_t index = 0; index < p.mUuidArray.Length(); ++index) {
         nsAutoString uuid;
         UuidToString(p.mUuidArray[index], uuid);
 
         if (!uuids.Contains(uuid)) { // filter out duplicate uuids
           uuids.InsertElementSorted(uuid);
         }
       }
-      BT_APPEND_NAMED_VALUE(propertiesArray, "UUIDs", uuids);
+      AppendNamedValue(propertiesArray, "UUIDs", uuids);
 
     } else if (p.mType == PROPERTY_TYPE_OF_DEVICE) {
-      BT_APPEND_NAMED_VALUE(propertiesArray, "Type",
-                            static_cast<uint32_t>(p.mTypeOfDevice));
+      AppendNamedValue(propertiesArray, "Type",
+                       static_cast<uint32_t>(p.mTypeOfDevice));
 
     } else if (p.mType == PROPERTY_UNKNOWN) {
       /* Bug 1065999: working around unknown properties */
     } else {
       BT_LOGD("Not handled remote device property: %d", p.mType);
     }
   }
 
@@ -1778,17 +1771,17 @@ void
 BluetoothServiceBluedroid::DiscoveryStateChangedNotification(bool aState)
 {
   MOZ_ASSERT(NS_IsMainThread());
 
   mDiscovering = aState;
 
   // Fire PropertyChanged of Discovering
   InfallibleTArray<BluetoothNamedValue> propertiesArray;
-  BT_APPEND_NAMED_VALUE(propertiesArray, "Discovering", mDiscovering);
+  AppendNamedValue(propertiesArray, "Discovering", mDiscovering);
 
   DistributeSignal(NS_LITERAL_STRING("PropertyChanged"),
                    NS_LITERAL_STRING(KEY_ADAPTER),
                    BluetoothValue(propertiesArray));
 
   // Reply that Promise is resolved
   if (!mChangeDiscoveryRunnables.IsEmpty()) {
     DispatchReplySuccess(mChangeDiscoveryRunnables[0]);
@@ -1810,21 +1803,21 @@ BluetoothServiceBluedroid::PinRequestNot
   nsString bdName(aBdName);
   if (bdName.IsEmpty()) {
     mDeviceNameMap.Get(bdAddr, &bdName);
   } else {
     mDeviceNameMap.Remove(bdAddr);
     mDeviceNameMap.Put(bdAddr, bdName);
   }
 
-  BT_APPEND_NAMED_VALUE(propertiesArray, "address", bdAddr);
-  BT_APPEND_NAMED_VALUE(propertiesArray, "name", bdName);
-  BT_APPEND_NAMED_VALUE(propertiesArray, "passkey", EmptyString());
-  BT_APPEND_NAMED_VALUE(propertiesArray, "type",
-                        NS_LITERAL_STRING(PAIRING_REQ_TYPE_ENTERPINCODE));
+  AppendNamedValue(propertiesArray, "address", bdAddr);
+  AppendNamedValue(propertiesArray, "name", bdName);
+  AppendNamedValue(propertiesArray, "passkey", EmptyString());
+  AppendNamedValue(propertiesArray, "type",
+                   NS_LITERAL_STRING(PAIRING_REQ_TYPE_ENTERPINCODE));
 
   DistributeSignal(NS_LITERAL_STRING("PairingRequest"),
                    NS_LITERAL_STRING(KEY_PAIRING_LISTENER),
                    BluetoothValue(propertiesArray));
 }
 
 void
 BluetoothServiceBluedroid::SspRequestNotification(
@@ -1868,20 +1861,20 @@ BluetoothServiceBluedroid::SspRequestNot
     case SSP_VARIANT_CONSENT:
       pairingType.AssignLiteral(PAIRING_REQ_TYPE_CONSENT);
       break;
     default:
       BT_WARNING("Unhandled SSP Bonding Variant: %d", aPairingVariant);
       return;
   }
 
-  BT_APPEND_NAMED_VALUE(propertiesArray, "address", bdAddr);
-  BT_APPEND_NAMED_VALUE(propertiesArray, "name", bdName);
-  BT_APPEND_NAMED_VALUE(propertiesArray, "passkey", passkey);
-  BT_APPEND_NAMED_VALUE(propertiesArray, "type", pairingType);
+  AppendNamedValue(propertiesArray, "address", bdAddr);
+  AppendNamedValue(propertiesArray, "name", bdName);
+  AppendNamedValue(propertiesArray, "passkey", passkey);
+  AppendNamedValue(propertiesArray, "type", pairingType);
 
   DistributeSignal(NS_LITERAL_STRING("PairingRequest"),
                    NS_LITERAL_STRING(KEY_PAIRING_LISTENER),
                    BluetoothValue(propertiesArray));
 }
 
 void
 BluetoothServiceBluedroid::BondStateChangedNotification(
@@ -1933,27 +1926,27 @@ BluetoothServiceBluedroid::BondStateChan
     if (!mBondedAddresses.Contains(remoteBdAddr)) {
       mBondedAddresses.AppendElement(remoteBdAddr);
     }
 
     // We don't assert |!remotebdName.IsEmpty()| since empty string is also
     // valid, according to Bluetooth Core Spec. v3.0 - Sec. 6.22:
     // "a valid Bluetooth name is a UTF-8 encoding string which is up to 248
     // bytes in length."
-    BT_APPEND_NAMED_VALUE(propertiesArray, "Name", remotebdName);
+    AppendNamedValue(propertiesArray, "Name", remotebdName);
   }
 
   // Notify device of attribute changed
-  BT_APPEND_NAMED_VALUE(propertiesArray, "Paired", bonded);
+  AppendNamedValue(propertiesArray, "Paired", bonded);
   DistributeSignal(NS_LITERAL_STRING("PropertyChanged"),
                    remoteBdAddr,
                    BluetoothValue(propertiesArray));
 
   // Notify adapter of device paired/unpaired
-  BT_INSERT_NAMED_VALUE(propertiesArray, 0, "Address", remoteBdAddr);
+  InsertNamedValue(propertiesArray, 0, "Address", remoteBdAddr);
   DistributeSignal(bonded ? NS_LITERAL_STRING(DEVICE_PAIRED_ID)
                           : NS_LITERAL_STRING(DEVICE_UNPAIRED_ID),
                    NS_LITERAL_STRING(KEY_ADAPTER),
                    BluetoothValue(propertiesArray));
 
   // Resolve existing pair/unpair promise
   if (bonded && !mCreateBondRunnables.IsEmpty()) {
     DispatchReplySuccess(mCreateBondRunnables[0]);
--- a/dom/bluetooth/bluedroid/hfp/BluetoothHfpManager.cpp
+++ b/dom/bluetooth/bluedroid/hfp/BluetoothHfpManager.cpp
@@ -604,17 +604,17 @@ BluetoothHfpManager::NotifyConnectionSta
 }
 
 void
 BluetoothHfpManager::NotifyDialer(const nsAString& aCommand)
 {
   NS_NAMED_LITERAL_STRING(type, "bluetooth-dialer-command");
   InfallibleTArray<BluetoothNamedValue> parameters;
 
-  BT_APPEND_NAMED_VALUE(parameters, "command", nsString(aCommand));
+  AppendNamedValue(parameters, "command", nsString(aCommand));
 
   BT_ENSURE_TRUE_VOID_BROADCAST_SYSMSG(type, parameters);
 }
 
 class BluetoothHfpManager::VolumeControlResultHandler final
   : public BluetoothHandsfreeResultHandler
 {
 public:
--- a/dom/bluetooth/common/BluetoothCommon.h
+++ b/dom/bluetooth/common/BluetoothCommon.h
@@ -54,32 +54,16 @@ extern bool gBluetoothDebugFlag;
     }                                                                \
   } while(0)
 
 #define BT_LOGR(msg, ...) printf("%s: " msg, __FUNCTION__, ##__VA_ARGS__)
 #define BT_WARNING(msg, ...) printf("%s: " msg, __FUNCTION__, ##__VA_ARGS__)
 #endif
 
 /**
- * Wrap literal name and value into a BluetoothNamedValue
- * and append it to the array.
- */
-#define BT_APPEND_NAMED_VALUE(array, name, value)                    \
-  array.AppendElement(BluetoothNamedValue(NS_LITERAL_STRING(name),   \
-                                          BluetoothValue(value)))
-
-/**
- * Wrap literal name and value into a BluetoothNamedValue
- * and insert it to the array.
- */
-#define BT_INSERT_NAMED_VALUE(array, index, name, value)                      \
-  array.InsertElementAt(index, BluetoothNamedValue(NS_LITERAL_STRING(name),   \
-                                                   BluetoothValue(value)))
-
-/**
  * Convert an enum value to string and append it to a fallible array.
  */
 #define BT_APPEND_ENUM_STRING_FALLIBLE(array, enumType, enumValue)   \
   do {                                                               \
     uint32_t index = uint32_t(enumValue);                            \
     nsAutoString name;                                               \
     name.AssignASCII(enumType##Values::strings[index].value,         \
                      enumType##Values::strings[index].length);       \
--- a/dom/bluetooth/common/BluetoothHidManager.cpp
+++ b/dom/bluetooth/common/BluetoothHidManager.cpp
@@ -239,18 +239,18 @@ BluetoothHidManager::HandleInputProperty
 void
 BluetoothHidManager::NotifyStatusChanged()
 {
   MOZ_ASSERT(NS_IsMainThread());
 
   NS_NAMED_LITERAL_STRING(type, BLUETOOTH_HID_STATUS_CHANGED_ID);
   InfallibleTArray<BluetoothNamedValue> parameters;
 
-  BT_APPEND_NAMED_VALUE(parameters, "connected", mConnected);
-  BT_APPEND_NAMED_VALUE(parameters, "address", mDeviceAddress);
+  AppendNamedValue(parameters, "connected", mConnected);
+  AppendNamedValue(parameters, "address", mDeviceAddress);
 
   BT_ENSURE_TRUE_VOID_BROADCAST_SYSMSG(type, parameters);
 }
 
 void
 BluetoothHidManager::OnGetServiceChannel(const nsAString& aDeviceAddress,
                                          const nsAString& aServiceUuid,
                                          int aChannel)
--- a/dom/bluetooth/common/BluetoothService.cpp
+++ b/dom/bluetooth/common/BluetoothService.cpp
@@ -659,17 +659,17 @@ BluetoothService::EnableDisable(bool aEn
 }
 
 void
 BluetoothService::FireAdapterStateChanged(bool aEnable)
 {
   MOZ_ASSERT(NS_IsMainThread());
 
   InfallibleTArray<BluetoothNamedValue> props;
-  BT_APPEND_NAMED_VALUE(props, "State", aEnable);
+  AppendNamedValue(props, "State", aEnable);
 
   DistributeSignal(NS_LITERAL_STRING("PropertyChanged"),
                    NS_LITERAL_STRING(KEY_ADAPTER),
                    BluetoothValue(props));
 }
 
 void
 BluetoothService::AcknowledgeToggleBt(bool aEnabled)
--- a/dom/bluetooth/common/BluetoothUtils.cpp
+++ b/dom/bluetooth/common/BluetoothUtils.cpp
@@ -307,18 +307,39 @@ DispatchReplyError(BluetoothReplyRunnabl
 void
 DispatchStatusChangedEvent(const nsAString& aType,
                            const nsAString& aAddress,
                            bool aStatus)
 {
   MOZ_ASSERT(NS_IsMainThread());
 
   InfallibleTArray<BluetoothNamedValue> data;
-  BT_APPEND_NAMED_VALUE(data, "address", nsString(aAddress));
-  BT_APPEND_NAMED_VALUE(data, "status", aStatus);
+  AppendNamedValue(data, "address", nsString(aAddress));
+  AppendNamedValue(data, "status", aStatus);
 
   BluetoothService* bs = BluetoothService::Get();
   NS_ENSURE_TRUE_VOID(bs);
 
   bs->DistributeSignal(aType, NS_LITERAL_STRING(KEY_ADAPTER), data);
 }
 
+void
+AppendNamedValue(InfallibleTArray<BluetoothNamedValue>& aArray,
+                 const char* aName, const BluetoothValue& aValue)
+{
+  nsString name;
+  name.AssignASCII(aName);
+
+  aArray.AppendElement(BluetoothNamedValue(name, aValue));
+}
+
+void
+InsertNamedValue(InfallibleTArray<BluetoothNamedValue>& aArray,
+                 uint8_t aIndex, const char* aName,
+                 const BluetoothValue& aValue)
+{
+  nsString name;
+  name.AssignASCII(aName);
+
+  aArray.InsertElementAt(aIndex, BluetoothNamedValue(name, aValue));
+}
+
 END_BLUETOOTH_NAMESPACE
--- a/dom/bluetooth/common/BluetoothUtils.h
+++ b/dom/bluetooth/common/BluetoothUtils.h
@@ -152,11 +152,30 @@ void
 DispatchReplyError(BluetoothReplyRunnable* aRunnable,
                    const enum BluetoothStatus aStatus);
 
 void
 DispatchStatusChangedEvent(const nsAString& aType,
                            const nsAString& aDeviceAddress,
                            bool aStatus);
 
+//
+// BluetoothNamedValue manipulation
+//
+
+/**
+ * Wrap literal name and value into a BluetoothNamedValue and
+ * append it to the array.
+ */
+void AppendNamedValue(InfallibleTArray<BluetoothNamedValue>& aArray,
+                      const char* aName, const BluetoothValue& aValue);
+
+/**
+ * Wrap literal name and value into a BluetoothNamedValue and
+ * insert it to the array.
+ */
+void InsertNamedValue(InfallibleTArray<BluetoothNamedValue>& aArray,
+                      uint8_t aIndex, const char* aName,
+                      const BluetoothValue& aValue);
+
 END_BLUETOOTH_NAMESPACE
 
 #endif // mozilla_dom_bluetooth_BluetoothUtils_h
--- a/dom/bluetooth/common/webapi/BluetoothAdapter.cpp
+++ b/dom/bluetooth/common/webapi/BluetoothAdapter.cpp
@@ -444,18 +444,18 @@ BluetoothAdapter::SetPropertyByValue(con
     for (uint32_t i = 0; i < pairedDeviceAddresses.Length(); i++) {
       if (mDevices.Contains(pairedDeviceAddresses[i])) {
         // Existing paired devices handle 'PropertyChanged' signal
         // in BluetoothDevice::Notify()
         continue;
       }
 
       InfallibleTArray<BluetoothNamedValue> props;
-      BT_APPEND_NAMED_VALUE(props, "Address", pairedDeviceAddresses[i]);
-      BT_APPEND_NAMED_VALUE(props, "Paired", true);
+      AppendNamedValue(props, "Address", pairedDeviceAddresses[i]);
+      AppendNamedValue(props, "Paired", true);
 
       // Create paired device and append to adapter's device array
       mDevices.AppendElement(
         BluetoothDevice::Create(GetOwner(), BluetoothValue(props)));
     }
 
     // Retrieve device properties, result will be handled by device objects.
     GetPairedDeviceProperties(pairedDeviceAddresses);