Bug 1441308 - Support moving Maybe's in IPC serialization r=mccr8
authorDoug Thayer <dothayer@mozilla.com>
Fri, 22 Mar 2019 18:29:00 +0000
changeset 465759 8761ce294d2c
parent 465758 1d405e872db4
child 465760 9bfd4e60ec4e
push id35746
push usershindli@mozilla.com
push dateSat, 23 Mar 2019 09:46:24 +0000
treeherdermozilla-central@02b7484f316b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmccr8
bugs1441308
milestone68.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 1441308 - Support moving Maybe's in IPC serialization r=mccr8 I'd like to move an ipc::ByteBuf member of a struct into a Maybe, and in order for that to work IPDLParamTraits<Maybe> needs to support the rvalue Write. Differential Revision: https://phabricator.services.mozilla.com/D23986
ipc/glue/IPDLParamTraits.h
--- a/ipc/glue/IPDLParamTraits.h
+++ b/ipc/glue/IPDLParamTraits.h
@@ -184,16 +184,26 @@ struct IPDLParamTraits<mozilla::Maybe<T>
     bool isSome = aParam.isSome();
     WriteIPDLParam(aMsg, aActor, isSome);
 
     if (isSome) {
       WriteIPDLParam(aMsg, aActor, std::move(aParam.value()));
     }
   }
 
+  static void Write(IPC::Message* aMsg, IProtocol* aActor,
+                    mozilla::Maybe<T>&& aParam) {
+    bool isSome = aParam.isSome();
+    WriteIPDLParam(aMsg, aActor, isSome);
+
+    if (isSome) {
+      WriteIPDLParam(aMsg, aActor, std::move(aParam.ref()));
+    }
+  }
+
   static bool Read(const IPC::Message* aMsg, PickleIterator* aIter,
                    IProtocol* aActor, mozilla::Maybe<T>* aResult) {
     bool isSome;
     if (!ReadIPDLParam(aMsg, aIter, aActor, &isSome)) {
       return false;
     }
 
     if (isSome) {