Bug 1588241 - P8. Use NeckoTargetChannelFunctionEvent with FTPChannelChild. r?mattwoodrow draft
authorJean-Yves Avenard <jyavenard@mozilla.com>
Mon, 11 Nov 2019 16:51:50 +1100
changeset 2424707 2ede61af7e6241081010d48232a256d471784ae6
parent 2424706 24b168e4f9db2485af1a80728b18c100c82fa618
child 2424708 140e4f281066a7d1acaffcbaa6c897863d73d96b
child 2425283 4e37a07c66402caea9c0c41acc7adf449ec169e9
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 - P8. Use NeckoTargetChannelFunctionEvent with FTPChannelChild. r?mattwoodrow Fix style consistency while at it and a couple of constness issues. Differential Revision: https://phabricator.services.mozilla.com/D52505
netwerk/protocol/ftp/FTPChannelChild.cpp
netwerk/protocol/ftp/FTPChannelChild.h
--- a/netwerk/protocol/ftp/FTPChannelChild.cpp
+++ b/netwerk/protocol/ftp/FTPChannelChild.cpp
@@ -28,32 +28,32 @@ using mozilla::dom::ContentChild;
 using namespace mozilla::ipc;
 
 #undef LOG
 #define LOG(args) MOZ_LOG(gFTPLog, mozilla::LogLevel::Debug, args)
 
 namespace mozilla {
 namespace net {
 
-FTPChannelChild::FTPChannelChild(nsIURI* uri)
+FTPChannelChild::FTPChannelChild(nsIURI* aUri)
     : mIPCOpen(false),
+      mEventQ(new ChannelEventQueue(static_cast<nsIFTPChannel*>(this))),
       mUnknownDecoderInvolved(false),
       mCanceled(false),
       mSuspendCount(0),
       mIsPending(false),
       mLastModifiedTime(0),
       mStartPos(0),
       mDivertingToParent(false),
       mFlushedForDiversion(false),
       mSuspendSent(false) {
   LOG(("Creating FTPChannelChild @%p\n", this));
   // grab a reference to the handler to ensure that it doesn't go away.
   NS_ADDREF(gFtpHandler);
-  SetURI(uri);
-  mEventQ = new ChannelEventQueue(static_cast<nsIFTPChannel*>(this));
+  SetURI(aUri);
 
   // We could support thread retargeting, but as long as we're being driven by
   // IPDL on the main thread it doesn't buy us anything.
   DisallowThreadRetargeting();
 }
 
 FTPChannelChild::~FTPChannelChild() {
   LOG(("Destroying FTPChannelChild @%p\n", this));
@@ -79,58 +79,58 @@ void FTPChannelChild::ReleaseIPDLReferen
 NS_IMPL_ISUPPORTS_INHERITED(FTPChannelChild, nsBaseChannel, nsIFTPChannel,
                             nsIUploadChannel, nsIResumableChannel,
                             nsIProxiedChannel, nsIChildChannel,
                             nsIDivertableChannel)
 
 //-----------------------------------------------------------------------------
 
 NS_IMETHODIMP
-FTPChannelChild::GetLastModifiedTime(PRTime* lastModifiedTime) {
-  *lastModifiedTime = mLastModifiedTime;
+FTPChannelChild::GetLastModifiedTime(PRTime* aLastModifiedTime) {
+  *aLastModifiedTime = mLastModifiedTime;
   return NS_OK;
 }
 
 NS_IMETHODIMP
-FTPChannelChild::SetLastModifiedTime(PRTime lastModifiedTime) {
+FTPChannelChild::SetLastModifiedTime(PRTime aLastModifiedTime) {
   return NS_ERROR_NOT_AVAILABLE;
 }
 
 NS_IMETHODIMP
 FTPChannelChild::ResumeAt(uint64_t aStartPos, const nsACString& aEntityID) {
   NS_ENSURE_TRUE(!mIsPending, NS_ERROR_IN_PROGRESS);
   mStartPos = aStartPos;
   mEntityID = aEntityID;
   return NS_OK;
 }
 
 NS_IMETHODIMP
-FTPChannelChild::GetEntityID(nsACString& entityID) {
-  entityID = mEntityID;
+FTPChannelChild::GetEntityID(nsACString& aEntityID) {
+  aEntityID = mEntityID;
   return NS_OK;
 }
 
 NS_IMETHODIMP
 FTPChannelChild::GetProxyInfo(nsIProxyInfo** aProxyInfo) { DROP_DEAD(); }
 
 NS_IMETHODIMP
-FTPChannelChild::SetUploadStream(nsIInputStream* stream,
-                                 const nsACString& contentType,
-                                 int64_t contentLength) {
+FTPChannelChild::SetUploadStream(nsIInputStream* aStream,
+                                 const nsACString& aContentType,
+                                 int64_t aContentLength) {
   NS_ENSURE_TRUE(!mIsPending, NS_ERROR_IN_PROGRESS);
-  mUploadStream = stream;
+  mUploadStream = aStream;
   // NOTE: contentLength is intentionally ignored here.
   return NS_OK;
 }
 
 NS_IMETHODIMP
-FTPChannelChild::GetUploadStream(nsIInputStream** stream) {
-  NS_ENSURE_ARG_POINTER(stream);
-  *stream = mUploadStream;
-  NS_IF_ADDREF(*stream);
+FTPChannelChild::GetUploadStream(nsIInputStream** aStream) {
+  NS_ENSURE_ARG_POINTER(aStream);
+  *aStream = mUploadStream;
+  NS_IF_ADDREF(*aStream);
   return NS_OK;
 }
 
 NS_IMETHODIMP
 FTPChannelChild::AsyncOpen(nsIStreamListener* aListener) {
   nsCOMPtr<nsIStreamListener> listener = aListener;
   nsresult rv =
       nsContentSecurityManager::doContentSecurityCheck(this, listener);
@@ -202,78 +202,52 @@ FTPChannelChild::AsyncOpen(nsIStreamList
 
   mIsPending = true;
   mWasOpened = true;
 
   return rv;
 }
 
 NS_IMETHODIMP
-FTPChannelChild::IsPending(bool* result) {
-  *result = mIsPending;
+FTPChannelChild::IsPending(bool* aResult) {
+  *aResult = mIsPending;
   return NS_OK;
 }
 
-nsresult FTPChannelChild::OpenContentStream(bool async, nsIInputStream** stream,
-                                            nsIChannel** channel) {
+nsresult FTPChannelChild::OpenContentStream(bool aAsync,
+                                            nsIInputStream** aStream,
+                                            nsIChannel** aChannel) {
   MOZ_CRASH("FTPChannel*Child* should never have OpenContentStream called!");
   return NS_OK;
 }
 
 //-----------------------------------------------------------------------------
 // FTPChannelChild::PFTPChannelChild
 //-----------------------------------------------------------------------------
 
-class FTPStartRequestEvent : public NeckoTargetChannelEvent<FTPChannelChild> {
- public:
-  FTPStartRequestEvent(FTPChannelChild* aChild, const nsresult& aChannelStatus,
-                       const int64_t& aContentLength,
-                       const nsCString& aContentType,
-                       const PRTime& aLastModified, const nsCString& aEntityID,
-                       const URIParams& aURI)
-      : NeckoTargetChannelEvent<FTPChannelChild>(aChild),
-        mChannelStatus(aChannelStatus),
-        mContentLength(aContentLength),
-        mContentType(aContentType),
-        mLastModified(aLastModified),
-        mEntityID(aEntityID),
-        mURI(aURI) {}
-
-  void Run() override {
-    mChild->DoOnStartRequest(mChannelStatus, mContentLength, mContentType,
-                             mLastModified, mEntityID, mURI);
-  }
-
- private:
-  nsresult mChannelStatus;
-  int64_t mContentLength;
-  nsCString mContentType;
-  PRTime mLastModified;
-  nsCString mEntityID;
-  URIParams mURI;
-};
-
 mozilla::ipc::IPCResult FTPChannelChild::RecvOnStartRequest(
     const nsresult& aChannelStatus, const int64_t& aContentLength,
     const nsCString& aContentType, const PRTime& aLastModified,
     const nsCString& aEntityID, const URIParams& aURI) {
   // mFlushedForDiversion and mDivertingToParent should NEVER be set at this
   // stage, as they are set in the listener's OnStartRequest.
   MOZ_RELEASE_ASSERT(
       !mFlushedForDiversion,
       "mFlushedForDiversion should be unset before OnStartRequest!");
   MOZ_RELEASE_ASSERT(
       !mDivertingToParent,
       "mDivertingToParent should be unset before OnStartRequest!");
 
   LOG(("FTPChannelChild::RecvOnStartRequest [this=%p]\n", this));
 
-  mEventQ->RunOrEnqueue(
-      new FTPStartRequestEvent(this, aChannelStatus, aContentLength,
-                               aContentType, aLastModified, aEntityID, aURI));
+  RefPtr<FTPChannelChild> self = this;
+  mEventQ->RunOrEnqueue(new NeckoTargetChannelFunctionEvent(this, [=]() {
+    self->DoOnStartRequest(aChannelStatus, aContentLength, aContentType,
+                           aLastModified, aEntityID, aURI);
+  }));
   return IPC_OK();
 }
 
 void FTPChannelChild::DoOnStartRequest(const nsresult& aChannelStatus,
                                        const int64_t& aContentLength,
                                        const nsCString& aContentType,
                                        const PRTime& aLastModified,
                                        const nsCString& aEntityID,
@@ -323,178 +297,107 @@ void FTPChannelChild::DoOnStartRequest(c
   if (mDivertingToParent) {
     mListener = nullptr;
     if (mLoadGroup) {
       mLoadGroup->RemoveRequest(this, nullptr, mStatus);
     }
   }
 }
 
-class FTPDataAvailableEvent : public NeckoTargetChannelEvent<FTPChannelChild> {
- public:
-  FTPDataAvailableEvent(FTPChannelChild* aChild, const nsresult& aChannelStatus,
-                        const nsCString& aData, const uint64_t& aOffset,
-                        const uint32_t& aCount)
-      : NeckoTargetChannelEvent<FTPChannelChild>(aChild),
-        mChannelStatus(aChannelStatus),
-        mData(aData),
-        mOffset(aOffset),
-        mCount(aCount) {}
-
-  void Run() override {
-    mChild->DoOnDataAvailable(mChannelStatus, mData, mOffset, mCount);
-  }
-
- private:
-  nsresult mChannelStatus;
-  nsCString mData;
-  uint64_t mOffset;
-  uint32_t mCount;
-};
-
 mozilla::ipc::IPCResult FTPChannelChild::RecvOnDataAvailable(
-    const nsresult& channelStatus, const nsCString& data,
-    const uint64_t& offset, const uint32_t& count) {
+    const nsresult& aChannelStatus, const nsCString& aData,
+    const uint64_t& aOffset, const uint32_t& aCount) {
   MOZ_RELEASE_ASSERT(!mFlushedForDiversion,
                      "Should not be receiving any more callbacks from parent!");
 
   LOG(("FTPChannelChild::RecvOnDataAvailable [this=%p]\n", this));
 
-  mEventQ->RunOrEnqueue(
-      new FTPDataAvailableEvent(this, channelStatus, data, offset, count),
-      mDivertingToParent);
+  RefPtr<FTPChannelChild> self = this;
+  mEventQ->RunOrEnqueue(new NeckoTargetChannelFunctionEvent(
+                            this,
+                            [=]() {
+                              self->DoOnDataAvailable(aChannelStatus, aData,
+                                                      aOffset, aCount);
+                            }),
+                        mDivertingToParent);
 
   return IPC_OK();
 }
 
-class MaybeDivertOnDataFTPEvent
-    : public NeckoTargetChannelEvent<FTPChannelChild> {
- public:
-  MaybeDivertOnDataFTPEvent(FTPChannelChild* child, const nsCString& data,
-                            const uint64_t& offset, const uint32_t& count)
-      : NeckoTargetChannelEvent<FTPChannelChild>(child),
-        mData(data),
-        mOffset(offset),
-        mCount(count) {}
-
-  void Run() override { mChild->MaybeDivertOnData(mData, mOffset, mCount); }
-
- private:
-  nsCString mData;
-  uint64_t mOffset;
-  uint32_t mCount;
-};
-
-void FTPChannelChild::MaybeDivertOnData(const nsCString& data,
-                                        const uint64_t& offset,
-                                        const uint32_t& count) {
-  if (mDivertingToParent) {
-    SendDivertOnDataAvailable(data, offset, count);
-  }
-}
-
-void FTPChannelChild::DoOnDataAvailable(const nsresult& channelStatus,
-                                        const nsCString& data,
-                                        const uint64_t& offset,
-                                        const uint32_t& count) {
+void FTPChannelChild::DoOnDataAvailable(const nsresult& aChannelStatus,
+                                        const nsCString& aData,
+                                        const uint64_t& aOffset,
+                                        const uint32_t& aCount) {
   LOG(("FTPChannelChild::DoOnDataAvailable [this=%p]\n", this));
 
   if (!mCanceled && NS_SUCCEEDED(mStatus)) {
-    mStatus = channelStatus;
+    mStatus = aChannelStatus;
   }
 
   if (mDivertingToParent) {
     MOZ_RELEASE_ASSERT(
         !mFlushedForDiversion,
         "Should not be processing any more callbacks from parent!");
 
-    SendDivertOnDataAvailable(data, offset, count);
+    SendDivertOnDataAvailable(aData, aOffset, aCount);
+    return;
+  }
+
+  if (mCanceled) {
     return;
   }
 
-  if (mCanceled) return;
-
   if (mUnknownDecoderInvolved) {
+    RefPtr<FTPChannelChild> self = this;
     mUnknownDecoderEventQ.AppendElement(
-        MakeUnique<MaybeDivertOnDataFTPEvent>(this, data, offset, count));
+        MakeUnique<NeckoTargetChannelFunctionEvent>(this, [=]() {
+          if (self->mDivertingToParent) {
+            self->SendDivertOnDataAvailable(aData, aOffset, aCount);
+          }
+        }));
   }
 
   // NOTE: the OnDataAvailable contract requires the client to read all the data
   // in the inputstream.  This code relies on that ('data' will go away after
   // this function).  Apparently the previous, non-e10s behavior was to actually
   // support only reading part of the data, allowing later calls to read the
   // rest.
   nsCOMPtr<nsIInputStream> stringStream;
   nsresult rv =
       NS_NewByteInputStream(getter_AddRefs(stringStream),
-                            MakeSpan(data).To(count), NS_ASSIGNMENT_DEPEND);
+                            MakeSpan(aData).To(aCount), NS_ASSIGNMENT_DEPEND);
   if (NS_FAILED(rv)) {
     Cancel(rv);
     return;
   }
 
   AutoEventEnqueuer ensureSerialDispatch(mEventQ);
-  rv = mListener->OnDataAvailable(this, stringStream, offset, count);
-  if (NS_FAILED(rv)) Cancel(rv);
+  rv = mListener->OnDataAvailable(this, stringStream, aOffset, aCount);
+  if (NS_FAILED(rv)) {
+    Cancel(rv);
+  }
   stringStream->Close();
 }
 
-class FTPStopRequestEvent : public NeckoTargetChannelEvent<FTPChannelChild> {
- public:
-  FTPStopRequestEvent(FTPChannelChild* aChild, const nsresult& aChannelStatus,
-                      const nsCString& aErrorMsg, bool aUseUTF8)
-      : NeckoTargetChannelEvent<FTPChannelChild>(aChild),
-        mChannelStatus(aChannelStatus),
-        mErrorMsg(aErrorMsg),
-        mUseUTF8(aUseUTF8) {}
-
-  void Run() override {
-    mChild->DoOnStopRequest(mChannelStatus, mErrorMsg, mUseUTF8);
-  }
-
- private:
-  nsresult mChannelStatus;
-  nsCString mErrorMsg;
-  bool mUseUTF8;
-};
-
 mozilla::ipc::IPCResult FTPChannelChild::RecvOnStopRequest(
     const nsresult& aChannelStatus, const nsCString& aErrorMsg,
     const bool& aUseUTF8) {
   MOZ_RELEASE_ASSERT(!mFlushedForDiversion,
                      "Should not be receiving any more callbacks from parent!");
 
   LOG(("FTPChannelChild::RecvOnStopRequest [this=%p status=%" PRIx32 "]\n",
        this, static_cast<uint32_t>(aChannelStatus)));
 
-  mEventQ->RunOrEnqueue(
-      new FTPStopRequestEvent(this, aChannelStatus, aErrorMsg, aUseUTF8));
+  RefPtr<FTPChannelChild> self = this;
+  mEventQ->RunOrEnqueue(new NeckoTargetChannelFunctionEvent(this, [=]() {
+    self->DoOnStopRequest(aChannelStatus, aErrorMsg, aUseUTF8);
+  }));
   return IPC_OK();
 }
 
-class MaybeDivertOnStopFTPEvent
-    : public NeckoTargetChannelEvent<FTPChannelChild> {
- public:
-  MaybeDivertOnStopFTPEvent(FTPChannelChild* child,
-                            const nsresult& aChannelStatus)
-      : NeckoTargetChannelEvent<FTPChannelChild>(child),
-        mChannelStatus(aChannelStatus) {}
-
-  void Run() override { mChild->MaybeDivertOnStop(mChannelStatus); }
-
- private:
-  nsresult mChannelStatus;
-};
-
-void FTPChannelChild::MaybeDivertOnStop(const nsresult& aChannelStatus) {
-  if (mDivertingToParent) {
-    SendDivertOnStopRequest(aChannelStatus);
-  }
-}
-
 void FTPChannelChild::DoOnStopRequest(const nsresult& aChannelStatus,
                                       const nsCString& aErrorMsg,
                                       bool aUseUTF8) {
   LOG(("FTPChannelChild::DoOnStopRequest [this=%p status=%" PRIx32 "]\n", this,
        static_cast<uint32_t>(aChannelStatus)));
 
   if (mDivertingToParent) {
     MOZ_RELEASE_ASSERT(
@@ -503,92 +406,84 @@ void FTPChannelChild::DoOnStopRequest(co
 
     SendDivertOnStopRequest(aChannelStatus);
     return;
   }
 
   if (!mCanceled) mStatus = aChannelStatus;
 
   if (mUnknownDecoderInvolved) {
+    RefPtr<FTPChannelChild> self = this;
     mUnknownDecoderEventQ.AppendElement(
-        MakeUnique<MaybeDivertOnStopFTPEvent>(this, aChannelStatus));
+        MakeUnique<NeckoTargetChannelFunctionEvent>(this, [=]() {
+          if (self->mDivertingToParent) {
+            self->SendDivertOnStopRequest(aChannelStatus);
+          }
+        }));
   }
 
   {  // Ensure that all queued ipdl events are dispatched before
     // we initiate protocol deletion below.
     mIsPending = false;
     AutoEventEnqueuer ensureSerialDispatch(mEventQ);
     (void)mListener->OnStopRequest(this, aChannelStatus);
 
     mListener = nullptr;
 
-    if (mLoadGroup) mLoadGroup->RemoveRequest(this, nullptr, aChannelStatus);
+    if (mLoadGroup) {
+      mLoadGroup->RemoveRequest(this, nullptr, aChannelStatus);
+    }
   }
 
   // This calls NeckoChild::DeallocPFTPChannelChild(), which deletes |this| if
   // IPDL holds the last reference.  Don't rely on |this| existing after here!
   Send__delete__(this);
 }
 
-class FTPFailedAsyncOpenEvent
-    : public NeckoTargetChannelEvent<FTPChannelChild> {
- public:
-  FTPFailedAsyncOpenEvent(FTPChannelChild* aChild, nsresult aStatus)
-      : NeckoTargetChannelEvent<FTPChannelChild>(aChild), mStatus(aStatus) {}
-
-  void Run() override { mChild->DoFailedAsyncOpen(mStatus); }
-
- private:
-  nsresult mStatus;
-};
-
 mozilla::ipc::IPCResult FTPChannelChild::RecvFailedAsyncOpen(
-    const nsresult& statusCode) {
+    const nsresult& aStatusCode) {
   LOG(("FTPChannelChild::RecvFailedAsyncOpen [this=%p status=%" PRIx32 "]\n",
-       this, static_cast<uint32_t>(statusCode)));
-  mEventQ->RunOrEnqueue(new FTPFailedAsyncOpenEvent(this, statusCode));
+       this, static_cast<uint32_t>(aStatusCode)));
+  RefPtr<FTPChannelChild> self = this;
+  mEventQ->RunOrEnqueue(new NeckoTargetChannelFunctionEvent(
+      this, [=]() { self->DoFailedAsyncOpen(aStatusCode); }));
   return IPC_OK();
 }
 
-void FTPChannelChild::DoFailedAsyncOpen(const nsresult& statusCode) {
+void FTPChannelChild::DoFailedAsyncOpen(const nsresult& aStatusCode) {
   LOG(("FTPChannelChild::DoFailedAsyncOpen [this=%p status=%" PRIx32 "]\n",
-       this, static_cast<uint32_t>(statusCode)));
-  mStatus = statusCode;
+       this, static_cast<uint32_t>(aStatusCode)));
+  mStatus = aStatusCode;
 
-  if (mLoadGroup) mLoadGroup->RemoveRequest(this, nullptr, statusCode);
+  if (mLoadGroup) {
+    mLoadGroup->RemoveRequest(this, nullptr, aStatusCode);
+  }
 
   if (mListener) {
     mListener->OnStartRequest(this);
     mIsPending = false;
-    mListener->OnStopRequest(this, statusCode);
+    mListener->OnStopRequest(this, aStatusCode);
   } else {
     mIsPending = false;
   }
 
   mListener = nullptr;
 
-  if (mIPCOpen) Send__delete__(this);
+  if (mIPCOpen) {
+    Send__delete__(this);
+  }
 }
 
-class FTPFlushedForDiversionEvent
-    : public NeckoTargetChannelEvent<FTPChannelChild> {
- public:
-  explicit FTPFlushedForDiversionEvent(FTPChannelChild* aChild)
-      : NeckoTargetChannelEvent<FTPChannelChild>(aChild) {
-    MOZ_RELEASE_ASSERT(aChild);
-  }
-
-  void Run() override { mChild->FlushedForDiversion(); }
-};
-
 mozilla::ipc::IPCResult FTPChannelChild::RecvFlushedForDiversion() {
   LOG(("FTPChannelChild::RecvFlushedForDiversion [this=%p]\n", this));
   MOZ_ASSERT(mDivertingToParent);
 
-  mEventQ->RunOrEnqueue(new FTPFlushedForDiversionEvent(this), true);
+  RefPtr<FTPChannelChild> self = this;
+  mEventQ->RunOrEnqueue(new NeckoTargetChannelFunctionEvent(
+      this, [=]() { self->FlushedForDiversion(); }));
   return IPC_OK();
 }
 
 void FTPChannelChild::FlushedForDiversion() {
   LOG(("FTPChannelChild::FlushedForDiversion [this=%p]\n", this));
   MOZ_RELEASE_ASSERT(mDivertingToParent);
 
   // Once this is set, it should not be unset before FTPChannelChild is taken
@@ -607,40 +502,41 @@ mozilla::ipc::IPCResult FTPChannelChild:
   // DivertTo() has been called on parent, so we can now start sending queued
   // IPDL messages back to parent listener.
   if (NS_WARN_IF(NS_FAILED(Resume()))) {
     return IPC_FAIL_NO_REASON(this);
   }
   return IPC_OK();
 }
 
-class FTPDeleteSelfEvent : public NeckoTargetChannelEvent<FTPChannelChild> {
- public:
-  explicit FTPDeleteSelfEvent(FTPChannelChild* aChild)
-      : NeckoTargetChannelEvent<FTPChannelChild>(aChild) {}
-  void Run() override { mChild->DoDeleteSelf(); }
-};
-
 mozilla::ipc::IPCResult FTPChannelChild::RecvDeleteSelf() {
-  mEventQ->RunOrEnqueue(new FTPDeleteSelfEvent(this));
+  RefPtr<FTPChannelChild> self = this;
+  mEventQ->RunOrEnqueue(new NeckoTargetChannelFunctionEvent(
+      this, [=]() { self->DoDeleteSelf(); }));
   return IPC_OK();
 }
 
 void FTPChannelChild::DoDeleteSelf() {
-  if (mIPCOpen) Send__delete__(this);
+  if (mIPCOpen) {
+    Send__delete__(this);
+  }
 }
 
 NS_IMETHODIMP
-FTPChannelChild::Cancel(nsresult status) {
+FTPChannelChild::Cancel(nsresult aStatus) {
   LOG(("FTPChannelChild::Cancel [this=%p]\n", this));
-  if (mCanceled) return NS_OK;
+  if (mCanceled) {
+    return NS_OK;
+  }
 
   mCanceled = true;
-  mStatus = status;
-  if (mIPCOpen) SendCancel(status);
+  mStatus = aStatus;
+  if (mIPCOpen) {
+    SendCancel(aStatus);
+  }
   return NS_OK;
 }
 
 NS_IMETHODIMP
 FTPChannelChild::Suspend() {
   NS_ENSURE_TRUE(mIPCOpen, NS_ERROR_NOT_AVAILABLE);
 
   LOG(("FTPChannelChild::Suspend [this=%p]\n", this));
@@ -675,17 +571,17 @@ FTPChannelChild::Resume() {
   return NS_OK;
 }
 
 //-----------------------------------------------------------------------------
 // FTPChannelChild::nsIChildChannel
 //-----------------------------------------------------------------------------
 
 NS_IMETHODIMP
-FTPChannelChild::ConnectParent(uint32_t id) {
+FTPChannelChild::ConnectParent(uint32_t aId) {
   NS_ENSURE_TRUE((gNeckoChild), NS_ERROR_FAILURE);
   NS_ENSURE_TRUE(
       !static_cast<ContentChild*>(gNeckoChild->Manager())->IsShuttingDown(),
       NS_ERROR_FAILURE);
 
   LOG(("FTPChannelChild::ConnectParent [this=%p]\n", this));
 
   mozilla::dom::BrowserChild* browserChild = nullptr;
@@ -701,40 +597,42 @@ FTPChannelChild::ConnectParent(uint32_t 
 
   // This must happen before the constructor message is sent.
   SetupNeckoTarget();
 
   // The socket transport in the chrome process now holds a logical ref to us
   // until OnStopRequest, or we do a redirect, or we hit an IPDL error.
   AddIPDLReference();
 
-  FTPChannelConnectArgs connectArgs(id);
+  FTPChannelConnectArgs connectArgs(aId);
 
   if (!gNeckoChild->SendPFTPChannelConstructor(
           this, browserChild, IPC::SerializedLoadContext(this), connectArgs)) {
     return NS_ERROR_FAILURE;
   }
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
-FTPChannelChild::CompleteRedirectSetup(nsIStreamListener* listener,
+FTPChannelChild::CompleteRedirectSetup(nsIStreamListener* aListener,
                                        nsISupports* aContext) {
   LOG(("FTPChannelChild::CompleteRedirectSetup [this=%p]\n", this));
 
   NS_ENSURE_TRUE(!mIsPending, NS_ERROR_IN_PROGRESS);
   NS_ENSURE_TRUE(!mWasOpened, NS_ERROR_ALREADY_OPENED);
 
   mIsPending = true;
   mWasOpened = true;
-  mListener = listener;
+  mListener = aListener;
 
   // add ourselves to the load group.
-  if (mLoadGroup) mLoadGroup->AddRequest(this, nullptr);
+  if (mLoadGroup) {
+    mLoadGroup->AddRequest(this, nullptr);
+  }
 
   // We already have an open IPDL connection to the parent. If on-modify-request
   // listeners or load group observers canceled us, let the parent handle it
   // and send it back to us naturally.
   return NS_OK;
 }
 
 //-----------------------------------------------------------------------------
--- a/netwerk/protocol/ftp/FTPChannelChild.h
+++ b/netwerk/protocol/ftp/FTPChannelChild.h
@@ -48,92 +48,81 @@ class FTPChannelChild final : public PFT
   NS_DECL_ISUPPORTS_INHERITED
   NS_DECL_NSIFTPCHANNEL
   NS_DECL_NSIUPLOADCHANNEL
   NS_DECL_NSIRESUMABLECHANNEL
   NS_DECL_NSIPROXIEDCHANNEL
   NS_DECL_NSICHILDCHANNEL
   NS_DECL_NSIDIVERTABLECHANNEL
 
-  NS_IMETHOD Cancel(nsresult status) override;
+  NS_IMETHOD Cancel(nsresult aStatus) override;
   NS_IMETHOD Suspend() override;
   NS_IMETHOD Resume() override;
 
-  explicit FTPChannelChild(nsIURI* uri);
+  explicit FTPChannelChild(nsIURI* aUri);
 
   void AddIPDLReference();
   void ReleaseIPDLReference();
 
-  NS_IMETHOD AsyncOpen(nsIStreamListener* listener) override;
+  NS_IMETHOD AsyncOpen(nsIStreamListener* aListener) override;
 
   // Note that we handle this ourselves, overriding the nsBaseChannel
   // default behavior, in order to be e10s-friendly.
-  NS_IMETHOD IsPending(bool* result) override;
+  NS_IMETHOD IsPending(bool* aResult) override;
 
-  nsresult OpenContentStream(bool async, nsIInputStream** stream,
-                             nsIChannel** channel) override;
+  nsresult OpenContentStream(bool aAsync, nsIInputStream** aStream,
+                             nsIChannel** aChannel) override;
 
-  bool IsSuspended();
+  bool IsSuspended() const;
 
   void FlushedForDiversion();
 
  protected:
   virtual ~FTPChannelChild();
 
   mozilla::ipc::IPCResult RecvOnStartRequest(const nsresult& aChannelStatus,
                                              const int64_t& aContentLength,
                                              const nsCString& aContentType,
                                              const PRTime& aLastModified,
                                              const nsCString& aEntityID,
                                              const URIParams& aURI) override;
-  mozilla::ipc::IPCResult RecvOnDataAvailable(const nsresult& channelStatus,
-                                              const nsCString& data,
-                                              const uint64_t& offset,
-                                              const uint32_t& count) override;
-  mozilla::ipc::IPCResult RecvOnStopRequest(const nsresult& channelStatus,
+  mozilla::ipc::IPCResult RecvOnDataAvailable(const nsresult& aChannelStatus,
+                                              const nsCString& aData,
+                                              const uint64_t& aOffset,
+                                              const uint32_t& aCount) override;
+  mozilla::ipc::IPCResult RecvOnStopRequest(const nsresult& aChannelStatus,
                                             const nsCString& aErrorMsg,
                                             const bool& aUseUTF8) override;
   mozilla::ipc::IPCResult RecvFailedAsyncOpen(
-      const nsresult& statusCode) override;
+      const nsresult& aStatusCode) override;
   mozilla::ipc::IPCResult RecvFlushedForDiversion() override;
   mozilla::ipc::IPCResult RecvDivertMessages() override;
   mozilla::ipc::IPCResult RecvDeleteSelf() override;
 
   void DoOnStartRequest(const nsresult& aChannelStatus,
                         const int64_t& aContentLength,
                         const nsCString& aContentType,
                         const PRTime& aLastModified, const nsCString& aEntityID,
                         const URIParams& aURI);
-  void DoOnDataAvailable(const nsresult& channelStatus, const nsCString& data,
-                         const uint64_t& offset, const uint32_t& count);
-  void MaybeDivertOnData(const nsCString& data, const uint64_t& offset,
-                         const uint32_t& count);
-  void MaybeDivertOnStop(const nsresult& statusCode);
-  void DoOnStopRequest(const nsresult& statusCode, const nsCString& aErrorMsg,
+  void DoOnDataAvailable(const nsresult& aChannelStatus, const nsCString& aData,
+                         const uint64_t& aOffset, const uint32_t& aCount);
+  void DoOnStopRequest(const nsresult& StatusCode, const nsCString& aErrorMsg,
                        bool aUseUTF8);
-  void DoFailedAsyncOpen(const nsresult& statusCode);
+  void DoFailedAsyncOpen(const nsresult& aStatusCode);
   void DoDeleteSelf();
 
   void SetupNeckoTarget() override;
 
-  friend class FTPStartRequestEvent;
-  friend class FTPDataAvailableEvent;
-  friend class MaybeDivertOnDataFTPEvent;
-  friend class FTPStopRequestEvent;
-  friend class MaybeDivertOnStopFTPEvent;
-  friend class FTPFailedAsyncOpenEvent;
-  friend class FTPFlushedForDiversionEvent;
-  friend class FTPDeleteSelfEvent;
-  friend class NeckoTargetChannelEvent<FTPChannelChild>;
+  friend class NeckoTargetChannelFunctionEvent;
 
  private:
   nsCOMPtr<nsIInputStream> mUploadStream;
 
   bool mIPCOpen;
-  RefPtr<ChannelEventQueue> mEventQ;
+  const RefPtr<ChannelEventQueue> mEventQ;
 
   // If nsUnknownDecoder is involved we queue onDataAvailable (and possibly
   // OnStopRequest) so that we can divert them if needed when the listener's
   // OnStartRequest is finally called
   nsTArray<UniquePtr<ChannelEvent>> mUnknownDecoderEventQ;
   bool mUnknownDecoderInvolved;
 
   bool mCanceled;
@@ -153,14 +142,14 @@ class FTPChannelChild final : public PFT
   // Once set, no OnStart/OnData/OnStop callbacks should be received from the
   // parent channel, nor dequeued from the ChannelEventQueue.
   bool mFlushedForDiversion;
   // Set if SendSuspend is called. Determines if SendResume is needed when
   // diverting callbacks to parent.
   bool mSuspendSent;
 };
 
-inline bool FTPChannelChild::IsSuspended() { return mSuspendCount != 0; }
+inline bool FTPChannelChild::IsSuspended() const { return mSuspendCount != 0; }
 
 }  // namespace net
 }  // namespace mozilla
 
 #endif  // mozilla_net_FTPChannelChild_h