Bug 1186317 - [cleanup] Remove unused macros and unnecessary logs, r=shuang
authorBen Tian <btian@mozilla.com>
Tue, 21 Jul 2015 18:05:44 +0800
changeset 254163 0ab04fa107627a3c597d2a348899f5941dcc78b8
parent 254162 2459286437139795b247a8f6517237e8cf5913cb
child 254164 34c435547025fb41ed950650ca52c776545c0fb3
push id29092
push usercbook@mozilla.com
push dateThu, 23 Jul 2015 09:49:12 +0000
treeherdermozilla-central@8a28809f50b4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersshuang
bugs1186317
milestone42.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 1186317 - [cleanup] Remove unused macros and unnecessary logs, r=shuang
dom/bluetooth/BluetoothCommon.h
dom/bluetooth/BluetoothRilListener.cpp
dom/bluetooth/bluetooth2/BluetoothAdapter.cpp
dom/bluetooth/bluetooth2/BluetoothDevice.h
dom/bluetooth/bluetooth2/BluetoothPairingListener.cpp
--- a/dom/bluetooth/BluetoothCommon.h
+++ b/dom/bluetooth/BluetoothCommon.h
@@ -52,23 +52,23 @@ extern bool gBluetoothDebugFlag;
     }                                                                \
   } while(0)
 
 /**
  * Prints 'R'ELEASE build logs, which show in both RELEASE and DEBUG builds.
  */
 #define BT_LOGR(msg, ...)                                            \
   __android_log_print(ANDROID_LOG_INFO, "GeckoBluetooth",            \
-                      "%s: " msg, __FUNCTION__, ##__VA_ARGS__)       \
+                      "%s: " msg, __FUNCTION__, ##__VA_ARGS__)
 
 /**
  * Prints DEBUG build warnings, which show in DEBUG build only.
  */
 #define BT_WARNING(args...)                                          \
-  NS_WARNING(nsPrintfCString(args).get())                            \
+  NS_WARNING(nsPrintfCString(args).get())
 
 #else
 #define BT_LOGD(msg, ...)                                            \
   do {                                                               \
     if (gBluetoothDebugFlag) {                                       \
       printf("%s: " msg, __FUNCTION__, ##__VA_ARGS__);               \
     }                                                                \
   } while(0)
@@ -83,58 +83,48 @@ extern bool gBluetoothDebugFlag;
  */
 #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.
+ *
+ * TODO: remove with bluetooth1
  */
 #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);       \
+    array.AppendElement(name, mozilla::fallible);                    \
+  } while(0)
+
+/**
  * Ensure success of system message broadcast with void return.
  */
 #define BT_ENSURE_TRUE_VOID_BROADCAST_SYSMSG(type, parameters)       \
   do {                                                               \
     if (!BroadcastSystemMessage(type, parameters)) {                 \
       BT_WARNING("Failed to broadcast [%s]",                         \
                  NS_ConvertUTF16toUTF8(type).get());                 \
       return;                                                        \
     }                                                                \
   } while(0)
 
 /**
- * Convert an enum value to string then append it to an array.
- */
-#define BT_APPEND_ENUM_STRING(array, enumType, enumValue)            \
-  do {                                                               \
-    uint32_t index = uint32_t(enumValue);                            \
-    nsAutoString name;                                               \
-    name.AssignASCII(enumType##Values::strings[index].value,         \
-                     enumType##Values::strings[index].length);       \
-    array.AppendElement(name);                                       \
-  } while(0)                                                         \
-
-/**
- * Convert an enum value to string then 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);       \
-    array.AppendElement(name, mozilla::fallible);                    \
-  } while(0)                                                         \
-
-/**
  * Resolve |promise| with |ret| if |x| is false.
  */
 #define BT_ENSURE_TRUE_RESOLVE(x, promise, ret)                      \
   do {                                                               \
     if (MOZ_UNLIKELY(!(x))) {                                        \
       BT_LOGR("BT_ENSURE_TRUE_RESOLVE(" #x ") failed");              \
       (promise)->MaybeResolve(ret);                                  \
       return (promise).forget();                                     \
@@ -148,16 +138,22 @@ extern bool gBluetoothDebugFlag;
   do {                                                               \
     if (MOZ_UNLIKELY(!(x))) {                                        \
       BT_LOGR("BT_ENSURE_TRUE_REJECT(" #x ") failed");               \
       (promise)->MaybeReject(ret);                                   \
       return (promise).forget();                                     \
     }                                                                \
   } while(0)
 
+/**
+ * Reject |promise| with |ret| if nsresult |rv| is not successful.
+ */
+#define BT_ENSURE_SUCCESS_REJECT(rv, promise, ret)                   \
+  BT_ENSURE_TRUE_REJECT(NS_SUCCEEDED(rv), promise, ret)
+
 #define BEGIN_BLUETOOTH_NAMESPACE \
   namespace mozilla { namespace dom { namespace bluetooth {
 #define END_BLUETOOTH_NAMESPACE \
   } /* namespace bluetooth */ } /* namespace dom */ } /* namespace mozilla */
 #define USING_BLUETOOTH_NAMESPACE \
   using namespace mozilla::dom::bluetooth;
 
 #define KEY_LOCAL_AGENT       "/B2G/bluetooth/agent"
--- a/dom/bluetooth/BluetoothRilListener.cpp
+++ b/dom/bluetooth/BluetoothRilListener.cpp
@@ -394,17 +394,17 @@ BluetoothRilListener::ServiceChanged(uin
     mClientId = aClientId;
   } else {
     SelectClient();
   }
 
   // Restart listening
   ListenMobileConnAndIccInfo(true);
 
-  BT_LOGR("%d client %d. new mClientId %d", aRegistered, aClientId,
+  BT_LOGD("%d client %d. new mClientId %d", aRegistered, aClientId,
           (mClientId < mMobileConnListeners.Length()) ? mClientId : -1);
 }
 
 void
 BluetoothRilListener::EnumerateCalls()
 {
   nsCOMPtr<nsITelephonyService> service =
     do_GetService(TELEPHONY_SERVICE_CONTRACTID);
--- a/dom/bluetooth/bluetooth2/BluetoothAdapter.cpp
+++ b/dom/bluetooth/bluetooth2/BluetoothAdapter.cpp
@@ -404,33 +404,29 @@ BluetoothAdapter::SetPropertyByValue(con
       // Reset discovery handle in use to nullptr
       SetDiscoveryHandleInUse(nullptr);
     }
   } else if (name.EqualsLiteral("PairedDevices")) {
     const InfallibleTArray<nsString>& pairedDeviceAddresses
       = value.get_ArrayOfnsString();
 
     for (uint32_t i = 0; i < pairedDeviceAddresses.Length(); i++) {
-      // Check whether or not the address exists in mDevices.
       if (mDevices.Contains(pairedDeviceAddresses[i])) {
-        // If the paired device exists in mDevices, it would handle
-        // 'PropertyChanged' signal in BluetoothDevice::Notify().
+        // 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);
 
-      // Create paired device with 'address' and 'paired' attributes
-      nsRefPtr<BluetoothDevice> pairedDevice =
-        BluetoothDevice::Create(GetOwner(), BluetoothValue(props));
-
-      // Append to adapter's device array
-      mDevices.AppendElement(pairedDevice);
+      // 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);
   } else {
     BT_WARNING("Not handling adapter property: %s",
                NS_ConvertUTF16toUTF8(name).get());
   }
@@ -688,22 +684,20 @@ BluetoothAdapter::SetName(const nsAStrin
                         NS_ERROR_DOM_INVALID_STATE_ERR);
   BluetoothService* bs = BluetoothService::Get();
   BT_ENSURE_TRUE_REJECT(bs, promise, NS_ERROR_NOT_AVAILABLE);
 
   // Wrap property to set and runnable to handle result
   nsString name(aName);
   BluetoothNamedValue property(NS_LITERAL_STRING("Name"),
                                BluetoothValue(name));
-  BT_ENSURE_TRUE_REJECT(
-    NS_SUCCEEDED(
-      bs->SetProperty(BluetoothObjectType::TYPE_ADAPTER, property,
-                      new BluetoothVoidReplyRunnable(nullptr, promise))),
-    promise,
-    NS_ERROR_DOM_OPERATION_ERR);
+  BT_ENSURE_SUCCESS_REJECT(
+    bs->SetProperty(BluetoothObjectType::TYPE_ADAPTER, property,
+                    new BluetoothVoidReplyRunnable(nullptr, promise)),
+    promise, NS_ERROR_DOM_OPERATION_ERR);
 
   return promise.forget();
 }
 
 already_AddRefed<Promise>
 BluetoothAdapter::SetDiscoverable(bool aDiscoverable, ErrorResult& aRv)
 {
   nsCOMPtr<nsIGlobalObject> global = do_QueryInterface(GetOwner());
@@ -728,22 +722,20 @@ BluetoothAdapter::SetDiscoverable(bool a
                         promise,
                         NS_ERROR_DOM_INVALID_STATE_ERR);
   BluetoothService* bs = BluetoothService::Get();
   BT_ENSURE_TRUE_REJECT(bs, promise, NS_ERROR_NOT_AVAILABLE);
 
   // Wrap property to set and runnable to handle result
   BluetoothNamedValue property(NS_LITERAL_STRING("Discoverable"),
                                BluetoothValue(aDiscoverable));
-  BT_ENSURE_TRUE_REJECT(
-    NS_SUCCEEDED(
-      bs->SetProperty(BluetoothObjectType::TYPE_ADAPTER, property,
-                      new BluetoothVoidReplyRunnable(nullptr, promise))),
-    promise,
-    NS_ERROR_DOM_OPERATION_ERR);
+  BT_ENSURE_SUCCESS_REJECT(
+    bs->SetProperty(BluetoothObjectType::TYPE_ADAPTER, property,
+                    new BluetoothVoidReplyRunnable(nullptr, promise)),
+    promise, NS_ERROR_DOM_OPERATION_ERR);
 
   return promise.forget();
 }
 
 already_AddRefed<DOMRequest>
 BluetoothAdapter::GetConnectedDevices(uint16_t aServiceUuid, ErrorResult& aRv)
 {
   MOZ_ASSERT(NS_IsMainThread());
--- a/dom/bluetooth/bluetooth2/BluetoothDevice.h
+++ b/dom/bluetooth/bluetooth2/BluetoothDevice.h
@@ -147,17 +147,17 @@ private:
   /**
    * Parse advertising data to update device properties.
    *
    * Parse 'Advertising Data Type' from an inquiry response and set name, UUIDs
    * and COD if they exist in ADV data.
    *
    * @param aAdvData [in] advertising data which provided by the LeScan result.
    */
-   void UpdatePropertiesFromAdvData(const nsTArray<uint8_t>& aAdvData);
+  void UpdatePropertiesFromAdvData(const nsTArray<uint8_t>& aAdvData);
 
   /****************************************************************************
    * Variables
    ***************************************************************************/
   /**
    * BD address of this device.
    */
   nsString mAddress;
--- a/dom/bluetooth/bluetooth2/BluetoothPairingListener.cpp
+++ b/dom/bluetooth/bluetooth2/BluetoothPairingListener.cpp
@@ -138,17 +138,17 @@ BluetoothPairingListener::TryListeningTo
 
   // Listen to bluetooth signal only if all pairing event handlers have been
   // attached. All pending pairing requests queued in BluetoothService would
   // be fired when pairing listener starts listening to bluetooth signal.
   if (!HasListenersFor(nsGkAtoms::ondisplaypasskeyreq) ||
       !HasListenersFor(nsGkAtoms::onenterpincodereq) ||
       !HasListenersFor(nsGkAtoms::onpairingconfirmationreq) ||
       !HasListenersFor(nsGkAtoms::onpairingconsentreq)) {
-    BT_LOGR("Pairing listener is not ready to handle pairing requests!");
+    BT_LOGD("Pairing listener is not ready to handle pairing requests!");
     return;
   }
 
   // Start listening to bluetooth signal to handle pairing requests
   RegisterBluetoothSignalHandler(NS_LITERAL_STRING(KEY_PAIRING_LISTENER),
                                  this);
 
   mHasListenedToSignal = true;