Bug 1371699 part 3. Make nsIStringInputStream not inherit from nsIInputStream anymore. r=bkelly
☠☠ backed out by 3611ff7a79e6 ☠ ☠
authorBoris Zbarsky <bzbarsky@mit.edu>
Tue, 13 Jun 2017 16:16:23 -0400
changeset 363826 2d67624a01dc4894d647ebae9aaac75097b3b353
parent 363825 503c9d22e6bbaa92f42940f878b797c765f54708
child 363827 30405ec37e1e2441ed1f7e91cfa114ff22868c26
push id32027
push usercbook@mozilla.com
push dateWed, 14 Jun 2017 12:45:45 +0000
treeherdermozilla-central@45fde181a497 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbkelly
bugs1371699
milestone56.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1371699 part 3. Make nsIStringInputStream not inherit from nsIInputStream anymore. r=bkelly This will prevent ambiguous nsIInputStream inheritance once we also inherit from nsIAsyncInputStream.
browser/components/feeds/nsFeedSniffer.cpp
dom/network/UDPSocket.cpp
dom/plugins/base/nsPluginHost.cpp
dom/plugins/base/nsPluginInstanceOwner.cpp
dom/presentation/PresentationTCPSessionTransport.cpp
dom/security/nsCSPContext.cpp
image/decoders/icon/android/nsIconChannel.cpp
image/decoders/icon/gtk/nsIconChannel.cpp
image/decoders/icon/mac/nsIconChannelCocoa.mm
image/decoders/icon/win/nsIconChannel.cpp
intl/uconv/nsScriptableUConv.cpp
netwerk/base/nsNetUtil.cpp
netwerk/streamconv/converters/nsHTTPCompressConv.cpp
netwerk/streamconv/converters/nsUnknownDecoder.cpp
startupcache/StartupCache.cpp
startupcache/StartupCacheUtils.cpp
toolkit/components/downloads/ApplicationReputation.cpp
toolkit/components/url-classifier/nsUrlClassifierStreamUpdater.cpp
xpcom/io/nsIStringStream.idl
xpcom/io/nsStringStream.cpp
xpcom/io/nsStringStream.h
--- a/browser/components/feeds/nsFeedSniffer.cpp
+++ b/browser/components/feeds/nsFeedSniffer.cpp
@@ -68,28 +68,27 @@ nsFeedSniffer::ConvertEncodedData(nsIReq
       nsCOMPtr<nsIStreamListener> converter;
       rv = converterService->AsyncConvertData(contentEncoding.get(), 
                                               "uncompressed", this, nullptr, 
                                               getter_AddRefs(converter));
       NS_ENSURE_SUCCESS(rv, rv);
 
       converter->OnStartRequest(request, nullptr);
 
-      nsCOMPtr<nsIStringInputStream> rawStream =
-        do_CreateInstance(NS_STRINGINPUTSTREAM_CONTRACTID);
-      if (!rawStream)
-        return NS_ERROR_FAILURE;
+      if (data) {
+        nsCOMPtr<nsIInputStream> rawStream;
+        rv = NS_NewCStringInputStream(
+          getter_AddRefs(rawStream),
+          nsDependentCSubstring(reinterpret_cast<const char*>(data), length));
+        if (NS_SUCCEEDED(rv)) {
+          rv = converter->OnDataAvailable(request, nullptr, rawStream, 0, length);
+        }
+      }
 
-      rv = rawStream->SetData((const char*)data, length);
-      NS_ENSURE_SUCCESS(rv, rv);
-
-      rv = converter->OnDataAvailable(request, nullptr, rawStream, 0, length);
-      NS_ENSURE_SUCCESS(rv, rv);
-
-      converter->OnStopRequest(request, nullptr, NS_OK);
+      converter->OnStopRequest(request, nullptr, rv);
     }
   }
   return rv;
 }
 
 template<int N>
 static bool
 StringBeginsWithLowercaseLiteral(nsAString& aString,
--- a/dom/network/UDPSocket.cpp
+++ b/dom/network/UDPSocket.cpp
@@ -367,17 +367,17 @@ UDPSocket::Send(const StringOrBlobOrArra
       data.ComputeLengthAndData();
       aRv = strStream->SetData(reinterpret_cast<const char*>(data.Data()), data.Length());
     }
 
     if (NS_WARN_IF(aRv.Failed())) {
       return false;
     }
 
-    stream = strStream;
+    stream = do_QueryInterface(strStream);
   }
 
   if (mSocket) {
     aRv = mSocket->SendBinaryStream(remoteAddress, remotePort, stream);
   } else if (mSocketChild) {
     aRv = mSocketChild->SendBinaryStream(remoteAddress, remotePort, stream);
   }
 
--- a/dom/plugins/base/nsPluginHost.cpp
+++ b/dom/plugins/base/nsPluginHost.cpp
@@ -575,17 +575,17 @@ nsresult nsPluginHost::PostURL(nsISuppor
     free(dataToPost);
     return rv;
   }
 
   // data allocated by ParsePostBufferToFixHeaders() is managed and
   // freed by the string stream.
   postDataLen = newDataToPostLen;
   sis->AdoptData(dataToPost, postDataLen);
-  postStream = sis;
+  postStream = do_QueryInterface(sis);
 
   if (target) {
     RefPtr<nsPluginInstanceOwner> owner = instance->GetOwner();
     if (owner) {
       rv = owner->GetURL(url, target, postStream,
                          (void*)postHeaders, postHeadersLength, true);
     }
   }
--- a/dom/plugins/base/nsPluginInstanceOwner.cpp
+++ b/dom/plugins/base/nsPluginInstanceOwner.cpp
@@ -20,17 +20,17 @@ using mozilla::DefaultXDisplay;
 #include "nsContentUtils.h"
 #include "nsRect.h"
 #include "nsSize.h"
 #include "nsDisplayList.h"
 #include "ImageLayers.h"
 #include "GLImages.h"
 #include "nsPluginFrame.h"
 #include "nsIPluginDocument.h"
-#include "nsIStringStream.h"
+#include "nsStringStream.h"
 #include "nsNetUtil.h"
 #include "mozilla/Preferences.h"
 #include "nsILinkHandler.h"
 #include "nsIDocShellTreeItem.h"
 #include "nsIWebBrowserChrome.h"
 #include "nsLayoutUtils.h"
 #include "nsIPluginWidget.h"
 #include "nsViewManager.h"
@@ -535,23 +535,21 @@ NS_IMETHODIMP nsPluginInstanceOwner::Get
   nsresult rv = NS_NewURI(getter_AddRefs(uri), aURL, baseURI);
   NS_ENSURE_SUCCESS(rv, NS_ERROR_FAILURE);
 
   nsCOMPtr<nsIInputStream> headersDataStream;
   if (aPostStream && aHeadersData) {
     if (!aHeadersDataLen)
       return NS_ERROR_UNEXPECTED;
 
-    nsCOMPtr<nsIStringInputStream> sis = do_CreateInstance("@mozilla.org/io/string-input-stream;1");
-    if (!sis)
-      return NS_ERROR_OUT_OF_MEMORY;
-
-    rv = sis->SetData((char *)aHeadersData, aHeadersDataLen);
+    rv = NS_NewCStringInputStream(
+      getter_AddRefs(headersDataStream),
+      nsDependentCSubstring(reinterpret_cast<const char*>(aHeadersData),
+                            aHeadersDataLen));
     NS_ENSURE_SUCCESS(rv, rv);
-    headersDataStream = do_QueryInterface(sis);
   }
 
   int32_t blockPopups =
     Preferences::GetInt("privacy.popups.disable_from_plugins");
   nsAutoPopupStatePusher popupStatePusher((PopupControlState)blockPopups);
 
 
   // if security checks (in particular CheckLoadURIWithPrincipal) needs
--- a/dom/presentation/PresentationTCPSessionTransport.cpp
+++ b/dom/presentation/PresentationTCPSessionTransport.cpp
@@ -17,16 +17,17 @@
 #include "nsISupportsPrimitives.h"
 #include "nsNetUtil.h"
 #include "nsQueryObject.h"
 #include "nsServiceManagerUtils.h"
 #include "nsStreamUtils.h"
 #include "nsThreadUtils.h"
 #include "PresentationLog.h"
 #include "PresentationTCPSessionTransport.h"
+#include "nsStringStream.h"
 
 #define BUFFER_SIZE 65536
 
 using namespace mozilla;
 using namespace mozilla::dom;
 
 class CopierCallbacks final : public nsIRequestObserver
 {
@@ -388,26 +389,20 @@ PresentationTCPSessionTransport::NotifyC
 
 NS_IMETHODIMP
 PresentationTCPSessionTransport::Send(const nsAString& aData)
 {
   if (NS_WARN_IF(mReadyState != ReadyState::OPEN)) {
     return NS_ERROR_DOM_INVALID_STATE_ERR;
   }
 
-  nsresult rv;
-  nsCOMPtr<nsIStringInputStream> stream =
-    do_CreateInstance(NS_STRINGINPUTSTREAM_CONTRACTID, &rv);
-  if(NS_WARN_IF(NS_FAILED(rv))) {
-    return NS_ERROR_DOM_INVALID_STATE_ERR;
-  }
-
-  NS_ConvertUTF16toUTF8 msgString(aData);
-  rv = stream->SetData(msgString.BeginReading(), msgString.Length());
-  if(NS_WARN_IF(NS_FAILED(rv))) {
+  nsCOMPtr<nsIInputStream> stream;
+  nsresult rv = NS_NewCStringInputStream(getter_AddRefs(stream),
+                                         NS_ConvertUTF16toUTF8(aData));
+  if (NS_WARN_IF(NS_FAILED(rv))) {
     return NS_ERROR_DOM_INVALID_STATE_ERR;
   }
 
   mMultiplexStream->AppendStream(stream);
 
   EnsureCopying();
 
   return NS_OK;
--- a/dom/security/nsCSPContext.cpp
+++ b/dom/security/nsCSPContext.cpp
@@ -1010,31 +1010,31 @@ nsCSPContext::SendReports(nsISupports* a
     reportChannel->SetNotificationCallbacks(reportSink);
 
     // apply the loadgroup from the channel taken by setRequestContext.  If
     // there's no loadgroup, AsyncOpen will fail on process-split necko (since
     // the channel cannot query the iTabChild).
     rv = reportChannel->SetLoadGroup(mCallingChannelLoadGroup);
     NS_ENSURE_SUCCESS(rv, rv);
 
-    // wire in the string input stream to send the report
-    nsCOMPtr<nsIStringInputStream> sis(do_CreateInstance(NS_STRINGINPUTSTREAM_CONTRACTID));
-    NS_ASSERTION(sis, "nsIStringInputStream is needed but not available to send CSP violation reports");
-    nsAutoCString utf8CSPReport = NS_ConvertUTF16toUTF8(csp_report);
-    rv = sis->SetData(utf8CSPReport.get(), utf8CSPReport.Length());
-    NS_ENSURE_SUCCESS(rv, rv);
-
     nsCOMPtr<nsIUploadChannel> uploadChannel(do_QueryInterface(reportChannel));
     if (!uploadChannel) {
       // It's possible the URI provided can't be uploaded to, in which case
       // we skip this one. We'll already have warned about a non-HTTP URI earlier.
       continue;
     }
 
-    rv = uploadChannel->SetUploadStream(sis, NS_LITERAL_CSTRING("application/csp-report"), -1);
+    // wire in the string input stream to send the report
+    nsCOMPtr<nsIInputStream> stream;
+    rv = NS_NewCStringInputStream(getter_AddRefs(stream),
+                                  NS_ConvertUTF16toUTF8(csp_report));
+    NS_ENSURE_SUCCESS(rv, rv);
+
+    rv = uploadChannel->SetUploadStream(
+      stream, NS_LITERAL_CSTRING("application/csp-report"), -1);
     NS_ENSURE_SUCCESS(rv, rv);
 
     // if this is an HTTP channel, set the request method to post
     nsCOMPtr<nsIHttpChannel> httpChannel(do_QueryInterface(reportChannel));
     if (httpChannel) {
       rv = httpChannel->SetRequestMethod(NS_LITERAL_CSTRING("POST"));
       MOZ_ASSERT(NS_SUCCEEDED(rv));
     }
--- a/image/decoders/icon/android/nsIconChannel.cpp
+++ b/image/decoders/icon/android/nsIconChannel.cpp
@@ -6,16 +6,17 @@
 #include <stdlib.h>
 #include "mozilla/dom/ContentChild.h"
 #include "nsMimeTypes.h"
 #include "nsIURL.h"
 #include "nsXULAppAPI.h"
 #include "AndroidBridge.h"
 #include "nsIconChannel.h"
 #include "nsIStringStream.h"
+#include "nsIInputStream.h"
 #include "nsNetUtil.h"
 #include "nsComponentManagerUtils.h"
 #include "NullPrincipal.h"
 
 NS_IMPL_ISUPPORTS(nsIconChannel,
                   nsIRequest,
                   nsIChannel)
 
@@ -100,23 +101,25 @@ moz_icon_to_channel(nsIURI* aURI, const 
       *(out++) = DO_PREMULTIPLY(b);
       *(out++) = DO_PREMULTIPLY(g);
       *(out++) = DO_PREMULTIPLY(r);
       *(out++) = a;
 #undef DO_PREMULTIPLY
     }
   }
 
-  nsCOMPtr<nsIStringInputStream> stream =
+  nsCOMPtr<nsIStringInputStream> sis =
     do_CreateInstance("@mozilla.org/io/string-input-stream;1", &rv);
   NS_ENSURE_SUCCESS(rv, rv);
 
-  rv = stream->AdoptData((char*)buf, buf_size);
+  rv = sis->AdoptData((char*)buf, buf_size);
   NS_ENSURE_SUCCESS(rv, rv);
 
+  nsCOMPtr<nsIInputStream> stream = do_QueryInterface(sis);
+
   // nsIconProtocolHandler::NewChannel2 will provide the correct loadInfo for
   // this iconChannel. Use the most restrictive security settings for the
   // temporary loadInfo to make sure the channel can not be openend.
   nsCOMPtr<nsIPrincipal> nullPrincipal = NullPrincipal::Create();
   return NS_NewInputStreamChannel(aChannel,
                                   aURI,
                                   stream,
                                   nullPrincipal,
--- a/image/decoders/icon/gtk/nsIconChannel.cpp
+++ b/image/decoders/icon/gtk/nsIconChannel.cpp
@@ -19,16 +19,17 @@
 #include "nsMimeTypes.h"
 #include "nsIMIMEService.h"
 
 #include "nsServiceManagerUtils.h"
 
 #include "nsNetUtil.h"
 #include "nsComponentManagerUtils.h"
 #include "nsIStringStream.h"
+#include "nsIInputStream.h"
 #include "nsServiceManagerUtils.h"
 #include "NullPrincipal.h"
 #include "nsIURL.h"
 #include "prlink.h"
 #include "gfxPlatform.h"
 
 NS_IMPL_ISUPPORTS(nsIconChannel,
                   nsIRequest,
@@ -81,33 +82,35 @@ moz_gdk_pixbuf_to_channel(GdkPixbuf* aPi
 #endif
 #undef DO_PREMULTIPLY
     }
   }
 
   NS_ASSERTION(out == buf + buf_size, "size miscalculation");
 
   nsresult rv;
-  nsCOMPtr<nsIStringInputStream> stream =
+  nsCOMPtr<nsIStringInputStream> sis =
     do_CreateInstance("@mozilla.org/io/string-input-stream;1", &rv);
 
   // Prevent the leaking of buf
   if (NS_WARN_IF(NS_FAILED(rv))) {
     free(buf);
     return rv;
   }
 
   // stream takes ownership of buf and will free it on destruction.
   // This function cannot fail.
-  rv = stream->AdoptData((char*)buf, buf_size);
+  rv = sis->AdoptData((char*)buf, buf_size);
 
   // If this no longer holds then re-examine buf's lifetime.
   MOZ_ASSERT(NS_SUCCEEDED(rv));
   NS_ENSURE_SUCCESS(rv, rv);
 
+  nsCOMPtr<nsIInputStream> stream(do_QueryInterface(sis));
+
   // nsIconProtocolHandler::NewChannel2 will provide the correct loadInfo for
   // this iconChannel. Use the most restrictive security settings for the
   // temporary loadInfo to make sure the channel can not be openend.
   nsCOMPtr<nsIPrincipal> nullPrincipal = NullPrincipal::Create();
   return NS_NewInputStreamChannel(aChannel,
                                   aURI,
                                   stream,
                                   nullPrincipal,
--- a/image/decoders/icon/mac/nsIconChannelCocoa.mm
+++ b/image/decoders/icon/mac/nsIconChannelCocoa.mm
@@ -9,17 +9,17 @@
 #include "mozilla/EndianUtils.h"
 #include "nsIIconURI.h"
 #include "nsIServiceManager.h"
 #include "nsIInterfaceRequestor.h"
 #include "nsIInterfaceRequestorUtils.h"
 #include "nsXPIDLString.h"
 #include "nsMimeTypes.h"
 #include "nsMemory.h"
-#include "nsIStringStream.h"
+#include "nsIInputStream.h"
 #include "nsIURL.h"
 #include "nsNetCID.h"
 #include "nsIPipe.h"
 #include "nsIOutputStream.h"
 #include "nsIMIMEService.h"
 #include "nsCExternalHandlerService.h"
 #include "nsILocalFileMac.h"
 #include "nsIFileURL.h"
--- a/image/decoders/icon/win/nsIconChannel.cpp
+++ b/image/decoders/icon/win/nsIconChannel.cpp
@@ -10,17 +10,17 @@
 #include "nsIIconURI.h"
 #include "nsIServiceManager.h"
 #include "nsIInterfaceRequestor.h"
 #include "nsIInterfaceRequestorUtils.h"
 #include "nsXPIDLString.h"
 #include "nsReadableUtils.h"
 #include "nsMimeTypes.h"
 #include "nsMemory.h"
-#include "nsIStringStream.h"
+#include "nsIInputStream.h"
 #include "nsIURL.h"
 #include "nsIOutputStream.h"
 #include "nsIPipe.h"
 #include "nsNetCID.h"
 #include "nsIFile.h"
 #include "nsIFileURL.h"
 #include "nsIMIMEService.h"
 #include "nsCExternalHandlerService.h"
--- a/intl/uconv/nsScriptableUConv.cpp
+++ b/intl/uconv/nsScriptableUConv.cpp
@@ -3,16 +3,17 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "nsString.h"
 #include "nsIScriptableUConv.h"
 #include "nsScriptableUConv.h"
 #include "nsIStringStream.h"
+#include "nsIInputStream.h"
 #include "nsComponentManagerUtils.h"
 
 using namespace mozilla;
 
 /* Implementation file */
 NS_IMPL_ISUPPORTS(nsScriptableUnicodeConverter, nsIScriptableUnicodeConverter)
 
 nsScriptableUnicodeConverter::nsScriptableUnicodeConverter()
@@ -228,18 +229,17 @@ nsScriptableUnicodeConverter::ConvertToI
     return rv;
 
   rv = inputStream->AdoptData(reinterpret_cast<char*>(data), dataLen);
   if (NS_FAILED(rv)) {
     free(data);
     return rv;
   }
 
-  NS_ADDREF(*_retval = inputStream);
-  return rv;
+  return CallQueryInterface(inputStream, _retval);
 }
 
 NS_IMETHODIMP
 nsScriptableUnicodeConverter::GetCharset(nsACString& aCharset)
 {
   if (!mDecoder) {
     aCharset.Truncate();
   } else {
--- a/netwerk/base/nsNetUtil.cpp
+++ b/netwerk/base/nsNetUtil.cpp
@@ -617,25 +617,21 @@ NS_NewInputStreamChannel(nsIChannel     
 nsresult
 NS_NewInputStreamChannelInternal(nsIChannel        **outChannel,
                                  nsIURI             *aUri,
                                  const nsAString    &aData,
                                  const nsACString   &aContentType,
                                  nsILoadInfo        *aLoadInfo,
                                  bool                aIsSrcdocChannel /* = false */)
 {
-  nsresult rv;
-  nsCOMPtr<nsIStringInputStream> stream;
-  stream = do_CreateInstance(NS_STRINGINPUTSTREAM_CONTRACTID, &rv);
+  nsCOMPtr<nsIInputStream> stream;
+  nsresult rv = NS_NewCStringInputStream(getter_AddRefs(stream),
+                                         NS_ConvertUTF16toUTF8(aData));
   NS_ENSURE_SUCCESS(rv, rv);
 
-    uint32_t len;
-    char* utf8Bytes = ToNewUTF8String(aData, &len);
-    rv = stream->AdoptData(utf8Bytes, len);
-
   nsCOMPtr<nsIChannel> channel;
   rv = NS_NewInputStreamChannelInternal(getter_AddRefs(channel),
                                         aUri,
                                         stream,
                                         aContentType,
                                         NS_LITERAL_CSTRING("UTF-8"),
                                         aLoadInfo);
 
@@ -1449,22 +1445,18 @@ NS_NewPostDataStream(nsIInputStream  **r
                 // wrap the file stream with a buffered input stream
                 rv = NS_NewBufferedInputStream(result, fileStream, 8192);
             }
         }
         return rv;
     }
 
     // otherwise, create a string stream for the data (copies)
-    nsCOMPtr<nsIStringInputStream> stream
-        (do_CreateInstance("@mozilla.org/io/string-input-stream;1", &rv));
-    if (NS_FAILED(rv))
-        return rv;
-
-    rv = stream->SetData(data.BeginReading(), data.Length());
+    nsCOMPtr<nsIInputStream> stream;
+    rv = NS_NewCStringInputStream(getter_AddRefs(stream), data);
     if (NS_FAILED(rv))
         return rv;
 
     stream.forget(result);
     return NS_OK;
 }
 
 nsresult
--- a/netwerk/streamconv/converters/nsHTTPCompressConv.cpp
+++ b/netwerk/streamconv/converters/nsHTTPCompressConv.cpp
@@ -512,17 +512,18 @@ nsHTTPCompressConv::do_OnDataAvailable(n
 
   mStream->ShareData(buffer, count);
 
   nsCOMPtr<nsIStreamListener> listener;
   {
     MutexAutoLock lock(mMutex);
     listener = mListener;
   }
-  nsresult rv = listener->OnDataAvailable(request, context, mStream,
+  nsCOMPtr<nsIInputStream> stream(do_QueryInterface(mStream));
+  nsresult rv = listener->OnDataAvailable(request, context, stream,
                                           offset, count);
 
   // Make sure the stream no longer references |buffer| in case our listener
   // is crazy enough to try to read from |mStream| after ODA.
   mStream->ShareData("", 0);
   mDecodedDataLength += count;
 
   return rv;
--- a/netwerk/streamconv/converters/nsUnknownDecoder.cpp
+++ b/netwerk/streamconv/converters/nsUnknownDecoder.cpp
@@ -760,29 +760,25 @@ nsUnknownDecoder::ConvertEncodedData(nsI
 
     if (NS_FAILED(rv)) {
       return rv;
     }
 
     if (listener) {
       listener->OnStartRequest(request, nullptr);
 
-      nsCOMPtr<nsIStringInputStream> rawStream =
-        do_CreateInstance(NS_STRINGINPUTSTREAM_CONTRACTID);
-      if (!rawStream)
-        return NS_ERROR_FAILURE;
+      nsCOMPtr<nsIInputStream> rawStream;
+      rv = NS_NewCStringInputStream(getter_AddRefs(rawStream),
+                                    nsDependentCSubstring(data, length));
+      if (NS_SUCCEEDED(rv)) {
+        rv = listener->OnDataAvailable(request, nullptr, rawStream, 0,
+                                       length);
+      }
 
-      rv = rawStream->SetData((const char*)data, length);
-      NS_ENSURE_SUCCESS(rv, rv);
-
-      rv = listener->OnDataAvailable(request, nullptr, rawStream, 0,
-                                     length);
-      NS_ENSURE_SUCCESS(rv, rv);
-
-      listener->OnStopRequest(request, nullptr, NS_OK);
+      listener->OnStopRequest(request, nullptr, rv);
     }
   }
   return rv;
 }
 
 void
 nsBinaryDetector::DetermineContentType(nsIRequest* aRequest)
 {
--- a/startupcache/StartupCache.cpp
+++ b/startupcache/StartupCache.cpp
@@ -370,27 +370,28 @@ struct CacheWriteHolder
 
 static void
 CacheCloseHelper(const nsACString& key, const CacheEntry* data,
                  const CacheWriteHolder* holder)
 {
   MOZ_ASSERT(data); // assert key was found in mTable.
 
   nsresult rv;
-  nsIStringInputStream* stream = holder->stream;
+  nsIStringInputStream* sis = holder->stream;
   nsIZipWriter* writer = holder->writer;
 
-  stream->ShareData(data->data.get(), data->size);
+  sis->ShareData(data->data.get(), data->size);
 
 #ifdef DEBUG
   bool hasEntry;
   rv = writer->HasEntry(key, &hasEntry);
   NS_ASSERTION(NS_SUCCEEDED(rv) && hasEntry == false, 
                "Existing entry in disk StartupCache.");
 #endif
+  nsCOMPtr<nsIInputStream> stream(do_QueryInterface(sis));
   rv = writer->AddEntryStream(key, holder->time, true, stream, false);
 
   if (NS_FAILED(rv)) {
     NS_WARNING("cache entry deleted but not written to disk.");
   }
 }
 
 
--- a/startupcache/StartupCacheUtils.cpp
+++ b/startupcache/StartupCacheUtils.cpp
@@ -26,17 +26,18 @@ NewObjectInputStreamFromBuffer(UniquePtr
     do_CreateInstance("@mozilla.org/io/string-input-stream;1");
   NS_ENSURE_TRUE(stringStream, NS_ERROR_FAILURE);
 
   nsCOMPtr<nsIObjectInputStream> objectInput =
     do_CreateInstance("@mozilla.org/binaryinputstream;1");
   NS_ENSURE_TRUE(objectInput, NS_ERROR_FAILURE);
 
   stringStream->AdoptData(buffer.release(), len);
-  objectInput->SetInputStream(stringStream);
+  nsCOMPtr<nsIInputStream> baseStream(do_QueryInterface(stringStream));
+  objectInput->SetInputStream(baseStream);
 
   objectInput.forget(stream);
   return NS_OK;
 }
 
 nsresult
 NewObjectOutputWrappedStorageStream(nsIObjectOutputStream **wrapperStream,
                                     nsIStorageStream** stream,
--- a/toolkit/components/downloads/ApplicationReputation.cpp
+++ b/toolkit/components/downloads/ApplicationReputation.cpp
@@ -1358,16 +1358,19 @@ PendingLookup::SendRemoteQueryInternal()
   // Set the input stream to the serialized protocol buffer
   nsCOMPtr<nsIStringInputStream> sstream =
     do_CreateInstance("@mozilla.org/io/string-input-stream;1", &rv);
   NS_ENSURE_SUCCESS(rv, rv);
 
   rv = sstream->SetData(serialized.c_str(), serialized.length());
   NS_ENSURE_SUCCESS(rv, rv);
 
+
+  nsCOMPtr<nsIInputStream> stream(do_QueryInterface(sstream));
+
   // Set up the channel to transmit the request to the service.
   nsCOMPtr<nsIIOService> ios = do_GetService(NS_IOSERVICE_CONTRACTID, &rv);
   rv = ios->NewChannel2(serviceUrl,
                         nullptr,
                         nullptr,
                         nullptr, // aLoadingNode
                         nsContentUtils::GetSystemPrincipal(),
                         nullptr, // aTriggeringPrincipal
@@ -1386,17 +1389,17 @@ PendingLookup::SendRemoteQueryInternal()
   nsCOMPtr<nsIHttpChannel> httpChannel(do_QueryInterface(mChannel, &rv));
   NS_ENSURE_SUCCESS(rv, rv);
   mozilla::Unused << httpChannel;
 
   // Upload the protobuf to the application reputation service.
   nsCOMPtr<nsIUploadChannel2> uploadChannel = do_QueryInterface(mChannel, &rv);
   NS_ENSURE_SUCCESS(rv, rv);
 
-  rv = uploadChannel->ExplicitSetUploadStream(sstream,
+  rv = uploadChannel->ExplicitSetUploadStream(stream,
     NS_LITERAL_CSTRING("application/octet-stream"), serialized.size(),
     NS_LITERAL_CSTRING("POST"), false);
   NS_ENSURE_SUCCESS(rv, rv);
 
   uint32_t timeoutMs = Preferences::GetUint(PREF_SB_DOWNLOADS_REMOTE_TIMEOUT, 10000);
   mTimeoutTimer = do_CreateInstance(NS_TIMER_CONTRACTID);
   mTimeoutTimer->InitWithCallback(this, timeoutMs, nsITimer::TYPE_ONE_SHOT);
 
--- a/toolkit/components/url-classifier/nsUrlClassifierStreamUpdater.cpp
+++ b/toolkit/components/url-classifier/nsUrlClassifierStreamUpdater.cpp
@@ -541,23 +541,19 @@ nsUrlClassifierStreamUpdater::UpdateErro
   }
 
   return NS_OK;
 }
 
 nsresult
 nsUrlClassifierStreamUpdater::AddRequestBody(const nsACString &aRequestBody)
 {
-  nsresult rv;
-  nsCOMPtr<nsIStringInputStream> strStream =
-    do_CreateInstance(NS_STRINGINPUTSTREAM_CONTRACTID, &rv);
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  rv = strStream->SetData(aRequestBody.BeginReading(),
-                          aRequestBody.Length());
+  nsCOMPtr<nsIInputStream> strStream;
+  nsresult rv = NS_NewCStringInputStream(getter_AddRefs(strStream),
+                                         aRequestBody);
   NS_ENSURE_SUCCESS(rv, rv);
 
   nsCOMPtr<nsIUploadChannel> uploadChannel = do_QueryInterface(mChannel, &rv);
   NS_ENSURE_SUCCESS(rv, rv);
 
   rv = uploadChannel->SetUploadStream(strStream,
                                       NS_LITERAL_CSTRING("text/plain"),
                                       -1);
--- a/xpcom/io/nsIStringStream.idl
+++ b/xpcom/io/nsIStringStream.idl
@@ -1,29 +1,29 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
-#include "nsIInputStream.idl"
+#include "nsISupports.idl"
 
 %{C++
 #include "mozilla/MemoryReporting.h"
 %}
 
 native MallocSizeOf(mozilla::MallocSizeOf);
 
 /**
  * nsIStringInputStream
  *
  * Provides scriptable and specialized C++-only methods for initializing a
  * nsIInputStream implementation with a simple character array.
  */
 [scriptable, builtinclass, uuid(450cd2d4-f0fd-424d-b365-b1251f80fd53)]
-interface nsIStringInputStream : nsIInputStream
+interface nsIStringInputStream : nsISupports
 {
     /**
      * SetData - assign data to the input stream (copied on assignment).
      *
      * @param data    - stream data
      * @param dataLen - stream data length (-1 if length should be computed)
      *
      * NOTE: C++ code should consider using AdoptData or ShareData to avoid
--- a/xpcom/io/nsStringStream.cpp
+++ b/xpcom/io/nsStringStream.cpp
@@ -29,16 +29,17 @@ using mozilla::Maybe;
 using mozilla::Some;
 
 //-----------------------------------------------------------------------------
 // nsIStringInputStream implementation
 //-----------------------------------------------------------------------------
 
 class nsStringInputStream final
   : public nsIStringInputStream
+  , public nsIInputStream
   , public nsISeekableStream
   , public nsISupportsCString
   , public nsIIPCSerializableInputStream
   , public nsICloneableInputStream
 {
 public:
   NS_DECL_THREADSAFE_ISUPPORTS
   NS_DECL_NSIINPUTSTREAM
--- a/xpcom/io/nsStringStream.h
+++ b/xpcom/io/nsStringStream.h
@@ -3,16 +3,17 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef nsStringStream_h__
 #define nsStringStream_h__
 
 #include "nsIStringStream.h"
+#include "nsIInputStream.h"
 #include "nsStringGlue.h"
 #include "nsMemory.h"
 
 /**
  * Implements:
  *   nsIStringInputStream
  *   nsIInputStream
  *   nsISeekableStream