Bug 1588241 - P7. Use NeckoTargetChannelFunctionEvent in DCC. r=mattwoodrow
authorJean-Yves Avenard <jyavenard@mozilla.com>
Fri, 15 Nov 2019 02:42:18 +0000
changeset 502108 693144fd8c54c51f442ca4741aa484d1f3795747
parent 502107 c70d60f8293ca2996cde6384af2a0f9bc5311e9c
child 502109 0ba862a839d190ce4c443e4db2f5788aeeea97ad
push id114172
push userdluca@mozilla.com
push dateTue, 19 Nov 2019 11:31:10 +0000
treeherdermozilla-inbound@b5c5ba07d3db [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmattwoodrow
bugs1588241
milestone72.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 1588241 - P7. Use NeckoTargetChannelFunctionEvent in DCC. r=mattwoodrow Differential Revision: https://phabricator.services.mozilla.com/D52503
netwerk/ipc/DocumentChannelChild.cpp
netwerk/ipc/DocumentChannelChild.h
--- a/netwerk/ipc/DocumentChannelChild.cpp
+++ b/netwerk/ipc/DocumentChannelChild.cpp
@@ -185,41 +185,25 @@ DocumentChannelChild::AsyncOpen(nsIStrea
 
   mIsPending = true;
   mWasOpened = true;
   mListener = listener;
 
   return NS_OK;
 }
 
-class DocumentFailedAsyncOpenEvent
-    : public NeckoTargetChannelEvent<DocumentChannelChild> {
- public:
-  DocumentFailedAsyncOpenEvent(DocumentChannelChild* aChild,
-                               nsresult aStatusCode)
-      : NeckoTargetChannelEvent<DocumentChannelChild>(aChild),
-        mStatus(aStatusCode) {}
-
-  void Run() override { mChild->DoFailedAsyncOpen(mStatus); }
-
- private:
-  nsresult mStatus;
-};
-
 IPCResult DocumentChannelChild::RecvFailedAsyncOpen(
     const nsresult& aStatusCode) {
-  mEventQueue->RunOrEnqueue(
-      new DocumentFailedAsyncOpenEvent(this, aStatusCode));
+  mEventQueue->RunOrEnqueue(new NeckoTargetChannelFunctionEvent(
+      this, [self = UnsafePtr<DocumentChannelChild>(this), aStatusCode]() {
+        self->ShutdownListeners(aStatusCode);
+      }));
   return IPC_OK();
 }
 
-void DocumentChannelChild::DoFailedAsyncOpen(const nsresult& aStatusCode) {
-  ShutdownListeners(aStatusCode);
-}
-
 void DocumentChannelChild::ShutdownListeners(nsresult aStatusCode) {
   mStatus = aStatusCode;
 
   nsCOMPtr<nsIStreamListener> l = mListener;
   if (l) {
     l->OnStartRequest(this);
   }
 
--- a/netwerk/ipc/DocumentChannelChild.h
+++ b/netwerk/ipc/DocumentChannelChild.h
@@ -71,25 +71,22 @@ class DocumentChannelChild final : publi
 
   mozilla::ipc::IPCResult RecvAttachStreamFilter(
       Endpoint<extensions::PStreamFilterParent>&& aEndpoint);
 
   mozilla::ipc::IPCResult RecvConfirmRedirect(
       const LoadInfoArgs& aLoadInfo, nsIURI* aNewUri,
       ConfirmRedirectResolver&& aResolve);
 
-  void DoFailedAsyncOpen(const nsresult& aStatusCode);
-
   const nsTArray<DocumentChannelRedirect>& GetRedirectChain() const {
     return mRedirects;
   }
 
-  friend class NeckoTargetChannelEvent<DocumentChannelChild>;
-
  private:
+  friend class NeckoTargetChannelFunctionEvent;
   void ShutdownListeners(nsresult aStatusCode);
 
   ~DocumentChannelChild() = default;
 
   RefPtr<ChannelEventQueue> mEventQueue;
   nsCOMPtr<nsIChannel> mRedirectChannel;
   nsTArray<DocumentChannelRedirect> mRedirects;