Bug 1404045 - follow-up: Use SlicedInputStream() where offset/length for NS_NewInputStreamPump() are necessary. rs=bustage-fix
authorJorg K <jorgk@jorgk.com>
Sat, 30 Sep 2017 01:37:17 +0200
changeset 29065 3dfe0c40ba28093a2c4638126fd1df3bb204561d
parent 29064 e9367f02e475d6487615993f484be0a6b0f85597
child 29066 2c194c1a63a9145444ea59c7b5382210f7c32627
push id2068
push userclokep@gmail.com
push dateMon, 13 Nov 2017 19:02:14 +0000
treeherdercomm-beta@9c7e7ce8672b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbustage-fix
bugs1404045
Bug 1404045 - follow-up: Use SlicedInputStream() where offset/length for NS_NewInputStreamPump() are necessary. rs=bustage-fix
mailnews/imap/src/nsImapProtocol.cpp
mailnews/news/src/nsNNTPProtocol.cpp
--- a/mailnews/imap/src/nsImapProtocol.cpp
+++ b/mailnews/imap/src/nsImapProtocol.cpp
@@ -51,16 +51,17 @@
 #include "nsIWindowMediator.h"
 #include "nsIWindowWatcher.h"
 #include "nsCOMPtr.h"
 #include "nsMimeTypes.h"
 #include "nsIInterfaceRequestor.h"
 #include "nsXPCOMCIDInternal.h"
 #include "nsIXULAppInfo.h"
 #include "nsSyncRunnableHelpers.h"
+#include "SlicedInputStream.h"
 
 static mozilla::LazyLogModule IMAP("IMAP");
 
 // netlib required files
 #include "nsIStreamListener.h"
 #include "nsIMsgIncomingServer.h"
 #include "nsIImapIncomingServer.h"
 #include "nsIPrefBranch.h"
@@ -9650,19 +9651,20 @@ bool nsImapMockChannel::ReadFromLocalCac
       {
         // dougt - This may break the ablity to "cancel" a read from offline mail reading.
         // fileChannel->SetLoadGroup(m_loadGroup);
         RefPtr<nsImapCacheStreamListener> cacheListener = new nsImapCacheStreamListener();
         cacheListener->Init(m_channelListener, this);
 
         // create a stream pump that will async read the specified amount of data.
         // XXX make offset/size 64-bit ints
+        RefPtr<SlicedInputStream> slicedStream =
+          new SlicedInputStream(fileStream, uint64_t(offset), uint64_t(size));
         nsCOMPtr<nsIInputStreamPump> pump;
-        rv = NS_NewInputStreamPump(getter_AddRefs(pump), fileStream,
-                                   offset, (int64_t) size);
+        rv = NS_NewInputStreamPump(getter_AddRefs(pump), slicedStream);
         if (NS_SUCCEEDED(rv))
           rv = pump->AsyncRead(cacheListener, m_channelContext);
 
         if (NS_SUCCEEDED(rv)) // ONLY if we succeeded in actually starting the read should we return
         {
           // if the msg is unread, we should mark it read on the server. This lets
           // the code running this url we're loading from the cache, if it cares.
           imapUrl->SetMsgLoadingFromCache(true);
--- a/mailnews/news/src/nsNNTPProtocol.cpp
+++ b/mailnews/news/src/nsNNTPProtocol.cpp
@@ -75,16 +75,17 @@
 #include "nsIStreamConverterService.h"
 #include "nsIStreamListenerTee.h"
 #include "nsISocketTransport.h"
 #include "nsIArray.h"
 #include "nsArrayUtils.h"
 #include "nsICancelable.h"
 
 #include "nsIInputStreamPump.h"
+#include "SlicedInputStream.h"
 #include "nsIProxyInfo.h"
 #include "nsContentSecurityManager.h"
 
 #include <time.h>
 
 #undef GetPort  // XXX Windows!
 #undef SetPort  // XXX Windows!
 #undef PostMessage // avoid to collision with WinUser.h
@@ -734,19 +735,20 @@ bool nsNNTPProtocol::ReadFromLocalCache(
 
         RefPtr<nsNntpCacheStreamListener> cacheListener =
           new nsNntpCacheStreamListener();
 
         cacheListener->Init(m_channelListener, static_cast<nsIChannel *>(this), mailnewsUrl);
 
         // create a stream pump that will async read the specified amount of data.
         // XXX make size 64-bit int
+        RefPtr<SlicedInputStream> slicedStream =
+          new SlicedInputStream(fileStream, uint64_t(offset), uint64_t(size));
         nsCOMPtr<nsIInputStreamPump> pump;
-        rv = NS_NewInputStreamPump(getter_AddRefs(pump),
-                                   fileStream, offset, (int64_t) size);
+        rv = NS_NewInputStreamPump(getter_AddRefs(pump), slicedStream);
         if (NS_SUCCEEDED(rv))
           rv = pump->AsyncRead(cacheListener, m_channelContext);
 
         if (NS_SUCCEEDED(rv)) // ONLY if we succeeded in actually starting the read should we return
         {
           mContentType.Truncate();
           m_channelListener = nullptr;
           NNTP_LOG_NOTE("Loading message from offline storage");