Bug 1523249. r=valentin, a=lizzard
authorGijs Kruitbosch <gijskruitbosch@gmail.com>
Wed, 30 Jan 2019 11:39:42 +0000
changeset 515801 0630d18a7d26772237f829a59f2c1d72ba43f7aa
parent 515800 9b74b2602df1bb9f25a35b1fd3a47017c07aac0b
child 515802 d9506222285b1c0e08818aca83bfefa4a5c18a3f
push id1953
push userffxbld-merge
push dateMon, 11 Mar 2019 12:10:20 +0000
treeherdermozilla-release@9c35dcbaa899 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersvalentin, lizzard
bugs1523249
milestone66.0
Bug 1523249. r=valentin, a=lizzard Differential Revision: https://phabricator.services.mozilla.com/D17965
netwerk/protocol/ftp/FTPChannelChild.cpp
netwerk/protocol/ftp/nsFtpConnectionThread.cpp
--- a/netwerk/protocol/ftp/FTPChannelChild.cpp
+++ b/netwerk/protocol/ftp/FTPChannelChild.cpp
@@ -16,17 +16,16 @@
 #include "nsITabChild.h"
 #include "nsStringStream.h"
 #include "nsNetUtil.h"
 #include "base/compiler_specific.h"
 #include "mozilla/ipc/IPCStreamUtils.h"
 #include "mozilla/ipc/URIUtils.h"
 #include "SerializedLoadContext.h"
 #include "mozilla/ipc/BackgroundUtils.h"
-#include "nsIPrompt.h"
 #include "nsIURIMutator.h"
 
 using mozilla::dom::ContentChild;
 using namespace mozilla::ipc;
 
 #undef LOG
 #define LOG(args) MOZ_LOG(gFTPLog, mozilla::LogLevel::Debug, args)
 
@@ -463,39 +462,16 @@ mozilla::ipc::IPCResult FTPChannelChild:
   LOG(("FTPChannelChild::RecvOnStopRequest [this=%p status=%" PRIx32 "]\n",
        this, static_cast<uint32_t>(aChannelStatus)));
 
   mEventQ->RunOrEnqueue(
       new FTPStopRequestEvent(this, aChannelStatus, aErrorMsg, aUseUTF8));
   return IPC_OK();
 }
 
-class nsFtpChildAsyncAlert : public Runnable {
- public:
-  nsFtpChildAsyncAlert(nsIPrompt* aPrompter, nsString aResponseMsg)
-      : Runnable("nsFtpChildAsyncAlert"),
-        mPrompter(aPrompter),
-        mResponseMsg(std::move(aResponseMsg)) {}
-
- protected:
-  virtual ~nsFtpChildAsyncAlert() = default;
-
- public:
-  NS_IMETHOD Run() override {
-    if (mPrompter) {
-      mPrompter->Alert(nullptr, mResponseMsg.get());
-    }
-    return NS_OK;
-  }
-
- private:
-  nsCOMPtr<nsIPrompt> mPrompter;
-  nsString mResponseMsg;
-};
-
 class MaybeDivertOnStopFTPEvent
     : public NeckoTargetChannelEvent<FTPChannelChild> {
  public:
   MaybeDivertOnStopFTPEvent(FTPChannelChild* child,
                             const nsresult& aChannelStatus)
       : NeckoTargetChannelEvent<FTPChannelChild>(child),
         mChannelStatus(aChannelStatus) {}
 
@@ -534,33 +510,16 @@ void FTPChannelChild::DoOnStopRequest(co
   }
 
   {  // Ensure that all queued ipdl events are dispatched before
     // we initiate protocol deletion below.
     mIsPending = false;
     AutoEventEnqueuer ensureSerialDispatch(mEventQ);
     (void)mListener->OnStopRequest(this, mListenerContext, aChannelStatus);
 
-    if (NS_FAILED(aChannelStatus) && !aErrorMsg.IsEmpty()) {
-      nsCOMPtr<nsIPrompt> prompter;
-      GetCallback(prompter);
-      if (prompter) {
-        nsCOMPtr<nsIRunnable> alertEvent;
-        if (aUseUTF8) {
-          alertEvent = new nsFtpChildAsyncAlert(
-              prompter, NS_ConvertUTF8toUTF16(aErrorMsg));
-        } else {
-          alertEvent = new nsFtpChildAsyncAlert(
-              prompter, NS_ConvertASCIItoUTF16(aErrorMsg));
-        }
-
-        Dispatch(alertEvent.forget());
-      }
-    }
-
     mListener = nullptr;
     mListenerContext = nullptr;
 
     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!
--- a/netwerk/protocol/ftp/nsFtpConnectionThread.cpp
+++ b/netwerk/protocol/ftp/nsFtpConnectionThread.cpp
@@ -26,17 +26,16 @@
 #include "nsIAsyncStreamCopier.h"
 #include "nsThreadUtils.h"
 #include "nsStreamUtils.h"
 #include "nsIURL.h"
 #include "nsISocketTransport.h"
 #include "nsIStreamListenerTee.h"
 #include "nsIPrefService.h"
 #include "nsIPrefBranch.h"
-#include "nsIStringBundle.h"
 #include "nsAuthInformationHolder.h"
 #include "nsIProtocolProxyService.h"
 #include "nsICancelable.h"
 #include "nsIOutputStream.h"
 #include "nsIPrompt.h"
 #include "nsIProtocolHandler.h"
 #include "nsIProxyInfo.h"
 #include "nsIRunnable.h"
@@ -845,43 +844,18 @@ nsFtpState::R_syst() {
                (mResponseMsg.Find("windows", true) > -1)) {
       mServerType = FTP_NT_TYPE;
     } else if (mResponseMsg.Find("OS/2", true) > -1) {
       mServerType = FTP_OS2_TYPE;
     } else if (mResponseMsg.Find("VMS", true) > -1) {
       mServerType = FTP_VMS_TYPE;
     } else {
       NS_ERROR("Server type list format unrecognized.");
-      // Guessing causes crashes.
-      // (Of course, the parsing code should be more robust...)
-      nsCOMPtr<nsIStringBundleService> bundleService =
-          do_GetService(NS_STRINGBUNDLE_CONTRACTID);
-      if (!bundleService) return FTP_ERROR;
 
-      nsCOMPtr<nsIStringBundle> bundle;
-      nsresult rv =
-          bundleService->CreateBundle(NECKO_MSGS_URL, getter_AddRefs(bundle));
-      if (NS_FAILED(rv)) return FTP_ERROR;
-
-      char16_t *ucs2Response = ToNewUnicode(mResponseMsg);
-      const char16_t *formatStrings[1] = {ucs2Response};
-
-      nsAutoString formattedString;
-      rv = bundle->FormatStringFromName("UnsupportedFTPServer", formatStrings,
-                                        1, formattedString);
-      free(ucs2Response);
-      if (NS_FAILED(rv)) return FTP_ERROR;
-
-      // TODO(darin): this code should not be dictating UI like this!
-      nsCOMPtr<nsIPrompt> prompter;
-      mChannel->GetCallback(prompter);
-      if (prompter) prompter->Alert(nullptr, formattedString.get());
-
-      // since we just alerted the user, clear mResponseMsg,
-      // which is displayed to the user.
+      // clear mResponseMsg, which is displayed to the user.
       mResponseMsg = "";
       return FTP_ERROR;
     }
 
     return FTP_S_FEAT;
   }
 
   if (mResponseCode / 100 == 5) {
@@ -1624,64 +1598,25 @@ void nsFtpState::KillControlConnection()
     mControlConnection->Disconnect(rv);
   } else {
     mControlConnection->Disconnect(NS_BINDING_ABORTED);
   }
 
   mControlConnection = nullptr;
 }
 
-class nsFtpAsyncAlert : public Runnable {
- public:
-  nsFtpAsyncAlert(nsIPrompt *aPrompter, nsString aResponseMsg)
-      : mozilla::Runnable("nsFtpAsyncAlert"),
-        mPrompter(aPrompter),
-        mResponseMsg(std::move(aResponseMsg)) {}
-
- protected:
-  virtual ~nsFtpAsyncAlert() = default;
-
- public:
-  NS_IMETHOD Run() override {
-    if (mPrompter) {
-      mPrompter->Alert(nullptr, mResponseMsg.get());
-    }
-    return NS_OK;
-  }
-
- private:
-  nsCOMPtr<nsIPrompt> mPrompter;
-  nsString mResponseMsg;
-};
-
 nsresult nsFtpState::StopProcessing() {
   // Only do this function once.
   if (!mKeepRunning) return NS_OK;
   mKeepRunning = false;
 
   LOG_INFO(("FTP:(%p) nsFtpState stopping", this));
 
   if (NS_FAILED(mInternalError) && !mResponseMsg.IsEmpty()) {
-    // check to see if the control status is bad.
-    // web shell wont throw an alert.  we better:
-
-    // XXX(darin): this code should not be dictating UI like this!
-    nsCOMPtr<nsIPrompt> prompter;
-    mChannel->GetCallback(prompter);
-    if (prompter) {
-      nsCOMPtr<nsIRunnable> alertEvent;
-      if (mUseUTF8) {
-        alertEvent =
-            new nsFtpAsyncAlert(prompter, NS_ConvertUTF8toUTF16(mResponseMsg));
-      } else {
-        alertEvent =
-            new nsFtpAsyncAlert(prompter, NS_ConvertASCIItoUTF16(mResponseMsg));
-      }
-      NS_DispatchToMainThread(alertEvent);
-    }
+    // check to see if the control status is bad, forward the error message.
     nsCOMPtr<nsIFTPChannelParentInternal> ftpChanP;
     mChannel->GetCallback(ftpChanP);
     if (ftpChanP) {
       ftpChanP->SetErrorMsg(mResponseMsg.get(), mUseUTF8);
     }
   }
 
   nsresult broadcastErrorCode = mControlStatus;