Bug 1202704: Move Bluetooth's |UnpackPDUInitOp| to generic HAL IPC code, r=shuang
authorThomas Zimmermann <tdz@users.sourceforge.net>
Wed, 09 Sep 2015 13:40:26 +0200
changeset 294104 834376f2e95eeb0e96b8eca6c251475562b5da53
parent 294103 d019cd8fc5cc3ff426129a52fe74da16cf6013a0
child 294105 b74e8af3488c8ee0810a3324a929d6034899c241
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
bugs1202704
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 1202704: Move Bluetooth's |UnpackPDUInitOp| to generic HAL IPC code, r=shuang
dom/bluetooth/bluedroid/BluetoothDaemonHelpers.h
ipc/hal/DaemonSocketPDUHelpers.h
--- a/dom/bluetooth/bluedroid/BluetoothDaemonHelpers.h
+++ b/dom/bluetooth/bluedroid/BluetoothDaemonHelpers.h
@@ -531,137 +531,11 @@ inline nsresult
 UnpackPDU(DaemonSocketPDU& aPDU, const UnpackReversed<BluetoothUuid>& aOut)
 {
   return UnpackPDU(
     aPDU,
     UnpackReversed<UnpackArray<uint8_t>>(
       UnpackArray<uint8_t>(aOut.mValue->mUuid, sizeof(aOut.mValue->mUuid))));
 }
 
-//
-// Init operators
-//
-
-// |UnpackPDUInitOp| is a general-purpose init operator for all variants
-// of |BluetoothResultRunnable| and |BluetoothNotificationRunnable|. The
-// call operators of |UnpackPDUInitOp| unpack a PDU into the supplied
-// arguments.
-class UnpackPDUInitOp final : private PDUInitOp
-{
-public:
-  UnpackPDUInitOp(DaemonSocketPDU& aPDU)
-  : PDUInitOp(aPDU)
-  { }
-
-  nsresult operator () () const
-  {
-    WarnAboutTrailingData();
-    return NS_OK;
-  }
-
-  template<typename T1>
-  nsresult operator () (T1& aArg1) const
-  {
-    nsresult rv = UnpackPDU(GetPDU(), aArg1);
-    if (NS_FAILED(rv)) {
-      return rv;
-    }
-    WarnAboutTrailingData();
-    return NS_OK;
-  }
-
-  template<typename T1, typename T2>
-  nsresult operator () (T1& aArg1, T2& aArg2) const
-  {
-    DaemonSocketPDU& pdu = GetPDU();
-
-    nsresult rv = UnpackPDU(pdu, aArg1);
-    if (NS_FAILED(rv)) {
-      return rv;
-    }
-    rv = UnpackPDU(pdu, aArg2);
-    if (NS_FAILED(rv)) {
-      return rv;
-    }
-    WarnAboutTrailingData();
-    return NS_OK;
-  }
-
-  template<typename T1, typename T2, typename T3>
-  nsresult operator () (T1& aArg1, T2& aArg2, T3& aArg3) const
-  {
-    DaemonSocketPDU& pdu = GetPDU();
-
-    nsresult rv = UnpackPDU(pdu, aArg1);
-    if (NS_FAILED(rv)) {
-      return rv;
-    }
-    rv = UnpackPDU(pdu, aArg2);
-    if (NS_FAILED(rv)) {
-      return rv;
-    }
-    rv = UnpackPDU(pdu, aArg3);
-    if (NS_FAILED(rv)) {
-      return rv;
-    }
-    WarnAboutTrailingData();
-    return NS_OK;
-  }
-
-  template<typename T1, typename T2, typename T3, typename T4>
-  nsresult operator () (T1& aArg1, T2& aArg2, T3& aArg3, T4& aArg4) const
-  {
-    DaemonSocketPDU& pdu = GetPDU();
-
-    nsresult rv = UnpackPDU(pdu, aArg1);
-    if (NS_FAILED(rv)) {
-      return rv;
-    }
-    rv = UnpackPDU(pdu, aArg2);
-    if (NS_FAILED(rv)) {
-      return rv;
-    }
-    rv = UnpackPDU(pdu, aArg3);
-    if (NS_FAILED(rv)) {
-      return rv;
-    }
-    rv = UnpackPDU(pdu, aArg4);
-    if (NS_FAILED(rv)) {
-      return rv;
-    }
-    WarnAboutTrailingData();
-    return NS_OK;
-  }
-
-  template<typename T1, typename T2, typename T3, typename T4, typename T5>
-  nsresult operator () (T1& aArg1, T2& aArg2, T3& aArg3, T4& aArg4,
-                        T5& aArg5) const
-  {
-    DaemonSocketPDU& pdu = GetPDU();
-
-    nsresult rv = UnpackPDU(pdu, aArg1);
-    if (NS_FAILED(rv)) {
-      return rv;
-    }
-    rv = UnpackPDU(pdu, aArg2);
-    if (NS_FAILED(rv)) {
-      return rv;
-    }
-    rv = UnpackPDU(pdu, aArg3);
-    if (NS_FAILED(rv)) {
-      return rv;
-    }
-    rv = UnpackPDU(pdu, aArg4);
-    if (NS_FAILED(rv)) {
-      return rv;
-    }
-    rv = UnpackPDU(pdu, aArg5);
-    if (NS_FAILED(rv)) {
-      return rv;
-    }
-    WarnAboutTrailingData();
-    return NS_OK;
-  }
-};
-
 END_BLUETOOTH_NAMESPACE
 
 #endif // mozilla_dom_bluetooth_bluedroid_BluetoothDaemonHelpers_h
--- a/ipc/hal/DaemonSocketPDUHelpers.h
+++ b/ipc/hal/DaemonSocketPDUHelpers.h
@@ -826,14 +826,136 @@ protected:
   }
 
   void WarnAboutTrailingData() const;
 
 private:
   DaemonSocketPDU* mPDU; // Hold pointer to allow for constant instances
 };
 
+// |UnpackPDUInitOp| is a general-purpose init operator for all variants
+// of |DaemonResultRunnable| and |DaemonNotificationRunnable|. The call
+// operators of |UnpackPDUInitOp| unpack a PDU into the supplied
+// arguments.
+class UnpackPDUInitOp final : private PDUInitOp
+{
+public:
+  UnpackPDUInitOp(DaemonSocketPDU& aPDU)
+    : PDUInitOp(aPDU)
+  { }
+
+  nsresult operator () () const
+  {
+    WarnAboutTrailingData();
+    return NS_OK;
+  }
+
+  template<typename T1>
+  nsresult operator () (T1& aArg1) const
+  {
+    nsresult rv = UnpackPDU(GetPDU(), aArg1);
+    if (NS_FAILED(rv)) {
+      return rv;
+    }
+    WarnAboutTrailingData();
+    return NS_OK;
+  }
+
+  template<typename T1, typename T2>
+  nsresult operator () (T1& aArg1, T2& aArg2) const
+  {
+    DaemonSocketPDU& pdu = GetPDU();
+
+    nsresult rv = UnpackPDU(pdu, aArg1);
+    if (NS_FAILED(rv)) {
+      return rv;
+    }
+    rv = UnpackPDU(pdu, aArg2);
+    if (NS_FAILED(rv)) {
+      return rv;
+    }
+    WarnAboutTrailingData();
+    return NS_OK;
+  }
+
+  template<typename T1, typename T2, typename T3>
+  nsresult operator () (T1& aArg1, T2& aArg2, T3& aArg3) const
+  {
+    DaemonSocketPDU& pdu = GetPDU();
+
+    nsresult rv = UnpackPDU(pdu, aArg1);
+    if (NS_FAILED(rv)) {
+      return rv;
+    }
+    rv = UnpackPDU(pdu, aArg2);
+    if (NS_FAILED(rv)) {
+      return rv;
+    }
+    rv = UnpackPDU(pdu, aArg3);
+    if (NS_FAILED(rv)) {
+      return rv;
+    }
+    WarnAboutTrailingData();
+    return NS_OK;
+  }
+
+  template<typename T1, typename T2, typename T3, typename T4>
+  nsresult operator () (T1& aArg1, T2& aArg2, T3& aArg3, T4& aArg4) const
+  {
+    DaemonSocketPDU& pdu = GetPDU();
+
+    nsresult rv = UnpackPDU(pdu, aArg1);
+    if (NS_FAILED(rv)) {
+      return rv;
+    }
+    rv = UnpackPDU(pdu, aArg2);
+    if (NS_FAILED(rv)) {
+      return rv;
+    }
+    rv = UnpackPDU(pdu, aArg3);
+    if (NS_FAILED(rv)) {
+      return rv;
+    }
+    rv = UnpackPDU(pdu, aArg4);
+    if (NS_FAILED(rv)) {
+      return rv;
+    }
+    WarnAboutTrailingData();
+    return NS_OK;
+  }
+
+  template<typename T1, typename T2, typename T3, typename T4, typename T5>
+  nsresult operator () (T1& aArg1, T2& aArg2, T3& aArg3, T4& aArg4,
+                        T5& aArg5) const
+  {
+    DaemonSocketPDU& pdu = GetPDU();
+
+    nsresult rv = UnpackPDU(pdu, aArg1);
+    if (NS_FAILED(rv)) {
+      return rv;
+    }
+    rv = UnpackPDU(pdu, aArg2);
+    if (NS_FAILED(rv)) {
+      return rv;
+    }
+    rv = UnpackPDU(pdu, aArg3);
+    if (NS_FAILED(rv)) {
+      return rv;
+    }
+    rv = UnpackPDU(pdu, aArg4);
+    if (NS_FAILED(rv)) {
+      return rv;
+    }
+    rv = UnpackPDU(pdu, aArg5);
+    if (NS_FAILED(rv)) {
+      return rv;
+    }
+    WarnAboutTrailingData();
+    return NS_OK;
+  }
+};
+
 } // namespace DaemonSocketPDUHelpers
 
 } // namespace ipc
 } // namespace mozilla
 
 #endif // mozilla_ipc_DaemonSocketPDUHelpers_h