Bug 1588241 - P7. Use NeckoTargetChannelFunctionEvent in DCC. r?mattwoodrow draft
authorJean-Yves Avenard <jyavenard@mozilla.com>
Mon, 11 Nov 2019 16:16:20 +1100
changeset 2424706 24b168e4f9db2485af1a80728b18c100c82fa618
parent 2424705 f9004e10caf80a59be240fbdcf1d9064cb12f380
child 2424707 2ede61af7e6241081010d48232a256d471784ae6
push id447522
push userjyavenard@mozilla.com
push dateMon, 11 Nov 2019 06:10:20 +0000
treeherdertry@140e4f281066 [default view] [failures only]
reviewersmattwoodrow
bugs1588241
milestone72.0a1
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,24 @@ 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));
+  RefPtr<DocumentChannelChild> self = this;
+  mEventQueue->RunOrEnqueue(new NeckoTargetChannelFunctionEvent(
+      this, [self, 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;