Bug 1218029 - Implements progressive Unicode chars decoding in nsScriptLoader. r=djvj
authorYury Delendik <ydelendik@mozilla.com>
Mon, 30 Nov 2015 08:54:52 -0600
changeset 275117 2bb2a3f0fb90
parent 275116 7a7adc1f24f8
child 275118 3b624179e13b
push id29747
push usercbook@mozilla.com
push dateWed, 02 Dec 2015 14:21:19 +0000
treeherdermozilla-central@f6ac392322b3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdjvj
bugs1218029
milestone45.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 1218029 - Implements progressive Unicode chars decoding in nsScriptLoader. r=djvj
dom/base/nsScriptLoader.cpp
dom/base/nsScriptLoader.h
dom/security/SRICheck.cpp
dom/security/SRICheck.h
--- a/dom/base/nsScriptLoader.cpp
+++ b/dom/base/nsScriptLoader.cpp
@@ -9,17 +9,16 @@
  */
 
 #include "nsScriptLoader.h"
 
 #include "prsystem.h"
 #include "jsapi.h"
 #include "jsfriendapi.h"
 #include "xpcpublic.h"
-#include "nsIUnicodeDecoder.h"
 #include "nsIContent.h"
 #include "nsJSUtils.h"
 #include "mozilla/dom/ScriptSettings.h"
 #include "mozilla/dom/Element.h"
 #include "nsGkAtoms.h"
 #include "nsNetUtil.h"
 #include "nsIScriptGlobalObject.h"
 #include "nsIScriptContext.h"
@@ -49,17 +48,16 @@
 #include "nsSandboxFlags.h"
 #include "nsContentTypeParser.h"
 #include "nsINetworkPredictor.h"
 #include "ImportManager.h"
 #include "mozilla/dom/EncodingUtils.h"
 
 #include "mozilla/Attributes.h"
 #include "mozilla/unused.h"
-#include "mozilla/dom/SRICheck.h"
 #include "nsIScriptError.h"
 
 using namespace mozilla;
 using namespace mozilla::dom;
 
 static LazyLogModule gCspPRLog("CSP");
 
 static LogModule*
@@ -347,17 +345,23 @@ nsScriptLoader::StartLoad(nsScriptLoadRe
       nsINetworkPredictor::LEARN_LOAD_SUBRESOURCE, loadContext);
 
   // Set the initiator type
   nsCOMPtr<nsITimedChannel> timedChannel(do_QueryInterface(httpChannel));
   if (timedChannel) {
     timedChannel->SetInitiatorType(NS_LITERAL_STRING("script"));
   }
 
-  RefPtr<nsScriptLoadHandler> handler = new nsScriptLoadHandler(this, aRequest);
+  nsAutoPtr<mozilla::dom::SRICheckDataVerifier> sriDataVerifier;
+  if (!aRequest->mIntegrity.IsEmpty()) {
+    sriDataVerifier = new SRICheckDataVerifier(aRequest->mIntegrity, mDocument);
+  }
+
+  RefPtr<nsScriptLoadHandler> handler =
+      new nsScriptLoadHandler(this, aRequest, sriDataVerifier.forget());
 
   nsCOMPtr<nsIIncrementalStreamLoader> loader;
   rv = NS_NewIncrementalStreamLoader(getter_AddRefs(loader), handler);
   NS_ENSURE_SUCCESS(rv, rv);
 
   return channel->AsyncOpen2(loader);
 }
 
@@ -1405,30 +1409,43 @@ nsScriptLoader::ConvertToUTF16(nsIChanne
     aLengthOut = 0;
   }
   return rv;
 }
 
 nsresult
 nsScriptLoader::OnStreamComplete(nsIIncrementalStreamLoader* aLoader,
                                  nsISupports* aContext,
-                                 nsresult aStatus,
-                                 uint32_t aStringLen,
-                                 const uint8_t* aString)
+                                 nsresult aChannelStatus,
+                                 nsresult aSRIStatus,
+                                 mozilla::Vector<char16_t> &aString,
+                                 mozilla::dom::SRICheckDataVerifier* aSRIDataVerifier)
 {
   nsScriptLoadRequest* request = static_cast<nsScriptLoadRequest*>(aContext);
   NS_ASSERTION(request, "null request in stream complete handler");
   NS_ENSURE_TRUE(request, NS_ERROR_FAILURE);
 
-  nsresult rv = NS_ERROR_SRI_CORRUPT;
-  if (request->mIntegrity.IsEmpty() ||
-      NS_SUCCEEDED(SRICheck::VerifyIntegrity(request->mIntegrity, aLoader,
-                                             request->mCORSMode, aStringLen,
-                                             aString, mDocument))) {
-    rv = PrepareLoadedRequest(request, aLoader, aStatus, aStringLen, aString);
+  nsresult rv = NS_OK;
+  if (!request->mIntegrity.IsEmpty() &&
+      NS_SUCCEEDED((rv = aSRIStatus))) {
+    MOZ_ASSERT(aSRIDataVerifier);
+
+    nsCOMPtr<nsIRequest> channelRequest;
+    aLoader->GetRequest(getter_AddRefs(channelRequest));
+    nsCOMPtr<nsIChannel> channel;
+    channel = do_QueryInterface(channelRequest);
+
+    if (NS_FAILED(aSRIDataVerifier->Verify(request->mIntegrity, channel,
+                                           request->mCORSMode, mDocument))) {
+      rv = NS_ERROR_SRI_CORRUPT;
+    }
+  }
+
+  if (NS_SUCCEEDED(rv)) {
+    rv = PrepareLoadedRequest(request, aLoader, aChannelStatus, aString);
   }
 
   if (NS_FAILED(rv)) {
     /*
      * Handle script not loading error because source was a tracking URL.
      * We make a note of this script node by including it in a dedicated
      * array of blocked tracking nodes under its parent document.
      */
@@ -1461,26 +1478,22 @@ nsScriptLoader::OnStreamComplete(nsIIncr
     } else if (mParserBlockingRequest == request) {
       mParserBlockingRequest = nullptr;
       UnblockParser(request);
       FireScriptAvailable(rv, request);
       ContinueParserAsync(request);
     } else {
       mPreloads.RemoveElement(request, PreloadRequestComparator());
     }
-    rv = NS_OK;
-  } else {
-    free(const_cast<uint8_t *>(aString));
-    rv = NS_SUCCESS_ADOPTED_DATA;
   }
 
   // Process our request and/or any pending ones
   ProcessPendingRequests();
 
-  return rv;
+  return NS_OK;
 }
 
 void
 nsScriptLoader::UnblockParser(nsScriptLoadRequest* aParserBlockingRequest)
 {
   aParserBlockingRequest->mElement->UnblockParser();
 }
 
@@ -1501,18 +1514,17 @@ nsScriptLoader::NumberOfProcessors()
     mNumberOfProcessors = numProcs;
   return mNumberOfProcessors;
 }
 
 nsresult
 nsScriptLoader::PrepareLoadedRequest(nsScriptLoadRequest* aRequest,
                                      nsIIncrementalStreamLoader* aLoader,
                                      nsresult aStatus,
-                                     uint32_t aStringLen,
-                                     const uint8_t* aString)
+                                     mozilla::Vector<char16_t> &aString)
 {
   if (NS_FAILED(aStatus)) {
     return aStatus;
   }
 
   if (aRequest->IsCanceled()) {
     return NS_BINDING_ABORTED;
   }
@@ -1550,31 +1562,19 @@ nsScriptLoader::PrepareLoadedRequest(nsS
   // separate origin principal, so that it will treat our document's
   // principal as the origin principal
   if (aRequest->mCORSMode == CORS_NONE) {
     rv = nsContentUtils::GetSecurityManager()->
       GetChannelResultPrincipal(channel, getter_AddRefs(aRequest->mOriginPrincipal));
     NS_ENSURE_SUCCESS(rv, rv);
   }
 
-  if (aStringLen) {
-    // Check the charset attribute to determine script charset.
-    nsAutoString hintCharset;
-    if (!aRequest->IsPreload()) {
-      aRequest->mElement->GetScriptCharset(hintCharset);
-    } else {
-      nsTArray<PreloadInfo>::index_type i =
-        mPreloads.IndexOf(aRequest, 0, PreloadRequestComparator());
-      NS_ASSERTION(i != mPreloads.NoIndex, "Incorrect preload bookkeeping");
-      hintCharset = mPreloads[i].mCharset;
-    }
-    rv = ConvertToUTF16(channel, aString, aStringLen, hintCharset, mDocument,
-                        aRequest->mScriptTextBuf, aRequest->mScriptTextLength);
-
-    NS_ENSURE_SUCCESS(rv, rv);
+  if (!aString.empty()) {
+    aRequest->mScriptTextLength = aString.length();
+    aRequest->mScriptTextBuf = aString.extractRawBuffer();
   }
 
   // This assertion could fire errorously if we ran out of memory when
   // inserting the request in the array. However it's an unlikely case
   // so if you see this assertion it is likely something else that is
   // wrong, especially if you see it more than once.
   NS_ASSERTION(mDeferRequests.Contains(aRequest) ||
                mLoadingAsyncRequests.Contains(aRequest) ||
@@ -1709,40 +1709,191 @@ nsScriptLoader::MaybeRemovedDeferRequest
   return false;
 }
 
 //////////////////////////////////////////////////////////////
 //
 //////////////////////////////////////////////////////////////
 
 nsScriptLoadHandler::nsScriptLoadHandler(nsScriptLoader *aScriptLoader,
-                                         nsScriptLoadRequest *aRequest)
+                                         nsScriptLoadRequest *aRequest,
+                                         mozilla::dom::SRICheckDataVerifier *aSRIDataVerifier)
   : mScriptLoader(aScriptLoader),
-    mRequest(aRequest)
+    mRequest(aRequest),
+    mSRIDataVerifier(aSRIDataVerifier),
+    mSRIStatus(NS_OK),
+    mDecoder(),
+    mBuffer()
 {}
 
 nsScriptLoadHandler::~nsScriptLoadHandler()
 {}
 
 NS_IMPL_ISUPPORTS(nsScriptLoadHandler, nsIIncrementalStreamLoaderObserver)
 
 NS_IMETHODIMP
 nsScriptLoadHandler::OnIncrementalData(nsIIncrementalStreamLoader* aLoader,
                                        nsISupports* aContext,
                                        uint32_t aDataLength,
                                        const uint8_t* aData,
                                        uint32_t *aConsumedLength)
 {
+  if (mRequest->IsCanceled()) {
+    // If request cancelled, ignore any incoming data.
+    *aConsumedLength = aDataLength;
+    return NS_OK;
+  }
+
+  if (!EnsureDecoder(aLoader, aData, aDataLength,
+                     /* aEndOfStream = */ false)) {
+    return NS_OK;
+  }
+
+  // Below we will/shall consume entire data chunk.
+  *aConsumedLength = aDataLength;
+
+  // Decoder has already been initialized. -- trying to decode all loaded bytes.
+  nsresult rv = TryDecodeRawData(aData, aDataLength,
+                                 /* aEndOfStream = */ false);
+  NS_ENSURE_SUCCESS(rv, rv);
+
+  // If SRI is required for this load, appending new bytes to the hash.
+  if (mSRIDataVerifier && NS_SUCCEEDED(mSRIStatus)) {
+    mSRIStatus = mSRIDataVerifier->Update(aDataLength, aData);
+  }
+
+  return rv;
+}
+
+nsresult
+nsScriptLoadHandler::TryDecodeRawData(const uint8_t* aData,
+                                      uint32_t aDataLength,
+                                      bool aEndOfStream)
+{
+  int32_t srcLen = aDataLength;
+  const char* src = reinterpret_cast<const char *>(aData);
+  int32_t dstLen;
+  nsresult rv =
+    mDecoder->GetMaxLength(src, srcLen, &dstLen);
+
+  NS_ENSURE_SUCCESS(rv, rv);
+
+  uint32_t haveRead = mBuffer.length();
+  uint32_t capacity = haveRead + dstLen;
+  if (!mBuffer.reserve(capacity)) {
+    return NS_ERROR_OUT_OF_MEMORY;
+  }
+
+  rv = mDecoder->Convert(src,
+                      &srcLen,
+                      mBuffer.begin() + haveRead,
+                      &dstLen);
+
+  NS_ENSURE_SUCCESS(rv, rv);
+
+  haveRead += dstLen;
+  MOZ_ASSERT(haveRead <= capacity, "mDecoder produced more data than expected");
+  mBuffer.resizeUninitialized(haveRead);
+
   return NS_OK;
 }
 
+bool
+nsScriptLoadHandler::EnsureDecoder(nsIIncrementalStreamLoader *aLoader,
+                                   const uint8_t* aData,
+                                   uint32_t aDataLength,
+                                   bool aEndOfStream)
+{
+  // Check if decoder has already been created.
+  if (mDecoder) {
+    return true;
+  }
+
+  nsAutoCString charset;
+
+  // Determine if BOM check should be done.  This occurs either
+  // if end-of-stream has been reached, or at least 3 bytes have
+  // been read from input.
+  if (!aEndOfStream && (aDataLength < 3)) {
+    return false;
+  }
+
+  // Do BOM detection.
+  if (DetectByteOrderMark(aData, aDataLength, charset)) {
+    mDecoder = EncodingUtils::DecoderForEncoding(charset);
+    return true;
+  }
+
+  // BOM detection failed, check content stream for charset.
+  nsCOMPtr<nsIRequest> req;
+  nsresult rv = aLoader->GetRequest(getter_AddRefs(req));
+  NS_ASSERTION(req, "StreamLoader's request went away prematurely");
+  NS_ENSURE_SUCCESS(rv, false);
+
+  nsCOMPtr<nsIChannel> channel = do_QueryInterface(req);
+
+  if (channel &&
+      NS_SUCCEEDED(channel->GetContentCharset(charset)) &&
+      EncodingUtils::FindEncodingForLabel(charset, charset)) {
+    mDecoder = EncodingUtils::DecoderForEncoding(charset);
+    return true;
+  }
+
+  // Check the hint charset from the script element or preload
+  // request.
+  nsAutoString hintCharset;
+  if (!mRequest->IsPreload()) {
+    mRequest->mElement->GetScriptCharset(hintCharset);
+  } else {
+    nsTArray<nsScriptLoader::PreloadInfo>::index_type i =
+      mScriptLoader->mPreloads.IndexOf(mRequest, 0,
+            nsScriptLoader::PreloadRequestComparator());
+
+    NS_ASSERTION(i != mScriptLoader->mPreloads.NoIndex,
+                 "Incorrect preload bookkeeping");
+    hintCharset = mScriptLoader->mPreloads[i].mCharset;
+  }
+
+  if (EncodingUtils::FindEncodingForLabel(hintCharset, charset)) {
+    mDecoder = EncodingUtils::DecoderForEncoding(charset);
+    return true;
+  }
+
+  // Get the charset from the charset of the document.
+  if (mScriptLoader->mDocument) {
+    charset = mScriptLoader->mDocument->GetDocumentCharacterSet();
+    mDecoder = EncodingUtils::DecoderForEncoding(charset);
+    return true;
+  }
+
+  // Curiously, there are various callers that don't pass aDocument. The
+  // fallback in the old code was ISO-8859-1, which behaved like
+  // windows-1252. Saying windows-1252 for clarity and for compliance
+  // with the Encoding Standard.
+  charset = "windows-1252";
+  mDecoder = EncodingUtils::DecoderForEncoding(charset);
+  return true;
+}
+
 NS_IMETHODIMP
 nsScriptLoadHandler::OnStreamComplete(nsIIncrementalStreamLoader* aLoader,
                                       nsISupports* aContext,
                                       nsresult aStatus,
-                                      uint32_t aStringLen,
-                                      const uint8_t* aString)
+                                      uint32_t aDataLength,
+                                      const uint8_t* aData)
 {
-  // pass arguments through except for the aContext,
-  // we have to mediate and use mRequest instead.
-  return mScriptLoader->OnStreamComplete(aLoader, mRequest, aStatus,
-                                         aStringLen, aString);
+  if (!mRequest->IsCanceled()) {
+    DebugOnly<bool> encoderSet =
+      EnsureDecoder(aLoader, aData, aDataLength, /* aEndOfStream = */ true);
+    MOZ_ASSERT(encoderSet);
+    DebugOnly<nsresult> rv = TryDecodeRawData(aData, aDataLength,
+                                              /* aEndOfStream = */ true);
+
+    // If SRI is required for this load, appending new bytes to the hash.
+    if (mSRIDataVerifier && NS_SUCCEEDED(mSRIStatus)) {
+      mSRIStatus = mSRIDataVerifier->Update(aDataLength, aData);
+    }
+  }
+
+  // we have to mediate and use mRequest.
+  return mScriptLoader->OnStreamComplete(aLoader, mRequest, aStatus, mSRIStatus,
+                                         mBuffer, mSRIDataVerifier);
 }
--- a/dom/base/nsScriptLoader.h
+++ b/dom/base/nsScriptLoader.h
@@ -7,26 +7,29 @@
 /*
  * A class that handles loading and evaluation of <script> elements.
  */
 
 #ifndef __nsScriptLoader_h__
 #define __nsScriptLoader_h__
 
 #include "nsCOMPtr.h"
+#include "nsIUnicodeDecoder.h"
 #include "nsIScriptElement.h"
 #include "nsCOMArray.h"
 #include "nsTArray.h"
 #include "nsAutoPtr.h"
 #include "nsIDocument.h"
 #include "nsIIncrementalStreamLoader.h"
 #include "mozilla/CORSMode.h"
 #include "mozilla/dom/SRIMetadata.h"
+#include "mozilla/dom/SRICheck.h"
 #include "mozilla/LinkedList.h"
 #include "mozilla/net/ReferrerPolicy.h"
+#include "mozilla/Vector.h"
 
 class nsScriptLoadRequestList;
 class nsIURI;
 
 namespace JS {
   class SourceBufferHolder;
 } // namespace JS
 
@@ -212,16 +215,17 @@ class nsScriptLoader final : public nsIS
       mScriptLoader->mCurrentScript.swap(mOldScript);
     }
   private:
     nsCOMPtr<nsIScriptElement> mOldScript;
     nsScriptLoader* mScriptLoader;
   };
 
   friend class nsScriptRequestProcessor;
+  friend class nsScriptLoadHandler;
   friend class AutoCurrentScriptUpdater;
 
 public:
   explicit nsScriptLoader(nsIDocument* aDocument);
 
   NS_DECL_ISUPPORTS
 
   /**
@@ -343,19 +347,20 @@ public:
 
   /**
    * Handle the completion of a stream.  This is called by the
    * nsScriptLoadHandler object which observes the IncrementalStreamLoader
    * loading the script.
    */
   nsresult OnStreamComplete(nsIIncrementalStreamLoader* aLoader,
                             nsISupports* aContext,
-                            nsresult aStatus,
-                            uint32_t aStringLen,
-                            const uint8_t* aString);
+                            nsresult aChannelStatus,
+                            nsresult aSRIStatus,
+                            mozilla::Vector<char16_t> &aString,
+                            mozilla::dom::SRICheckDataVerifier* aSRIDataVerifier);
 
   /**
    * Processes any pending requests that are ready for processing.
    */
   void ProcessPendingRequests();
 
   /**
    * Check whether it's OK to load a script from aURI in
@@ -496,18 +501,17 @@ private:
                                     nsScriptLoadRequest *aRequest,
                                     JS::Handle<JSObject *> aScopeChain,
                                     JS::CompileOptions *aOptions);
 
   uint32_t NumberOfProcessors();
   nsresult PrepareLoadedRequest(nsScriptLoadRequest* aRequest,
                                 nsIIncrementalStreamLoader* aLoader,
                                 nsresult aStatus,
-                                uint32_t aStringLen,
-                                const uint8_t* aString);
+                                mozilla::Vector<char16_t> &aString);
 
   void AddDeferRequest(nsScriptLoadRequest* aRequest);
   bool MaybeRemovedDeferRequests();
 
   nsIDocument* mDocument;                   // [WEAK]
   nsCOMArray<nsIScriptLoaderObserver> mObservers;
   nsScriptLoadRequestList mNonAsyncExternalScriptInsertedRequests;
   // mLoadingAsyncRequests holds async requests while they're loading; when they
@@ -547,26 +551,57 @@ private:
   bool mDocumentParsingDone;
   bool mBlockingDOMContentLoaded;
 };
 
 class nsScriptLoadHandler final : public nsIIncrementalStreamLoaderObserver
 {
 public:
   explicit nsScriptLoadHandler(nsScriptLoader* aScriptLoader,
-                               nsScriptLoadRequest *aRequest);
+                               nsScriptLoadRequest *aRequest,
+                               mozilla::dom::SRICheckDataVerifier *aSRIDataVerifier);
 
   NS_DECL_ISUPPORTS
   NS_DECL_NSIINCREMENTALSTREAMLOADEROBSERVER
 
 private:
   virtual ~nsScriptLoadHandler();
 
-  RefPtr<nsScriptLoader> mScriptLoader;
-  RefPtr<nsScriptLoadRequest> mRequest;
+  /*
+   * Try to decode some raw data.
+   */
+  nsresult TryDecodeRawData(const uint8_t* aData, uint32_t aDataLength,
+                            bool aEndOfStream);
+
+  /*
+   * Discover the charset by looking at the stream data, the script
+   * tag, and other indicators.  Returns true if charset has been
+   * discovered.
+   */
+  bool EnsureDecoder(nsIIncrementalStreamLoader *aLoader,
+                     const uint8_t* aData, uint32_t aDataLength,
+                     bool aEndOfStream);
+
+  // ScriptLoader which will handle the parsed script.
+  RefPtr<nsScriptLoader>        mScriptLoader;
+
+  // The nsScriptLoadRequest for this load.
+  RefPtr<nsScriptLoadRequest>   mRequest;
+
+  // SRI data verifier.
+  nsAutoPtr<mozilla::dom::SRICheckDataVerifier> mSRIDataVerifier;
+
+  // Status of SRI data operations.
+  nsresult                      mSRIStatus;
+
+  // Unicode decoder for charset.
+  nsCOMPtr<nsIUnicodeDecoder>   mDecoder;
+
+  // Accumulated decoded char buffer.
+  mozilla::Vector<char16_t>     mBuffer;
 };
 
 class nsAutoScriptLoaderDisabler
 {
 public:
   explicit nsAutoScriptLoaderDisabler(nsIDocument* aDoc)
   {
     mLoader = aDoc->ScriptLoader();
--- a/dom/security/SRICheck.cpp
+++ b/dom/security/SRICheck.cpp
@@ -206,44 +206,16 @@ SRICheck::VerifyIntegrity(const SRIMetad
   SRICheckDataVerifier verifier(aMetadata, aDocument);
   nsresult rv;
   rv = verifier.Update(utf8Hash.Length(), (uint8_t*)utf8Hash.get());
   NS_ENSURE_SUCCESS(rv, rv);
 
   return verifier.Verify(aMetadata, channel, aCORSMode, aDocument);
 }
 
-/* static */ nsresult
-SRICheck::VerifyIntegrity(const SRIMetadata& aMetadata,
-                          nsIIncrementalStreamLoader* aLoader,
-                          const CORSMode aCORSMode,
-                          uint32_t aStringLen,
-                          const uint8_t* aString,
-                          const nsIDocument* aDocument)
-{
-  NS_ENSURE_ARG_POINTER(aLoader);
-
-  nsCOMPtr<nsIRequest> request;
-  aLoader->GetRequest(getter_AddRefs(request));
-  NS_ENSURE_ARG_POINTER(request);
-  nsCOMPtr<nsIChannel> channel;
-  channel = do_QueryInterface(request);
-
-  if (MOZ_LOG_TEST(GetSriLog(), mozilla::LogLevel::Debug)) {
-    SRILOG(("SRICheck::VerifyIntegrity (stream)"));
-  }
-
-  SRICheckDataVerifier verifier(aMetadata, aDocument);
-  nsresult rv;
-  rv = verifier.Update(aStringLen, aString);
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  return verifier.Verify(aMetadata, channel, aCORSMode, aDocument);
-}
-
 //////////////////////////////////////////////////////////////
 //
 //////////////////////////////////////////////////////////////
 SRICheckDataVerifier::SRICheckDataVerifier(const SRIMetadata& aMetadata,
                                            const nsIDocument* aDocument)
   : mCryptoHash(nullptr),
     mBytesHashed(0),
     mInvalidMetadata(false),
--- a/dom/security/SRICheck.h
+++ b/dom/security/SRICheck.h
@@ -9,17 +9,16 @@
 
 #include "mozilla/CORSMode.h"
 #include "nsCOMPtr.h"
 #include "nsICryptoHash.h"
 #include "SRIMetadata.h"
 
 class nsIChannel;
 class nsIDocument;
-class nsIIncrementalStreamLoader;
 class nsIUnicharStreamLoader;
 
 namespace mozilla {
 namespace dom {
 
 class SRICheck final
 {
 public:
@@ -38,27 +37,16 @@ public:
    * Process the integrity attribute of the element.  A result of false
    * must prevent the resource from loading.
    */
   static nsresult VerifyIntegrity(const SRIMetadata& aMetadata,
                                   nsIUnicharStreamLoader* aLoader,
                                   const CORSMode aCORSMode,
                                   const nsAString& aString,
                                   const nsIDocument* aDocument);
-
-  /**
-   * Process the integrity attribute of the element.  A result of false
-   * must prevent the resource from loading.
-   */
-  static nsresult VerifyIntegrity(const SRIMetadata& aMetadata,
-                                  nsIIncrementalStreamLoader* aLoader,
-                                  const CORSMode aCORSMode,
-                                  uint32_t aStringLen,
-                                  const uint8_t* aString,
-                                  const nsIDocument* aDocument);
 };
 
 class SRICheckDataVerifier final
 {
   public:
     SRICheckDataVerifier(const SRIMetadata& aMetadata,
                          const nsIDocument* aDocument);