Bug 1512298 - Make IPDL MozPromise exclusive. r=gerald,froydnj
authorJean-Yves Avenard <jyavenard@mozilla.com>
Tue, 11 Dec 2018 19:22:26 +0000
changeset 507201 4e7923ac0159b263bfbe0b6922b485bb65005121
parent 507200 ac0ece710f8c949144b8273a833a506c45935b78
child 507202 2109be597625ff232c74d6b8778f32fcd964563c
push id10547
push userffxbld-merge
push dateMon, 21 Jan 2019 13:03:58 +0000
treeherdermozilla-beta@24ec1916bffe [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgerald, froydnj
bugs1512298
milestone66.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 1512298 - Make IPDL MozPromise exclusive. r=gerald,froydnj MozPromise most common use is to have an single or exclusive listener. By making the MozPromise generated by IPDL exclusive we can also use move semantics. While at it, we also use move semantics for the ResponseRejectReason and via the callback's reject method so that the lambda used with the MozPromise::Then can be identical to the one used by the IPDL callback. As it currently is, it provides no advantage over a copy as it's just an enum; however, this will facilitate future changes where it may not be. Differential Revision: https://phabricator.services.mozilla.com/D13906
dom/cache/CacheStreamControlChild.cpp
dom/ipc/TabParent.cpp
dom/media/CubebUtils.cpp
dom/media/gmp/ChromiumCDMParent.cpp
dom/serviceworkers/RemoteServiceWorkerContainerImpl.cpp
dom/serviceworkers/RemoteServiceWorkerRegistrationImpl.cpp
extensions/spellcheck/hunspell/glue/RemoteSpellCheckEngineChild.cpp
gfx/thebes/gfxPlatform.cpp
image/imgLoader.cpp
ipc/glue/MessageChannel.h
ipc/ipdl/ipdl/lower.py
ipc/ipdl/test/cxx/TestAsyncReturns.cpp
toolkit/components/extensions/webrequest/StreamFilter.cpp
tools/code-coverage/nsCodeCoverage.cpp
tools/profiler/gecko/nsProfiler.cpp
widget/PuppetWidget.cpp
--- a/dom/cache/CacheStreamControlChild.cpp
+++ b/dom/cache/CacheStreamControlChild.cpp
@@ -109,20 +109,20 @@ void CacheStreamControlChild::OpenStream
   // IPC operation below completes.  While the IPC layer will trigger a
   // rejection here in many cases, we must handle the case where the
   // MozPromise resolve runnable is already in the event queue when the
   // worker wants to shut down.
   RefPtr<CacheWorkerHolder> holder = GetWorkerHolder();
 
   SendOpenStream(aId)->Then(
       GetCurrentThreadSerialEventTarget(), __func__,
-      [aResolver, holder](const RefPtr<nsIInputStream>& aOptionalStream) {
-        aResolver(nsCOMPtr<nsIInputStream>(aOptionalStream));
+      [aResolver, holder](RefPtr<nsIInputStream>&& aOptionalStream) {
+        aResolver(nsCOMPtr<nsIInputStream>(aOptionalStream.forget()));
       },
-      [aResolver, holder](ResponseRejectReason aReason) {
+      [aResolver, holder](ResponseRejectReason&& aReason) {
         aResolver(nullptr);
       });
 }
 
 void CacheStreamControlChild::NoteClosedAfterForget(const nsID& aId) {
   NS_ASSERT_OWNINGTHREAD(CacheStreamControlChild);
   Unused << SendNoteClosed(aId);
 
--- a/dom/ipc/TabParent.cpp
+++ b/dom/ipc/TabParent.cpp
@@ -2694,24 +2694,24 @@ TabParent::GetContentBlockingLog(Promise
     return NS_ERROR_FAILURE;
   }
 
   RefPtr<Promise> copy(jsPromise);
   copy.forget(aPromise);
 
   auto cblPromise = SendGetContentBlockingLog();
   cblPromise->Then(GetMainThreadSerialEventTarget(), __func__,
-                   [jsPromise](Tuple<nsString, bool> aResult) {
+                   [jsPromise](Tuple<nsString, bool>&& aResult) {
                      if (Get<1>(aResult)) {
-                       jsPromise->MaybeResolve(Get<0>(aResult));
+                       jsPromise->MaybeResolve(std::move(Get<0>(aResult)));
                      } else {
                        jsPromise->MaybeRejectWithUndefined();
                      }
                    },
-                   [jsPromise](ResponseRejectReason aReason) {
+                   [jsPromise](ResponseRejectReason&& aReason) {
                      jsPromise->MaybeRejectWithUndefined();
                    });
 
   return NS_OK;
 }
 
 void TabParent::SuppressDisplayport(bool aEnabled) {
   if (IsDestroyed()) {
@@ -2813,32 +2813,32 @@ void TabParent::RequestRootPaint(gfx::Cr
   auto promise = SendRequestRootPaint(aRect, aScale, aBackgroundColor);
 
   RefPtr<gfx::CrossProcessPaint> paint(aPaint);
   TabId tabId(GetTabId());
   promise->Then(GetMainThreadSerialEventTarget(), __func__,
                 [paint, tabId](PaintFragment&& aFragment) {
                   paint->ReceiveFragment(tabId, std::move(aFragment));
                 },
-                [paint, tabId](ResponseRejectReason aReason) {
+                [paint, tabId](ResponseRejectReason&& aReason) {
                   paint->LostFragment(tabId);
                 });
 }
 
 void TabParent::RequestSubPaint(gfx::CrossProcessPaint* aPaint, float aScale,
                                 nscolor aBackgroundColor) {
   auto promise = SendRequestSubPaint(aScale, aBackgroundColor);
 
   RefPtr<gfx::CrossProcessPaint> paint(aPaint);
   TabId tabId(GetTabId());
   promise->Then(GetMainThreadSerialEventTarget(), __func__,
                 [paint, tabId](PaintFragment&& aFragment) {
                   paint->ReceiveFragment(tabId, std::move(aFragment));
                 },
-                [paint, tabId](ResponseRejectReason aReason) {
+                [paint, tabId](ResponseRejectReason&& aReason) {
                   paint->LostFragment(tabId);
                 });
 }
 
 mozilla::ipc::IPCResult TabParent::RecvPaintWhileInterruptingJSNoOp(
     const LayersObserverEpoch& aEpoch) {
   // We sent a PaintWhileInterruptingJS message when layers were already
   // visible. In this case, we should act as if an update occurred even though
--- a/dom/media/CubebUtils.cpp
+++ b/dom/media/CubebUtils.cpp
@@ -366,22 +366,22 @@ void InitBrandName() {
 
 #ifdef MOZ_CUBEB_REMOTING
 void InitAudioIPCConnection() {
   MOZ_ASSERT(NS_IsMainThread());
   auto contentChild = dom::ContentChild::GetSingleton();
   auto promise = contentChild->SendCreateAudioIPCConnection();
   promise->Then(
       AbstractThread::MainThread(), __func__,
-      [](ipc::FileDescriptor aFD) {
+      [](ipc::FileDescriptor&& aFD) {
         StaticMutexAutoLock lock(sMutex);
         MOZ_ASSERT(!sIPCConnection);
-        sIPCConnection = new ipc::FileDescriptor(aFD);
+        sIPCConnection = new ipc::FileDescriptor(std::move(aFD));
       },
-      [](mozilla::ipc::ResponseRejectReason aReason) {
+      [](mozilla::ipc::ResponseRejectReason&& aReason) {
         MOZ_LOG(gCubebLog, LogLevel::Error,
                 ("SendCreateAudioIPCConnection failed: %d", int(aReason)));
       });
 }
 #endif
 
 ipc::FileDescriptor CreateAudioIPCConnection() {
 #ifdef MOZ_CUBEB_REMOTING
--- a/dom/media/gmp/ChromiumCDMParent.cpp
+++ b/dom/media/gmp/ChromiumCDMParent.cpp
@@ -81,17 +81,17 @@ RefPtr<ChromiumCDMParent::InitPromise> C
                               "from child indicating CDM failed init"),
                   __func__);
               return;
             }
             GMP_LOG(
                 "ChromiumCDMParent::Init() succeeded with callback from child");
             self->mInitPromise.ResolveIfExists(true /* unused */, __func__);
           },
-          [self](ResponseRejectReason aReason) {
+          [self](ResponseRejectReason&& aReason) {
             RefPtr<gmp::GeckoMediaPluginService> service =
                 gmp::GeckoMediaPluginService::GetGeckoMediaPluginService();
             bool xpcomWillShutdown =
                 service && service->XPCOMWillShutdownReceived();
             GMP_LOG(
                 "ChromiumCDMParent::Init(this=%p) failed "
                 "shutdown=%s cdmCrash=%s actorDestroyed=%s "
                 "browserShutdown=%s promiseRejectReason=%d",
--- a/dom/serviceworkers/RemoteServiceWorkerContainerImpl.cpp
+++ b/dom/serviceworkers/RemoteServiceWorkerContainerImpl.cpp
@@ -73,17 +73,17 @@ void RemoteServiceWorkerContainerImpl::R
           MOZ_DIAGNOSTIC_ASSERT(rv.Failed());
           aFailureCB(CopyableErrorResult(rv));
           return;
         }
         // success
         auto& ipcDesc = aResult.get_IPCServiceWorkerRegistrationDescriptor();
         successCB(ServiceWorkerRegistrationDescriptor(ipcDesc));
       },
-      [aFailureCB](ResponseRejectReason aReason) {
+      [aFailureCB](ResponseRejectReason&& aReason) {
         // IPC layer error
         aFailureCB(CopyableErrorResult(NS_ERROR_DOM_INVALID_STATE_ERR));
       });
 }
 
 void RemoteServiceWorkerContainerImpl::GetRegistration(
     const ClientInfo& aClientInfo, const nsACString& aURL,
     ServiceWorkerRegistrationCallback&& aSuccessCB,
@@ -107,17 +107,17 @@ void RemoteServiceWorkerContainerImpl::G
           // find a registration.
           aFailureCB(CopyableErrorResult(rv));
           return;
         }
         // success
         auto& ipcDesc = aResult.get_IPCServiceWorkerRegistrationDescriptor();
         successCB(ServiceWorkerRegistrationDescriptor(ipcDesc));
       },
-      [aFailureCB](ResponseRejectReason aReason) {
+      [aFailureCB](ResponseRejectReason&& aReason) {
         // IPC layer error
         aFailureCB(CopyableErrorResult(NS_ERROR_DOM_INVALID_STATE_ERR));
       });
 }
 
 void RemoteServiceWorkerContainerImpl::GetRegistrations(
     const ClientInfo& aClientInfo,
     ServiceWorkerRegistrationListCallback&& aSuccessCB,
@@ -146,17 +146,17 @@ void RemoteServiceWorkerContainerImpl::G
             aResult.get_IPCServiceWorkerRegistrationDescriptorList();
         nsTArray<ServiceWorkerRegistrationDescriptor> list(
             ipcList.values().Length());
         for (auto& ipcDesc : ipcList.values()) {
           list.AppendElement(ServiceWorkerRegistrationDescriptor(ipcDesc));
         }
         successCB(std::move(list));
       },
-      [aFailureCB](ResponseRejectReason aReason) {
+      [aFailureCB](ResponseRejectReason&& aReason) {
         // IPC layer error
         aFailureCB(CopyableErrorResult(NS_ERROR_DOM_INVALID_STATE_ERR));
       });
 }
 
 void RemoteServiceWorkerContainerImpl::GetReady(
     const ClientInfo& aClientInfo,
     ServiceWorkerRegistrationCallback&& aSuccessCB,
@@ -179,17 +179,17 @@ void RemoteServiceWorkerContainerImpl::G
           MOZ_DIAGNOSTIC_ASSERT(rv.Failed());
           aFailureCB(CopyableErrorResult(rv));
           return;
         }
         // success
         auto& ipcDesc = aResult.get_IPCServiceWorkerRegistrationDescriptor();
         successCB(ServiceWorkerRegistrationDescriptor(ipcDesc));
       },
-      [aFailureCB](ResponseRejectReason aReason) {
+      [aFailureCB](ResponseRejectReason&& aReason) {
         // IPC layer error
         aFailureCB(CopyableErrorResult(NS_ERROR_DOM_INVALID_STATE_ERR));
       });
 }
 
 RemoteServiceWorkerContainerImpl::RemoteServiceWorkerContainerImpl()
     : mActor(nullptr), mOuter(nullptr), mShutdown(false) {
   PBackgroundChild* parentActor =
--- a/dom/serviceworkers/RemoteServiceWorkerRegistrationImpl.cpp
+++ b/dom/serviceworkers/RemoteServiceWorkerRegistrationImpl.cpp
@@ -68,17 +68,17 @@ void RemoteServiceWorkerRegistrationImpl
           MOZ_DIAGNOSTIC_ASSERT(rv.Failed());
           aFailureCB(CopyableErrorResult(rv));
           return;
         }
         // success
         auto& ipcDesc = aResult.get_IPCServiceWorkerRegistrationDescriptor();
         successCB(ServiceWorkerRegistrationDescriptor(ipcDesc));
       },
-      [aFailureCB](ResponseRejectReason aReason) {
+      [aFailureCB](ResponseRejectReason&& aReason) {
         // IPC layer error
         aFailureCB(CopyableErrorResult(NS_ERROR_DOM_INVALID_STATE_ERR));
       });
 }
 
 void RemoteServiceWorkerRegistrationImpl::Unregister(
     ServiceWorkerBoolCallback&& aSuccessCB,
     ServiceWorkerFailureCallback&& aFailureCB) {
@@ -93,17 +93,17 @@ void RemoteServiceWorkerRegistrationImpl
         if (Get<1>(aResult).Failed()) {
           // application layer error
           aFailureCB(Get<1>(aResult));
           return;
         }
         // success
         successCB(Get<0>(aResult));
       },
-      [aFailureCB](ResponseRejectReason aReason) {
+      [aFailureCB](ResponseRejectReason&& aReason) {
         // IPC layer error
         aFailureCB(CopyableErrorResult(NS_ERROR_DOM_INVALID_STATE_ERR));
       });
 }
 
 RemoteServiceWorkerRegistrationImpl::RemoteServiceWorkerRegistrationImpl(
     const ServiceWorkerRegistrationDescriptor& aDescriptor)
     : mActor(nullptr), mOuter(nullptr), mShutdown(false) {
--- a/extensions/spellcheck/hunspell/glue/RemoteSpellCheckEngineChild.cpp
+++ b/extensions/spellcheck/hunspell/glue/RemoteSpellCheckEngineChild.cpp
@@ -22,27 +22,27 @@ RemoteSpellcheckEngineChild::SetCurrentD
     const nsTArray<nsString>& aList) {
   MozPromiseHolder<GenericPromise>* promiseHolder =
       new MozPromiseHolder<GenericPromise>();
   RefPtr<GenericPromise> promise = promiseHolder->Ensure(__func__);
   RefPtr<mozSpellChecker> spellChecker = mOwner;
 
   SendSetDictionaryFromList(aList)->Then(
       GetMainThreadSerialEventTarget(), __func__,
-      [spellChecker, promiseHolder](const Tuple<bool, nsString>& aParam) {
+      [spellChecker, promiseHolder](Tuple<bool, nsString>&& aParam) {
         UniquePtr<MozPromiseHolder<GenericPromise>> holder(promiseHolder);
         if (!Get<0>(aParam)) {
           spellChecker->mCurrentDictionary.Truncate();
           holder->Reject(NS_ERROR_NOT_AVAILABLE, __func__);
           return;
         }
-        spellChecker->mCurrentDictionary = Get<1>(aParam);
+        spellChecker->mCurrentDictionary = std::move(Get<1>(aParam));
         holder->Resolve(true, __func__);
       },
-      [spellChecker, promiseHolder](ResponseRejectReason aReason) {
+      [spellChecker, promiseHolder](ResponseRejectReason&& aReason) {
         UniquePtr<MozPromiseHolder<GenericPromise>> holder(promiseHolder);
         spellChecker->mCurrentDictionary.Truncate();
         holder->Reject(NS_ERROR_NOT_AVAILABLE, __func__);
       });
   return promise;
 }
 
 }  // namespace mozilla
--- a/gfx/thebes/gfxPlatform.cpp
+++ b/gfx/thebes/gfxPlatform.cpp
@@ -711,17 +711,17 @@ WebRenderMemoryReporter::CollectReports(
         helper.ReportTexture(aReport.vertex_data_textures, "vertex-data");
         helper.ReportTexture(aReport.render_target_textures, "render-targets");
         helper.ReportTexture(aReport.texture_cache_textures, "texture-cache");
         helper.ReportTexture(aReport.depth_target_textures, "depth-targets");
         helper.ReportTexture(aReport.swap_chain, "swap-chains");
 
         FinishAsyncMemoryReport();
       },
-      [](mozilla::ipc::ResponseRejectReason aReason) {
+      [](mozilla::ipc::ResponseRejectReason&& aReason) {
         FinishAsyncMemoryReport();
       });
 
   return NS_OK;
 }
 
 static const char* const WR_ROLLOUT_PREF = "gfx.webrender.all.qualified";
 static const char* const WR_ROLLOUT_PREF_DEFAULT =
--- a/image/imgLoader.cpp
+++ b/image/imgLoader.cpp
@@ -92,17 +92,17 @@ class imgMemoryReporter final : public n
 
     RefPtr<imgMemoryReporter> self(this);
     nsCOMPtr<nsIHandleReportCallback> handleReport(aHandleReport);
     nsCOMPtr<nsISupports> data(aData);
     manager->SendReportSharedSurfacesMemory(
         [=](layers::SharedSurfacesMemoryReport aReport) {
           self->FinishCollectReports(handleReport, data, aAnonymize, aReport);
         },
-        [=](mozilla::ipc::ResponseRejectReason aReason) {
+        [=](mozilla::ipc::ResponseRejectReason&& aReason) {
           layers::SharedSurfacesMemoryReport sharedSurfaces;
           self->FinishCollectReports(handleReport, data, aAnonymize,
                                      sharedSurfaces);
         });
     return NS_OK;
   }
 
   void FinishCollectReports(
--- a/ipc/glue/MessageChannel.h
+++ b/ipc/glue/MessageChannel.h
@@ -106,17 +106,17 @@ class MessageChannel : HasResultCodes, M
 
  public:
   struct UntypedCallbackHolder {
     UntypedCallbackHolder(ActorIdType aActorId, RejectCallback&& aReject)
         : mActorId(aActorId), mReject(std::move(aReject)) {}
 
     virtual ~UntypedCallbackHolder() {}
 
-    void Reject(ResponseRejectReason aReason) { mReject(aReason); }
+    void Reject(ResponseRejectReason&& aReason) { mReject(std::move(aReason)); }
 
     ActorIdType mActorId;
     RejectCallback mReject;
   };
 
   template <typename Value>
   struct CallbackHolder : public UntypedCallbackHolder {
     CallbackHolder(ActorIdType aActorId, ResolveCallback<Value>&& aResolve,
--- a/ipc/ipdl/ipdl/lower.py
+++ b/ipc/ipdl/ipdl/lower.py
@@ -276,21 +276,20 @@ def _promise(resolvetype, rejecttype, ta
 
 
 def _makePromise(returns, side, resolver=False):
     if len(returns) > 1:
         resolvetype = _tuple([d.bareType(side) for d in returns])
     else:
         resolvetype = returns[0].bareType(side)
 
-    needmove = not all(d.isCopyable() for d in returns)
-
+    # MozPromise is purposefully made to be exclusive only. Really, we mean it.
     return _promise(resolvetype,
                     _ResponseRejectReason.Type(),
-                    ExprLiteral.TRUE if needmove else ExprLiteral.FALSE,
+                    ExprLiteral.TRUE,
                     resolver=resolver)
 
 
 def _makeResolver(returns, side):
     if len(returns) > 1:
         resolvetype = _tuple([d.moveType(side) for d in returns])
     else:
         resolvetype = returns[0].moveType(side)
@@ -4124,17 +4123,17 @@ class _GenerateProtocolActorCode(ipdl.as
                                                                   '.', 'get')),
                                               callbackptr,
                                               static=1)),
                        ifnocallback]
 
         resolvecallback = [StmtExpr(ExprCall(ExprSelect(callback, '->', 'Resolve'),
                                              args=[resolvearg]))]
         rejectcallback = [StmtExpr(ExprCall(ExprSelect(callback, '->', 'Reject'),
-                                            args=[reason]))]
+                                            args=[ExprMove(reason)]))]
         ifresolve = StmtIf(resolve)
         ifresolve.addifstmts(desstmts)
         ifresolve.addifstmts(resolvecallback)
         ifresolve.addelsestmts(desrej)
         ifresolve.addelsestmts(rejectcallback)
         case.addstmts(prologue)
         case.addstmts(getcallback)
         case.addstmt(ifresolve)
@@ -4684,21 +4683,23 @@ class _GenerateProtocolActorCode(ipdl.as
         resolvefn = ExprLambda([retpromise],
                                [Decl(resolvetype, "aValue")])
         resolvefn.addstmts([
             StmtExpr(ExprCall(ExprSelect(retpromise, '->', 'Resolve'),
                               args=[ExprMove(ExprVar('aValue')),
                                     ExprVar('__func__')])),
         ])
 
+        rejecttype = _ResponseRejectReason.Type()
+        rejecttype.ref = 2
         rejectfn = ExprLambda([retpromise],
-                              [Decl(_ResponseRejectReason.Type(), "aReason")])
+                              [Decl(rejecttype, "aReason")])
         rejectfn.addstmts([
             StmtExpr(ExprCall(ExprSelect(retpromise, '->', 'Reject'),
-                              args=[ExprVar('aReason'),
+                              args=[ExprMove(ExprVar('aReason')),
                                     ExprVar('__func__')])),
         ])
 
         args = [p.var() for p in md.params] + [resolvefn, rejectfn]
         stmts += [Whitespace.NL,
                   StmtExpr(ExprCall(ExprVar(md.sendMethod().name), args=args)),
                   StmtReturn(retpromise)]
         return stmts
--- a/ipc/ipdl/test/cxx/TestAsyncReturns.cpp
+++ b/ipc/ipdl/test/cxx/TestAsyncReturns.cpp
@@ -26,17 +26,17 @@ TestAsyncReturnsParent::~TestAsyncReturn
 
 void
 TestAsyncReturnsParent::Main()
 {
   SendNoReturn()->Then(MessageLoop::current()->SerialEventTarget(), __func__,
                        [](bool unused) {
                          fail("resolve handler should not be called");
                        },
-                       [](ResponseRejectReason aReason) {
+                       [](ResponseRejectReason&& aReason) {
                          // MozPromise asserts in debug build if the
                          // handler is not called
                          if (aReason != ResponseRejectReason::ChannelClosed) {
                            fail("reject with wrong reason");
                          }
                          passed("reject handler called on channel close");
                        });
   SendPing()->Then(MessageLoop::current()->SerialEventTarget(), __func__,
@@ -52,21 +52,21 @@ TestAsyncReturnsParent::Main()
                        [this](bool one) {
                          if (one) {
                            passed("take one argument");
                          } else {
                            fail("get one argument but has wrong value");
                          }
                          Close();
                        },
-                       [](ResponseRejectReason aReason) {
+                       [](ResponseRejectReason&& aReason) {
                          fail("sending Ping");
                        });
                    },
-                   [](ResponseRejectReason aReason) {
+                   [](ResponseRejectReason&& aReason) {
                      fail("sending Ping");
                    });
 }
 
 
 mozilla::ipc::IPCResult
 TestAsyncReturnsParent::RecvPong(PongResolver&& aResolve)
 {
@@ -102,17 +102,17 @@ TestAsyncReturnsChild::RecvPing(PingReso
                    [aResolve](const Tuple<uint32_t, uint32_t>& aParam) {
                      if (Get<0>(aParam) == sMagic1 && Get<1>(aParam) == sMagic2) {
                        passed("take two arguments");
                      } else {
                        fail("get two argument but has wrong value");
                      }
                      aResolve(true);
                    },
-                   [](ResponseRejectReason aReason) {
+                   [](ResponseRejectReason&& aReason) {
                      fail("sending Pong");
                    });
   return IPC_OK();
 }
 
 
 } // namespace _ipdltest
 } // namespace mozilla
--- a/toolkit/components/extensions/webrequest/StreamFilter.cpp
+++ b/toolkit/components/extensions/webrequest/StreamFilter.cpp
@@ -76,17 +76,17 @@ void StreamFilter::Connect() {
   if (cc) {
     RefPtr<StreamFilter> self(this);
 
     cc->SendInitStreamFilter(mChannelId, addonId)
         ->Then(GetCurrentThreadSerialEventTarget(), __func__,
                [=](mozilla::ipc::Endpoint<PStreamFilterChild>&& aEndpoint) {
                  self->FinishConnect(std::move(aEndpoint));
                },
-               [=](mozilla::ipc::ResponseRejectReason aReason) {
+               [=](mozilla::ipc::ResponseRejectReason&& aReason) {
                  self->mActor->RecvInitialized(false);
                });
   } else {
     mozilla::ipc::Endpoint<PStreamFilterChild> endpoint;
     Unused << StreamFilterParent::Create(nullptr, mChannelId, addonId,
                                          &endpoint);
 
     // Always dispatch asynchronously so JS callers have a chance to attach
--- a/tools/code-coverage/nsCodeCoverage.cpp
+++ b/tools/code-coverage/nsCodeCoverage.cpp
@@ -68,17 +68,17 @@ nsresult Request(JSContext* cx, Promise*
     RefPtr<ProcessCount> processCountHolder(new ProcessCount(processCount));
 
     auto resolve = [processCountHolder, promise](bool unused) {
       if (--(*processCountHolder) == 0) {
         promise->MaybeResolveWithUndefined();
       }
     };
 
-    auto reject = [promise](ResponseRejectReason aReason) {
+    auto reject = [promise](ResponseRejectReason&& aReason) {
       promise->MaybeReject(NS_ERROR_FAILURE);
     };
 
     for (auto* cp : ContentParent::AllProcesses(ContentParent::eLive)) {
       if (requestType == RequestType::Flush) {
         cp->SendFlushCodeCoverageCounters(resolve, reject);
       }
     }
--- a/tools/profiler/gecko/nsProfiler.cpp
+++ b/tools/profiler/gecko/nsProfiler.cpp
@@ -629,22 +629,22 @@ RefPtr<nsProfiler::GatheringPromise> nsP
   // until FinishGathering() is called. As profiles from the other processes
   // come in, they will be inserted and end up in the right spot.
   // FinishGathering() will close the array and the root object.
 
   mPendingProfiles = profiles.Length();
   RefPtr<nsProfiler> self = this;
   for (auto profile : profiles) {
     profile->Then(GetMainThreadSerialEventTarget(), __func__,
-                  [self](const mozilla::ipc::Shmem& aResult) {
+                  [self](mozilla::ipc::Shmem&& aResult) {
                     const nsDependentCSubstring profileString(
                         aResult.get<char>(), aResult.Size<char>() - 1);
                     self->GatheredOOPProfile(profileString);
                   },
-                  [self](ipc::ResponseRejectReason aReason) {
+                  [self](ipc::ResponseRejectReason&& aReason) {
                     self->GatheredOOPProfile(NS_LITERAL_CSTRING(""));
                   });
   }
   if (!mPendingProfiles) {
     FinishGathering();
   }
 
   return promise;
--- a/widget/PuppetWidget.cpp
+++ b/widget/PuppetWidget.cpp
@@ -767,20 +767,20 @@ nsresult PuppetWidget::NotifyIMEOfFocusC
     mContentCache.Clear();
   }
 
   mIMENotificationRequestsOfParent =
       IMENotificationRequests(IMENotificationRequests::NOTIFY_ALL);
   RefPtr<PuppetWidget> self = this;
   mTabChild->SendNotifyIMEFocus(mContentCache, aIMENotification)
       ->Then(mTabChild->TabGroup()->EventTargetFor(TaskCategory::UI), __func__,
-             [self](IMENotificationRequests aRequests) {
+             [self](IMENotificationRequests&& aRequests) {
                self->mIMENotificationRequestsOfParent = aRequests;
              },
-             [self](mozilla::ipc::ResponseRejectReason aReason) {
+             [self](mozilla::ipc::ResponseRejectReason&& aReason) {
                NS_WARNING("SendNotifyIMEFocus got rejected.");
              });
 
   return NS_OK;
 }
 
 nsresult PuppetWidget::NotifyIMEOfCompositionUpdate(
     const IMENotification& aIMENotification) {