Bug 1425926 - Add IPC serialization support for EnumSet. r=botond
authorDaniel Zielas <zielas.daniel@gmail.com>
Wed, 27 Dec 2017 21:46:03 +0100
changeset 449224 03c9d149151518d8b3b4312379dc783fca36585a
parent 449223 4cdac2f62179db0ca9b89cf1b45c6201c3dc526a
child 449225 d8d0222927b44d384e9caef796ee52372050659e
child 449229 5fff4549d41137f153e4fd2ea1a0f0be37a13c02
push id8527
push userCallek@gmail.com
push dateThu, 11 Jan 2018 21:05:50 +0000
treeherdermozilla-beta@95342d212a7a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbotond
bugs1425926
milestone59.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 1425926 - Add IPC serialization support for EnumSet. r=botond MozReview-Commit-ID: Ess2R3Rroym
ipc/glue/IPCMessageUtils.h
--- a/ipc/glue/IPCMessageUtils.h
+++ b/ipc/glue/IPCMessageUtils.h
@@ -9,16 +9,17 @@
 
 #include "base/process_util.h"
 #include "chrome/common/ipc_message_utils.h"
 
 #include "mozilla/ArrayUtils.h"
 #include "mozilla/Attributes.h"
 #include "mozilla/DebugOnly.h"
 #include "mozilla/dom/ipc/StructuredCloneData.h"
+#include "mozilla/EnumSet.h"
 #include "mozilla/Maybe.h"
 #include "mozilla/net/WebSocketFrame.h"
 #include "mozilla/TimeStamp.h"
 #ifdef XP_WIN
 #include "mozilla/TimeStamp_windows.h"
 #endif
 #include "mozilla/TypeTraits.h"
 #include "mozilla/IntegerTypeTraits.h"
@@ -913,16 +914,37 @@ struct ParamTraits<mozilla::Maybe<T>>
       *result = mozilla::Some(mozilla::Move(tmp));
     } else {
       *result = mozilla::Nothing();
     }
     return true;
   }
 };
 
+template<typename T>
+struct ParamTraits<mozilla::EnumSet<T>>
+{
+  typedef mozilla::EnumSet<T> paramType;
+
+  static void Write(Message* msg, const paramType& param)
+  {
+    WriteParam(msg, param.serialize());
+  }
+
+  static bool Read(const Message* msg, PickleIterator* iter, paramType* result)
+  {
+    decltype(result->serialize()) tmp;
+    if (ReadParam(msg, iter, &tmp)) {
+      result->deserialize(tmp);
+      return true;
+    }
+    return false;
+  }
+};
+
 template<class... Ts>
 struct ParamTraits<mozilla::Variant<Ts...>>
 {
   typedef mozilla::Variant<Ts...> paramType;
   using Tag = typename mozilla::detail::VariantTag<Ts...>::Type;
 
   struct VariantWriter
   {