Bug 1466023 - Remove an internal parameter only in NS_GetBlobForBlobURI, r=qdot
authorAndrea Marchesini <amarchesini@mozilla.com>
Sat, 02 Jun 2018 15:51:41 +0200
changeset 420981 29fbb29690f925bb99c2ddea6b1a43a063dea317
parent 420980 a42190f5c8b5501e40fde091c86c8bbbd20f0b66
child 420982 3ad2d9f4b20372c952f5525f0440769bdc5ccc1a
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 - Remove an internal parameter only in NS_GetBlobForBlobURI, r=qdot
dom/file/nsHostObjectProtocolHandler.cpp
dom/file/nsHostObjectProtocolHandler.h
--- a/dom/file/nsHostObjectProtocolHandler.cpp
+++ b/dom/file/nsHostObjectProtocolHandler.cpp
@@ -886,40 +886,36 @@ nsHostObjectProtocolHandler::NewURI(cons
 
 NS_IMETHODIMP
 nsHostObjectProtocolHandler::NewChannel2(nsIURI* uri,
                                          nsILoadInfo* aLoadInfo,
                                          nsIChannel** result)
 {
   *result = nullptr;
 
-  RefPtr<BlobImpl> blobImpl;
-  NS_GetBlobForBlobURI(uri, getter_AddRefs(blobImpl), true);
-  if (!blobImpl) {
+  DataInfo* info = GetDataInfoFromURI(uri, true /*aAlsoIfRevoked */);
+  if (!info || info->mObjectType != DataInfo::eBlobImpl || !info->mBlobImpl) {
     return NS_ERROR_DOM_BAD_URI;
   }
 
+  RefPtr<BlobImpl> blobImpl = info->mBlobImpl;
   nsCOMPtr<nsIURIWithPrincipal> uriPrinc = do_QueryInterface(uri);
   if (!uriPrinc) {
     return NS_ERROR_DOM_BAD_URI;
   }
 
   nsCOMPtr<nsIPrincipal> principal;
   nsresult rv = uriPrinc->GetPrincipal(getter_AddRefs(principal));
   NS_ENSURE_SUCCESS(rv, rv);
 
   if (!principal) {
     return NS_ERROR_DOM_BAD_URI;
   }
 
-#ifdef DEBUG
-  // Info can be null, in case this blob URL has been revoked already.
-  DataInfo* info = GetDataInfoFromURI(uri);
-  MOZ_ASSERT_IF(info, info->mPrincipal == principal);
-#endif
+  MOZ_ASSERT(info->mPrincipal == principal);
 
   // We want to be sure that we stop the creation of the channel if the blob URL
   // is copy-and-pasted on a different context (ex. private browsing or
   // containers).
   //
   // We also allow the system principal to create the channel regardless of the
   // OriginAttributes.  This is primarily for the benefit of mechanisms like
   // the Download API that explicitly create a channel with the system
@@ -1006,21 +1002,21 @@ nsFontTableProtocolHandler::GetProtocolF
 NS_IMETHODIMP
 nsFontTableProtocolHandler::GetScheme(nsACString &result)
 {
   result.AssignLiteral(FONTTABLEURI_SCHEME);
   return NS_OK;
 }
 
 nsresult
-NS_GetBlobForBlobURI(nsIURI* aURI, BlobImpl** aBlob, bool aAlsoIfRevoked)
+NS_GetBlobForBlobURI(nsIURI* aURI, BlobImpl** aBlob)
 {
   *aBlob = nullptr;
 
-  DataInfo* info = GetDataInfoFromURI(aURI, aAlsoIfRevoked);
+  DataInfo* info = GetDataInfoFromURI(aURI, false /* aAlsoIfRevoked */);
   if (!info || info->mObjectType != DataInfo::eBlobImpl) {
     return NS_ERROR_DOM_BAD_URI;
   }
 
   RefPtr<BlobImpl> blob = info->mBlobImpl;
   blob.forget(aBlob);
   return NS_OK;
 }
--- a/dom/file/nsHostObjectProtocolHandler.h
+++ b/dom/file/nsHostObjectProtocolHandler.h
@@ -122,17 +122,17 @@ inline bool IsRtspURI(nsIURI* aUri)
 
 inline bool IsFontTableURI(nsIURI* aUri)
 {
   bool isFont;
   return NS_SUCCEEDED(aUri->SchemeIs(FONTTABLEURI_SCHEME, &isFont)) && isFont;
 }
 
 extern nsresult
-NS_GetBlobForBlobURI(nsIURI* aURI, mozilla::dom::BlobImpl** aBlob, bool aAlsoIfRevoked = false);
+NS_GetBlobForBlobURI(nsIURI* aURI, mozilla::dom::BlobImpl** aBlob);
 
 extern nsresult
 NS_GetBlobForBlobURISpec(const nsACString& aSpec, mozilla::dom::BlobImpl** aBlob);
 
 extern nsresult
 NS_GetSourceForMediaSourceURI(nsIURI* aURI, mozilla::dom::MediaSource** aSource);
 
 #endif /* nsHostObjectProtocolHandler_h */