Bug 1350637 - Part 3: Move mozilla::dom::Optional serialization helper to ipc/glue/IPCMessageUtils.h to make it available to other consumers. r=billm, a=lizzard
authorJan Varga <jan.varga@gmail.com>
Tue, 08 Aug 2017 23:01:03 +0200
changeset 421296 b0bed209e7f7
parent 421295 5b5c8f31b0a7
child 421297 d06e37723df2
push id7647
push userryanvm@gmail.com
push dateMon, 21 Aug 2017 19:15:39 +0000
treeherdermozilla-beta@6a2167880016 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbillm, lizzard
bugs1350637
milestone56.0
Bug 1350637 - Part 3: Move mozilla::dom::Optional serialization helper to ipc/glue/IPCMessageUtils.h to make it available to other consumers. r=billm, a=lizzard
dom/media/webrtc/WebrtcGlobal.h
ipc/glue/IPCMessageUtils.h
--- a/dom/media/webrtc/WebrtcGlobal.h
+++ b/dom/media/webrtc/WebrtcGlobal.h
@@ -12,52 +12,16 @@
 
 typedef mozilla::dom::RTCStatsReportInternal StatsReport;
 typedef nsTArray< nsAutoPtr<StatsReport>> RTCReports;
 typedef mozilla::dom::Sequence<nsString> WebrtcGlobalLog;
 
 namespace IPC {
 
 template<typename T>
-struct ParamTraits<mozilla::dom::Optional<T>>
-{
-  typedef mozilla::dom::Optional<T> paramType;
-
-  static void Write(Message* aMsg, const paramType& aParam)
-  {
-    if (aParam.WasPassed()) {
-      WriteParam(aMsg, true);
-      WriteParam(aMsg, aParam.Value());
-      return;
-    }
-
-    WriteParam(aMsg, false);
-  }
-
-  static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult)
-  {
-    bool was_passed = false;
-
-    if (!ReadParam(aMsg, aIter, &was_passed)) {
-      return false;
-    }
-
-    aResult->Reset(); //XXX Optional_base seems to reach this point with isSome true.
-
-    if (was_passed) {
-      if (!ReadParam(aMsg, aIter, &(aResult->Construct()))) {
-        return false;
-      }
-    }
-
-    return true;
-  }
-};
-
-template<typename T>
 struct ParamTraits<mozilla::dom::Sequence<T>>
 {
   typedef mozilla::dom::Sequence<T> paramType;
 
   static void Write(Message* aMsg, const paramType& aParam)
   {
     WriteParam(aMsg, static_cast<const FallibleTArray<T>&>(aParam));
   }
--- a/ipc/glue/IPCMessageUtils.h
+++ b/ipc/glue/IPCMessageUtils.h
@@ -974,11 +974,47 @@ struct ParamTraits<mozilla::Variant<Ts..
     Tag tag;
     if (ReadParam(msg, iter, &tag)) {
       return VariantReader<sizeof...(Ts)>::Read(msg, iter, tag, result);
     }
     return false;
   }
 };
 
+template<typename T>
+struct ParamTraits<mozilla::dom::Optional<T>>
+{
+  typedef mozilla::dom::Optional<T> paramType;
+
+  static void Write(Message* aMsg, const paramType& aParam)
+  {
+    if (aParam.WasPassed()) {
+      WriteParam(aMsg, true);
+      WriteParam(aMsg, aParam.Value());
+      return;
+    }
+
+    WriteParam(aMsg, false);
+  }
+
+  static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult)
+  {
+    bool wasPassed = false;
+
+    if (!ReadParam(aMsg, aIter, &wasPassed)) {
+      return false;
+    }
+
+    aResult->Reset();
+
+    if (wasPassed) {
+      if (!ReadParam(aMsg, aIter, &aResult->Construct())) {
+        return false;
+      }
+    }
+
+    return true;
+  }
+};
+
 } /* namespace IPC */
 
 #endif /* __IPC_GLUE_IPCMESSAGEUTILS_H__ */