Bug 1531608 - Replace m_channelContext with m_isChannel bool flag in nsMsgProtocol.cpp. r=BenC a=jorgk
authorJorg K <jorgk@jorgk.com>
Fri, 02 Aug 2019 09:49:30 +0200
changeset 35268 160f774b6e653cf0b968120459c987c587dfff36
parent 35267 71349d370678bb201e7566a6e83950ac58385496
child 35269 c11139a488bed744ca3b24ec0e7cf16f4c1ddcfe
push id2475
push usermozilla@jorgk.com
push dateFri, 02 Aug 2019 20:07:29 +0000
treeherdercomm-beta@c7b7a4c6679d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersBenC, jorgk
bugs1531608
Bug 1531608 - Replace m_channelContext with m_isChannel bool flag in nsMsgProtocol.cpp. r=BenC a=jorgk
mailnews/base/util/nsMsgProtocol.cpp
mailnews/base/util/nsMsgProtocol.h
mailnews/news/src/nsNNTPProtocol.cpp
--- a/mailnews/base/util/nsMsgProtocol.cpp
+++ b/mailnews/base/util/nsMsgProtocol.cpp
@@ -54,16 +54,17 @@ static char16_t *FormatStringWithHostNam
                                                 nsIMsgMailNewsUrl *msgUri);
 
 nsMsgProtocol::nsMsgProtocol(nsIURI *aURL) {
   m_flags = 0;
   m_readCount = 0;
   mLoadFlags = 0;
   m_socketIsOpen = false;
   mContentLength = -1;
+  m_isChannel = false;
 
   GetSpecialDirectoryWithFileName(NS_OS_TEMP_DIR, "tempMessage.eml",
                                   getter_AddRefs(m_tempMsgFile));
 
   mSuppressListenerNotifications = false;
   InitFromURI(aURL);
 }
 
@@ -309,17 +310,17 @@ NS_IMETHODIMP nsMsgProtocol::OnStartRequ
       m_loadGroup->AddRequest(static_cast<nsIRequest *>(this),
                               nullptr /* context isupports */);
   }
 
   // if we are set up as a channel, we should notify our channel listener that
   // we are starting... so pass in ourself as the channel and not the underlying
   // socket or file channel the protocol happens to be using
   if (!mSuppressListenerNotifications && m_channelListener) {
-    if (!m_channelContext) m_channelContext = uri;
+    m_isChannel = true;
     rv = m_channelListener->OnStartRequest(this);
   }
 
   nsCOMPtr<nsISocketTransport> strans = do_QueryInterface(m_transport);
 
   if (strans)
     strans->SetTimeout(nsISocketTransport::TIMEOUT_READ_WRITE, gSocketTimeout);
 
@@ -389,25 +390,24 @@ NS_IMETHODIMP nsMsgProtocol::OnStopReque
 
   if (uri) {
     nsCOMPtr<nsIMsgMailNewsUrl> msgUrl = do_QueryInterface(uri);
     rv = msgUrl->SetUrlState(false, aStatus);  // Always returns NS_OK.
     if (m_loadGroup)
       m_loadGroup->RemoveRequest(static_cast<nsIRequest *>(this), nullptr,
                                  aStatus);
 
-    // !m_channelContext because if we're set up as a channel, then the remove
+    // !m_isChannel because if we're set up as a channel, then the remove
     // request above will handle alerting the user, so we don't need to.
     //
     // !NS_BINDING_ABORTED because we don't want to see an alert if the user
     // cancelled the operation.  also, we'll get here because we call Cancel()
     // to force removal of the nsSocketTransport.  see CloseSocket()
     // bugs #30775 and #30648 relate to this
-    if (!m_channelContext && NS_FAILED(aStatus) &&
-        (aStatus != NS_BINDING_ABORTED))
+    if (!m_isChannel && NS_FAILED(aStatus) && (aStatus != NS_BINDING_ABORTED))
       ShowAlertMessage(msgUrl, aStatus);
   }  // if we have a mailnews url.
 
   // Drop notification callbacks to prevent cycles.
   mCallbacks = nullptr;
   mProgressEventSink = nullptr;
   // Call CloseSocket(), in case we got here because the server dropped the
   // connection while reading, and we never get a chance to get back into
@@ -446,17 +446,17 @@ nsresult nsMsgProtocol::LoadUrl(nsIURI *
     rv = aMsgUrl->SetUrlState(true, NS_OK);
 
     // if the url is given a stream consumer then we should use it to forward
     // calls to...
     if (!m_channelListener &&
         aConsumer)  // if we don't have a registered listener already
     {
       m_channelListener = do_QueryInterface(aConsumer);
-      if (!m_channelContext) m_channelContext = do_QueryInterface(aURL);
+      m_isChannel = true;
     }
 
     if (!m_socketIsOpen) {
       if (m_transport) {
         // open buffered, asynchronous input stream
         nsCOMPtr<nsIInputStream> stream;
         rv = m_transport->OpenInputStream(0, 0, 0, getter_AddRefs(stream));
         if (NS_FAILED(rv)) return rv;
@@ -538,21 +538,17 @@ NS_IMETHODIMP nsMsgProtocol::AsyncOpen(n
   nsAutoCString scheme;
   rv = m_url->GetScheme(scheme);
   if (NS_FAILED(rv)) return rv;
 
   rv = NS_CheckPortSafety(port, scheme.get());
   if (NS_FAILED(rv)) return rv;
 
   // set the stream listener and then load the url
-  m_channelContext = nullptr;
-  nsCOMPtr<nsIChannel> channel;
-  nsCOMPtr<nsIURI> uri;
-  GetURI(getter_AddRefs(uri));
-  m_channelContext = uri;
+  m_isChannel = true;
 
   m_channelListener = listener;
   return LoadUrl(m_url, nullptr);
 }
 
 NS_IMETHODIMP nsMsgProtocol::GetLoadFlags(nsLoadFlags *aLoadFlags) {
   *aLoadFlags = mLoadFlags;
   return NS_OK;
--- a/mailnews/base/util/nsMsgProtocol.h
+++ b/mailnews/base/util/nsMsgProtocol.h
@@ -155,17 +155,17 @@ class NS_MSG_BASE nsMsgProtocol : public
   // auth module for access to NTLM functions
   nsCOMPtr<nsIAuthModule> m_authModule;
 
   // the following is a catch all for nsIChannel related data
   nsCOMPtr<nsIURI> m_originalUrl;  // the original url
   nsCOMPtr<nsIURI> m_url;          // the running url
   nsCOMPtr<nsISupports> m_consumer;
   nsCOMPtr<nsIStreamListener> m_channelListener;
-  nsCOMPtr<nsISupports> m_channelContext;
+  bool m_isChannel;
   nsCOMPtr<nsILoadGroup> m_loadGroup;
   nsLoadFlags mLoadFlags;
   nsCOMPtr<nsIProgressEventSink> mProgressEventSink;
   nsCOMPtr<nsIInterfaceRequestor> mCallbacks;
   nsCOMPtr<nsISupports> mOwner;
   nsCString mContentType;
   nsCString mCharset;
   int64_t mContentLength;
--- a/mailnews/news/src/nsNNTPProtocol.cpp
+++ b/mailnews/news/src/nsNNTPProtocol.cpp
@@ -812,19 +812,17 @@ NS_IMETHODIMP nsNNTPProtocol::AsyncOpen(
 
   int32_t port;
   rv = mailnewsUrl->GetPort(&port);
   if (NS_FAILED(rv)) return rv;
 
   rv = NS_CheckPortSafety(port, "news");
   if (NS_FAILED(rv)) return rv;
 
-  nsCOMPtr<nsIURI> uri;
-  GetURI(getter_AddRefs(uri));
-  m_channelContext = uri;
+  m_isChannel = true;
   m_channelListener = listener;
   m_runningURL->GetNewsAction(&m_newsAction);
 
   // Before running through the connection, try to see if we can grab the data
   // from the offline storage or the memory cache. Only actions retrieving
   // messages can be cached.
   if (mailnewsUrl && (m_newsAction == nsINntpUrl::ActionFetchArticle ||
                       m_newsAction == nsINntpUrl::ActionFetchPart ||
@@ -4368,17 +4366,17 @@ nsresult nsNNTPProtocol::CleanupAfterRun
 
   Cleanup();
 
   mDisplayInputStream = nullptr;
   mDisplayOutputStream = nullptr;
   mProgressEventSink = nullptr;
   SetOwner(nullptr);
 
-  m_channelContext = nullptr;
+  m_isChannel = false;
   m_channelListener = nullptr;
   m_loadGroup = nullptr;
   mCallbacks = nullptr;
 
   // disable timeout before caching.
   nsCOMPtr<nsISocketTransport> strans = do_QueryInterface(m_transport);
   if (strans)
     strans->SetTimeout(nsISocketTransport::TIMEOUT_READ_WRITE, PR_UINT32_MAX);