Bug 1466023 - Get rid of NS_GetStreamForBlobURI, r=qdot
authorAndrea Marchesini <amarchesini@mozilla.com>
Sat, 02 Jun 2018 15:51:41 +0200
changeset 420980 a42190f5c8b5501e40fde091c86c8bbbd20f0b66
parent 420979 db700985e1bedd652e9b80b5c86fcdc74e04b92f
child 420981 29fbb29690f925bb99c2ddea6b1a43a063dea317
push id34083
push userapavel@mozilla.com
push dateSat, 02 Jun 2018 23:03:25 +0000
treeherdermozilla-central@1f62ecdf59b6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersqdot
bugs1466023
milestone62.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 1466023 - Get rid of NS_GetStreamForBlobURI, r=qdot
dom/file/nsHostObjectProtocolHandler.cpp
dom/file/nsHostObjectProtocolHandler.h
dom/media/FileMediaResource.cpp
--- a/dom/file/nsHostObjectProtocolHandler.cpp
+++ b/dom/file/nsHostObjectProtocolHandler.cpp
@@ -1035,34 +1035,16 @@ NS_GetBlobForBlobURISpec(const nsACStrin
     return NS_ERROR_DOM_BAD_URI;
   }
 
   RefPtr<BlobImpl> blob = info->mBlobImpl;
   blob.forget(aBlob);
   return NS_OK;
 }
 
-nsresult
-NS_GetStreamForBlobURI(nsIURI* aURI, nsIInputStream** aStream)
-{
-  RefPtr<BlobImpl> blobImpl;
-  ErrorResult rv;
-  rv = NS_GetBlobForBlobURI(aURI, getter_AddRefs(blobImpl));
-  if (NS_WARN_IF(rv.Failed())) {
-    return rv.StealNSResult();
-  }
-
-  blobImpl->CreateInputStream(aStream, rv);
-  if (NS_WARN_IF(rv.Failed())) {
-    return rv.StealNSResult();
-  }
-
-  return NS_OK;
-}
-
 NS_IMETHODIMP
 nsFontTableProtocolHandler::NewURI(const nsACString& aSpec,
                                    const char *aCharset,
                                    nsIURI *aBaseURI,
                                    nsIURI **aResult)
 {
   nsresult rv;
   nsCOMPtr<nsIURI> uri;
--- a/dom/file/nsHostObjectProtocolHandler.h
+++ b/dom/file/nsHostObjectProtocolHandler.h
@@ -128,14 +128,11 @@ inline bool IsFontTableURI(nsIURI* aUri)
 
 extern nsresult
 NS_GetBlobForBlobURI(nsIURI* aURI, mozilla::dom::BlobImpl** aBlob, bool aAlsoIfRevoked = false);
 
 extern nsresult
 NS_GetBlobForBlobURISpec(const nsACString& aSpec, mozilla::dom::BlobImpl** aBlob);
 
 extern nsresult
-NS_GetStreamForBlobURI(nsIURI* aURI, nsIInputStream** aStream);
-
-extern nsresult
 NS_GetSourceForMediaSourceURI(nsIURI* aURI, mozilla::dom::MediaSource** aSource);
 
 #endif /* nsHostObjectProtocolHandler_h */
--- a/dom/media/FileMediaResource.cpp
+++ b/dom/media/FileMediaResource.cpp
@@ -1,16 +1,17 @@
 /* vim:set ts=2 sw=2 sts=2 et cindent: */
 /* 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 "FileMediaResource.h"
 
 #include "mozilla/AbstractThread.h"
+#include "mozilla/dom/BlobImpl.h"
 #include "nsContentUtils.h"
 #include "nsHostObjectProtocolHandler.h"
 #include "nsIFileChannel.h"
 #include "nsIFileStreams.h"
 #include "nsNetUtil.h"
 
 namespace mozilla {
 
@@ -70,22 +71,30 @@ FileMediaResource::Open(nsIStreamListene
   nsCOMPtr<nsIFileChannel> fc(do_QueryInterface(mChannel));
   if (fc) {
     nsCOMPtr<nsIFile> file;
     rv = fc->GetFile(getter_AddRefs(file));
     NS_ENSURE_SUCCESS(rv, rv);
 
     rv = NS_NewLocalFileInputStream(
       getter_AddRefs(mInput), file, -1, -1, nsIFileInputStream::SHARE_DELETE);
+    NS_ENSURE_SUCCESS(rv, rv);
   } else if (IsBlobURI(mURI)) {
-    rv = NS_GetStreamForBlobURI(mURI, getter_AddRefs(mInput));
+    RefPtr<dom::BlobImpl> blobImpl;
+    rv = NS_GetBlobForBlobURI(mURI, getter_AddRefs(blobImpl));
+    NS_ENSURE_SUCCESS(rv, rv);
+    MOZ_ASSERT(blobImpl);
+
+    ErrorResult err;
+    blobImpl->CreateInputStream(getter_AddRefs(mInput), err);
+    if (NS_WARN_IF(err.Failed())) {
+      return err.StealNSResult();
+    }
   }
 
-  NS_ENSURE_SUCCESS(rv, rv);
-
   mSeekable = do_QueryInterface(mInput);
   if (!mSeekable) {
     // XXX The file may just be a .url or similar
     // shortcut that points to a Web site. We need to fix this by
     // doing an async open and waiting until we locate the real resource,
     // then using that (if it's still a file!).
     return NS_ERROR_FAILURE;
   }