Bug 1418048 - Part 2: Pass callbacks by rvalue reference when possible, a=bustage
authorNika Layzell <nika@thelayzells.com>
Mon, 20 Nov 2017 18:12:21 -0500
changeset 392814 29e4123595f521b540cf8349837308e176211833
parent 392813 82dbe444d5e3cc4f1a184e5bcf38e0d9b39b9872
child 392815 2bb133c24dca29fc04a9862f2f173cae0f2515cf
push id32942
push usertoros@mozilla.com
push dateTue, 21 Nov 2017 09:56:05 +0000
treeherdermozilla-central@72ee4800d415 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbustage
bugs1418048
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 1418048 - Part 2: Pass callbacks by rvalue reference when possible, a=bustage MozReview-Commit-ID: 4KsbRJ9AEdB
dom/ipc/ContentChild.cpp
ipc/glue/MessageChannel.h
ipc/ipdl/ipdl/lower.py
--- a/dom/ipc/ContentChild.cpp
+++ b/dom/ipc/ContentChild.cpp
@@ -1013,17 +1013,17 @@ ContentChild::ProvideWindowCommon(TabChi
       url.SetIsVoid(true);
     }
 
     // NOTE: BrowserFrameOpenWindowPromise is the same type as
     // CreateWindowPromise, and this code depends on that fact.
     newChild->SendBrowserFrameOpenWindow(aTabOpener, renderFrame,
                                          NS_ConvertUTF8toUTF16(url),
                                          name, NS_ConvertUTF8toUTF16(features),
-                                         resolve, reject);
+                                         Move(resolve), Move(reject));
   } else {
     nsAutoCString baseURIString;
     float fullZoom;
     nsCOMPtr<nsIPrincipal> triggeringPrincipal;
     rv = GetWindowParamsFromParent(aParent, baseURIString, &fullZoom,
                                    getter_AddRefs(triggeringPrincipal));
     if (NS_WARN_IF(NS_FAILED(rv))) {
       return rv;
@@ -1035,17 +1035,17 @@ ContentChild::ProvideWindowCommon(TabChi
     } else {
       uriToLoad = mozilla::void_t();
     }
 
     SendCreateWindow(aTabOpener, newChild, renderFrame,
                      aChromeFlags, aCalledFromJS, aPositionSpecified,
                      aSizeSpecified, uriToLoad, features, baseURIString,
                      fullZoom, Principal(triggeringPrincipal),
-                     resolve, reject);
+                     Move(resolve), Move(reject));
   }
 
   // =======================
   // Begin Nested Event Loop
   // =======================
 
   // We have to wait for a response from either SendCreateWindow or
   // SendBrowserFrameOpenWindow with information we're going to need to return
--- a/ipc/glue/MessageChannel.h
+++ b/ipc/glue/MessageChannel.h
@@ -104,17 +104,17 @@ class MessageChannel : HasResultCodes, M
     // expand the code size. Using the actor address as the
     // identifier is already good enough.
     typedef void* ActorIdType;
 
 public:
     struct UntypedCallbackHolder
     {
         UntypedCallbackHolder(ActorIdType aActorId,
-                              RejectCallback aReject)
+                              RejectCallback&& aReject)
             : mActorId(aActorId)
             , mReject(Move(aReject))
         {}
 
         virtual ~UntypedCallbackHolder() {}
 
         void Reject(ResponseRejectReason aReason) {
             mReject(aReason);
@@ -123,18 +123,18 @@ public:
         ActorIdType mActorId;
         RejectCallback mReject;
     };
 
     template<typename Value>
     struct CallbackHolder : public UntypedCallbackHolder
     {
         CallbackHolder(ActorIdType aActorId,
-                       ResolveCallback<Value> aResolve,
-                       RejectCallback aReject)
+                       ResolveCallback<Value>&& aResolve,
+                       RejectCallback&& aReject)
             : UntypedCallbackHolder(aActorId, Move(aReject))
             , mResolve(Move(aResolve))
         {}
 
         void Resolve(Value&& aReason) {
             mResolve(Move(aReason));
         }
 
@@ -217,18 +217,18 @@ private:
     // Asynchronously send a message to the other side of the channel
     bool Send(Message* aMsg);
 
     // Asynchronously send a message to the other side of the channel
     // and wait for asynchronous reply.
     template<typename Value>
     void Send(Message* aMsg,
               ActorIdType aActorId,
-              ResolveCallback<Value> aResolve,
-              RejectCallback aReject) {
+              ResolveCallback<Value>&& aResolve,
+              RejectCallback&& aReject) {
         int32_t seqno = NextSeqno();
         aMsg->set_seqno(seqno);
         if (!Send(aMsg)) {
             aReject(ResponseRejectReason::SendError);
             return;
         }
 
         UniquePtr<UntypedCallbackHolder> callback =
--- a/ipc/ipdl/ipdl/lower.py
+++ b/ipc/ipdl/ipdl/lower.py
@@ -4629,18 +4629,18 @@ class _GenerateProtocolActorCode(ipdl.as
                   self.profilerLabel(md) ] + self.transition(md, actor)
         stmts.append(Whitespace.NL)
 
         # Generate the actual call expression.
         send = ExprSelect(self.protocol.callGetChannel(actor), '->', 'Send')
         if md.returns:
             stmts.append(StmtExpr(ExprCall(send, args=[ msgexpr,
                                                         ExprVar('this'),
-                                                        resolvefn,
-                                                        rejectfn ])))
+                                                        ExprMove(resolvefn),
+                                                        ExprMove(rejectfn) ])))
             retvar = None
         else:
             stmts.append(StmtDecl(Decl(Type.BOOL, sendok.name),
                                   init=ExprCall(send, args=[ msgexpr ])))
             retvar = sendok
 
         return (retvar, stmts)