Bug 1367707 - Bug 791645 follow-up: fix loading rest of message by moving load code from Initialize() to LoadUrl(). r=me
authorJorg K <jorgk@jorgk.com>
Sun, 28 May 2017 08:03:52 +0200
changeset 28225 489ff5fa04053595b1505036c27c8177f5a837e5
parent 28224 194e335f71ade6f03b1ca394d268c090bb831887
child 28226 4259c9a6422319d8d6b55cd27dfe875c5ffffac9
push id1966
push userclokep@gmail.com
push dateMon, 12 Jun 2017 16:57:35 +0000
treeherdercomm-beta@32d9b8d10da1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersme
bugs1367707, 791645
Bug 1367707 - Bug 791645 follow-up: fix loading rest of message by moving load code from Initialize() to LoadUrl(). r=me
mailnews/base/util/nsMsgProtocol.cpp
mailnews/local/src/nsPop3Protocol.cpp
--- a/mailnews/base/util/nsMsgProtocol.cpp
+++ b/mailnews/base/util/nsMsgProtocol.cpp
@@ -766,26 +766,24 @@ NS_IMETHODIMP nsMsgProtocol::GetStatus(n
     return m_request->GetStatus(status);
 
   *status = NS_OK;
   return *status;
 }
 
 NS_IMETHODIMP nsMsgProtocol::Cancel(nsresult status)
 {
-  NS_ASSERTION(m_request,"no channel");
-  if (!m_request)
-    return NS_ERROR_FAILURE;
+  if (m_proxyRequest)
+    m_proxyRequest->Cancel(status);
 
-  if (m_proxyRequest)
-  {
-    m_proxyRequest->Cancel(status);
-  }
+  if (m_request)
+    return m_request->Cancel(status);
 
-  return m_request->Cancel(status);
+  NS_WARNING("no request to cancel");
+  return NS_ERROR_NOT_AVAILABLE;
 }
 
 NS_IMETHODIMP nsMsgProtocol::Suspend()
 {
   if (m_request)
     return m_request->Suspend();
 
   NS_WARNING("no request to suspend");
--- a/mailnews/local/src/nsPop3Protocol.cpp
+++ b/mailnews/local/src/nsPop3Protocol.cpp
@@ -455,18 +455,16 @@ nsPop3Protocol::nsPop3Protocol(nsIURI* a
   m_totalBytesReceived(0),
   m_lineStreamBuffer(nullptr),
   m_pop3ConData(nullptr)
 {
 }
 
 nsresult nsPop3Protocol::Initialize(nsIURI * aURL)
 {
-  nsresult rv = NS_OK;
-
   MOZ_LOG(POP3LOGMODULE, LogLevel::Debug, (POP3LOG("Initialize()")));
 
   m_pop3ConData = (Pop3ConData *)PR_NEWZAP(Pop3ConData);
   if(!m_pop3ConData)
     return NS_ERROR_OUT_OF_MEMORY;
 
   m_totalBytesReceived = 0;
   m_bytesInMsgReceived = 0;
@@ -478,46 +476,22 @@ nsresult nsPop3Protocol::Initialize(nsIU
   m_prefAuthMethods = POP3_AUTH_MECH_UNDEFINED;
   m_failedAuthMethods = 0;
   m_password_already_sent = false;
   m_currentAuthMethod = POP3_AUTH_MECH_UNDEFINED;
   m_needToRerunUrl = false;
 
   m_url = do_QueryInterface(aURL);
 
-  bool proxyCallback = false;
-  if (aURL)
-  {
-    rv = MsgExamineForProxyAsync(this, this, getter_AddRefs(m_proxyRequest));
-    if (NS_FAILED(rv))
-    {
-      rv = InitializeInternal(nullptr);
-      NS_ENSURE_SUCCESS(rv, rv);
-    }
-    else
-    {
-      proxyCallback = true;
-    }
-  } // if we got a url...
-
   m_lineStreamBuffer = new nsMsgLineStreamBuffer(OUTPUT_BUFFER_SIZE, true);
-  if(!m_lineStreamBuffer)
-    return NS_ERROR_OUT_OF_MEMORY;
 
   nsCOMPtr<nsIStringBundleService> bundleService =
     mozilla::services::GetStringBundleService();
   NS_ENSURE_TRUE(bundleService, NS_ERROR_UNEXPECTED);
-  rv = bundleService->CreateBundle("chrome://messenger/locale/localMsgs.properties", getter_AddRefs(mLocalBundle));
-
-  if (!proxyCallback)
-  {
-    rv = LoadUrlInternal(m_url);
-  }
-
-  return rv;
+  return bundleService->CreateBundle("chrome://messenger/locale/localMsgs.properties", getter_AddRefs(mLocalBundle));
 }
 
 // nsIProtocolProxyCallback
 NS_IMETHODIMP
 nsPop3Protocol::OnProxyAvailable(nsICancelable *aRequest, nsIChannel *aChannel,
                                  nsIProxyInfo *aProxyInfo, nsresult aStatus)
 {
   // If we're called with NS_BINDING_ABORTED, we came here via Cancel().
@@ -1066,17 +1040,32 @@ NS_IMETHODIMP nsPop3Protocol::Cancel(nsr
   return nsMsgProtocol::Cancel(NS_BINDING_ABORTED);
 }
 
 
 nsresult nsPop3Protocol::LoadUrl(nsIURI* aURL, nsISupports * /* aConsumer */)
 {
   MOZ_LOG(POP3LOGMODULE, LogLevel::Debug, (POP3LOG("LoadUrl()")));
 
-  return Initialize(aURL);
+  nsresult rv = Initialize(aURL);
+  NS_ENSURE_SUCCESS(rv, rv);
+
+  if (aURL)
+  {
+    rv = MsgExamineForProxyAsync(this, this, getter_AddRefs(m_proxyRequest));
+    if (NS_FAILED(rv))
+    {
+      rv = InitializeInternal(nullptr);
+      NS_ENSURE_SUCCESS(rv, rv);
+
+      rv = LoadUrlInternal(m_url);
+    }
+  }
+
+  return rv;
 }
 
 nsresult nsPop3Protocol::LoadUrlInternal(nsIURI* aURL)
 {
   nsresult rv;
 
   nsCOMPtr<nsIURL> url = do_QueryInterface(aURL, &rv);
   if (NS_FAILED(rv)) return rv;