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 465776 8761ce294d2c
parent 465775 1d405e872db4
child 465777 9bfd4e60ec4e
push id81233
push userdothayer@mozilla.com
push dateFri, 22 Mar 2019 18:54:42 +0000
treeherderautoland@9bfd4e60ec4e [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) {