Bug 1588241 - P7. Use NeckoTargetChannelFunctionEvent in DCC. r=mattwoodrow
☠☠ backed out by 2f19e7b646e0 ☠ ☠
authorJean-Yves Avenard <jyavenard@mozilla.com>
Tue, 12 Nov 2019 01:16:14 +0000
changeset 501697 125430c4316a188db6ce5b50da3ffdd99c4fc5aa
parent 501696 449606f22baf89dbd2ddd4fc537219c13907bd11
child 501698 6a4727c44078f7eca99f39b72a6f8eab2752c3f0
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,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;