--- a/dom/security/SRICheck.cpp
+++ b/dom/security/SRICheck.cpp
@@ -13,17 +13,16 @@
#include "mozilla/dom/SRILogHelper.h"
#include "mozilla/dom/SRIMetadata.h"
#include "nsContentUtils.h"
#include "nsIChannel.h"
#include "nsIConsoleReportCollector.h"
#include "nsIProtocolHandler.h"
#include "nsIScriptError.h"
#include "nsIIncrementalStreamLoader.h"
-#include "nsIUnicharStreamLoader.h"
#include "nsIURI.h"
#include "nsNetUtil.h"
#include "nsWhitespaceTokenizer.h"
#define SRIVERBOSE(args) \
MOZ_LOG(SRILogHelper::GetSriLog(), mozilla::LogLevel::Verbose, args)
#define SRILOG(args) \
MOZ_LOG(SRILogHelper::GetSriLog(), mozilla::LogLevel::Debug, args)
--- a/layout/style/Loader.cpp
+++ b/layout/style/Loader.cpp
@@ -13,17 +13,16 @@
#include "mozilla/IntegerPrintfMacros.h"
#include "mozilla/LoadInfo.h"
#include "mozilla/MemoryReporting.h"
#include "mozilla/StyleSheetInlines.h"
#include "mozilla/SystemGroup.h"
#include "mozilla/ResultExtensions.h"
#include "mozilla/URLPreloader.h"
#include "nsIRunnable.h"
-#include "nsIUnicharStreamLoader.h"
#include "nsSyncLoadService.h"
#include "nsCOMPtr.h"
#include "nsString.h"
#include "nsIContent.h"
#include "nsIDocument.h"
#include "nsIDOMNode.h"
#include "nsIURI.h"
#include "nsNetUtil.h"
@@ -131,17 +130,17 @@ static const char* const gStateStrings[]
"eSheetPending",
"eSheetLoading",
"eSheetComplete"
};
/********************************
* SheetLoadData implementation *
********************************/
-NS_IMPL_ISUPPORTS(SheetLoadData, nsIUnicharStreamLoaderObserver, nsIRunnable,
+NS_IMPL_ISUPPORTS(SheetLoadData, nsIRunnable,
nsIThreadObserver)
SheetLoadData::SheetLoadData(Loader* aLoader,
const nsAString& aTitle,
nsIURI* aURI,
StyleSheet* aSheet,
nsIStyleSheetLinkingElement* aOwningElement,
bool aIsAlternate,
@@ -557,80 +556,28 @@ SheetLoadData::DetermineNonBOMEncoding(n
if (mLoader->mDocument) {
// Use the document charset.
return mLoader->mDocument->GetDocumentCharacterSet();
}
return UTF_8_ENCODING;
}
-/*
- * Encoding decision for the old style system
- */
-NS_IMETHODIMP
-SheetLoadData::OnDetermineCharset(nsIUnicharStreamLoader* aLoader,
- nsISupports* aContext,
- nsACString const& aSegment,
- nsACString& aCharset)
-{
- const Encoding* encoding;
- size_t bomLength;
- Tie(encoding, bomLength) = Encoding::ForBOM(aSegment);
- Unused << bomLength;
- if (!encoding) {
- nsCOMPtr<nsIChannel> channel;
- aLoader->GetChannel(getter_AddRefs(channel));
- encoding = DetermineNonBOMEncoding(aSegment, channel);
- }
-
- encoding->Name(aCharset);
- mEncoding = encoding;
- return NS_OK;
-}
-
already_AddRefed<nsIURI>
SheetLoadData::GetReferrerURI()
{
nsCOMPtr<nsIURI> uri;
if (mParentData)
uri = mParentData->mSheet->GetSheetURI();
if (!uri && mLoader->mDocument)
uri = mLoader->mDocument->GetDocumentURI();
return uri.forget();
}
/*
- * Load completion for the old style system.
- */
-NS_IMETHODIMP
-SheetLoadData::OnStreamComplete(nsIUnicharStreamLoader* aLoader,
- nsISupports* aContext,
- nsresult aStatus,
- const nsAString& aBuffer)
-{
- nsCOMPtr<nsIChannel> channel;
- aLoader->GetChannel(getter_AddRefs(channel));
- nsCString bytes;
- aLoader->GetRawBuffer(bytes);
-
- nsresult rv = VerifySheetReadyToParse(aStatus, bytes, channel);
- if (rv != NS_OK_PARSE_SHEET) {
- return rv;
- }
-
- // NB: The aAllowAsync doesn't really matter here, because this path is only
- // for the old style system.
- bool completed;
- rv = mLoader->ParseSheet(aBuffer, Span<const uint8_t>(), this,
- /* aAllowAsync = */ true, completed);
- NS_ASSERTION(completed || !mSyncLoad, "sync load did not complete");
- return rv;
-}
-
-/*
* Stream completion code shared by Stylo and the old style system.
*
* Here we need to check that the load did not give us an http error
* page and check the mimetype on the channel to make sure we're not
* loading non-text/css data in standards mode.
*/
nsresult
SheetLoadData::VerifySheetReadyToParse(nsresult aStatus,
@@ -1308,33 +1255,20 @@ Loader::LoadSheet(SheetLoadData* aLoadDa
aLoadData->mSheet->GetIntegrity(sriMetadata);
if (aLoadData->mSyncLoad) {
LOG((" Synchronous load"));
NS_ASSERTION(!aLoadData->mObserver, "Observer for a sync load?");
NS_ASSERTION(aSheetState == eSheetNeedsParser,
"Sync loads can't reuse existing async loads");
- // Create a nsIUnicharStreamLoader instance to which we will feed
+ // Create a StreamLoader instance to which we will feed
// the data from the sync load. Do this before creating the
// channel to make error recovery simpler.
- nsCOMPtr<nsIStreamListener> streamLoader;
- if (aLoadData->mSheet->IsGecko()) {
- nsCOMPtr<nsIUnicharStreamLoader> unicharStreamLoader;
- rv = NS_NewUnicharStreamLoader(getter_AddRefs(unicharStreamLoader),
- aLoadData);
- streamLoader = unicharStreamLoader;
- if (NS_FAILED(rv)) {
- LOG_ERROR((" Failed to create stream loader for sync load"));
- SheetComplete(aLoadData, rv);
- return rv;
- }
- } else {
- streamLoader = new StreamLoader(aLoadData);
- }
+ nsCOMPtr<nsIStreamListener> streamLoader = new StreamLoader(aLoadData);
if (mDocument) {
mozilla::net::PredictorLearn(aLoadData->mURI, mDocument->GetDocumentURI(),
nsINetworkPredictor::LEARN_LOAD_SUBRESOURCE,
mDocument);
}
nsSecurityFlags securityFlags =
@@ -1604,33 +1538,17 @@ Loader::LoadSheet(SheetLoadData* aLoadDa
// Now tell the channel we expect text/css data back.... We do
// this before opening it, so it's only treated as a hint.
channel->SetContentType(NS_LITERAL_CSTRING("text/css"));
// We don't have to hold on to the stream loader. The ownership
// model is: Necko owns the stream loader, which owns the load data,
// which owns us
- nsCOMPtr<nsIStreamListener> streamLoader;
- if (aLoadData->mSheet->IsGecko()) {
- nsCOMPtr<nsIUnicharStreamLoader> unicharStreamLoader;
- rv =
- NS_NewUnicharStreamLoader(getter_AddRefs(unicharStreamLoader), aLoadData);
- streamLoader = unicharStreamLoader;
- if (NS_FAILED(rv)) {
-#ifdef DEBUG
- mSyncCallback = false;
-#endif
- LOG_ERROR((" Failed to create stream loader"));
- SheetComplete(aLoadData, rv);
- return rv;
- }
- } else {
- streamLoader = new StreamLoader(aLoadData);
- }
+ nsCOMPtr<nsIStreamListener> streamLoader = new StreamLoader(aLoadData);
if (mDocument) {
mozilla::net::PredictorLearn(aLoadData->mURI, mDocument->GetDocumentURI(),
nsINetworkPredictor::LEARN_LOAD_SUBRESOURCE,
mDocument);
}
rv = channel->AsyncOpen2(streamLoader);
--- a/layout/style/SheetLoadData.h
+++ b/layout/style/SheetLoadData.h
@@ -6,17 +6,16 @@
#ifndef mozilla_css_SheetLoadData_h
#define mozilla_css_SheetLoadData_h
#include "mozilla/css/Loader.h"
#include "mozilla/css/SheetParsingMode.h"
#include "mozilla/Encoding.h"
#include "mozilla/NotNull.h"
-#include "nsIUnicharStreamLoader.h"
#include "nsIThreadInternal.h"
namespace mozilla {
class StyleSheet;
}
class nsICSSLoaderObserver;
class nsINode;
class nsIPrincipal;
@@ -32,17 +31,16 @@ namespace css {
static_assert(eAuthorSheetFeatures == 0 && eUserSheetFeatures == 1 &&
eAgentSheetFeatures == 2,
"sheet parsing mode constants won't fit "
"in SheetLoadData::mParsingMode");
class SheetLoadData final
: public nsIRunnable
- , public nsIUnicharStreamLoaderObserver
, public nsIThreadObserver
{
protected:
virtual ~SheetLoadData(void);
public:
// Data for loading a sheet linked from a document
SheetLoadData(Loader* aLoader,
@@ -84,17 +82,16 @@ public:
nsresult VerifySheetReadyToParse(nsresult aStatus,
const nsACString& aBytes,
nsIChannel* aChannel);
NS_DECL_ISUPPORTS
NS_DECL_NSIRUNNABLE
NS_DECL_NSITHREADOBSERVER
- NS_DECL_NSIUNICHARSTREAMLOADEROBSERVER
// Hold a ref to the CSSLoader so we can call back to it to let it
// know the load finished
RefPtr<Loader> mLoader;
// Title needed to pull datas out of the pending datas table when
// the preferred title is changed
nsString mTitle;
--- a/netwerk/base/moz.build
+++ b/netwerk/base/moz.build
@@ -116,17 +116,16 @@ XPIDL_SOURCES += [
'nsIThreadRetargetableRequest.idl',
'nsIThreadRetargetableStreamListener.idl',
'nsIThrottledInputChannel.idl',
'nsITimedChannel.idl',
'nsITLSServerSocket.idl',
'nsITraceableChannel.idl',
'nsITransport.idl',
'nsIUDPSocket.idl',
- 'nsIUnicharStreamLoader.idl',
'nsIUploadChannel.idl',
'nsIUploadChannel2.idl',
'nsIURI.idl',
'nsIURIClassifier.idl',
'nsIURIMutator.idl',
'nsIURIWithPrincipal.idl',
'nsIURL.idl',
'nsIURLParser.idl',
@@ -235,17 +234,16 @@ UNIFIED_SOURCES += [
'nsStandardURL.cpp',
'nsStreamListenerTee.cpp',
'nsStreamListenerWrapper.cpp',
'nsStreamLoader.cpp',
'nsStreamTransportService.cpp',
'nsSyncStreamListener.cpp',
'nsTransportUtils.cpp',
'nsUDPSocket.cpp',
- 'nsUnicharStreamLoader.cpp',
'nsURLHelper.cpp',
'nsURLParsers.cpp',
'PartiallySeekableInputStream.cpp',
'PollableEvent.cpp',
'Predictor.cpp',
'ProxyAutoConfig.cpp',
'RedirectChannelRegistrar.cpp',
'RequestContextService.cpp',
deleted file mode 100644
--- a/netwerk/base/nsIUnicharStreamLoader.idl
+++ /dev/null
@@ -1,88 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; 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 "nsIStreamListener.idl"
-
-interface nsIUnicharInputStream;
-interface nsIUnicharStreamLoader;
-interface nsIChannel;
-
-[scriptable, uuid(c2982b39-2e48-429e-92b7-99348a1633c5)]
-interface nsIUnicharStreamLoaderObserver : nsISupports
-{
- /**
- * Called as soon as at least 512 octets of data have arrived.
- * If the stream receives fewer than 512 octets of data in total,
- * called upon stream completion but before calling OnStreamComplete.
- * Will not be called if the stream receives no data at all.
- *
- * @param aLoader the unichar stream loader
- * @param aContext the context parameter of the underlying channel
- * @param aSegment up to 512 octets of raw data from the stream
- *
- * @return the name of the character set to be used to decode this stream
- */
- ACString onDetermineCharset(in nsIUnicharStreamLoader aLoader,
- in nsISupports aContext,
- in ACString aSegment);
-
- /**
- * Called when the entire stream has been loaded and decoded.
- *
- * @param aLoader the unichar stream loader
- * @param aContext the context parameter of the underlying channel
- * @param aStatus the status of the underlying channel
- * @param aBuffer the contents of the stream, decoded to UTF-16.
- *
- * This method will always be called asynchronously by the
- * nsUnicharIStreamLoader involved, on the thread that called the
- * loader's init() method. If onDetermineCharset fails,
- * onStreamComplete will still be called, but aStatus will be an
- * error code.
- */
- void onStreamComplete(in nsIUnicharStreamLoader aLoader,
- in nsISupports aContext,
- in nsresult aStatus,
- in AString aBuffer);
-};
-
-/**
- * Asynchronously load a channel, converting the data to UTF-16.
- *
- * To use this interface, first call init() with a
- * nsIUnicharStreamLoaderObserver that will be notified when the data has been
- * loaded. Then call asyncOpen() on the channel with the nsIUnicharStreamLoader
- * as the listener. The context argument in the asyncOpen() call will be
- * passed to the onStreamComplete() callback.
- */
-[scriptable, uuid(afb62060-37c7-4713-8a84-4a0c1199ba5c)]
-interface nsIUnicharStreamLoader : nsIStreamListener
-{
- /**
- * Initializes the unichar stream loader
- *
- * @param aObserver the observer to notify when a charset is needed and when
- * the load is complete
- */
- void init(in nsIUnicharStreamLoaderObserver aObserver);
-
- /**
- * The channel attribute is only valid inside the onDetermineCharset
- * and onStreamComplete callbacks. Otherwise it will be null.
- */
- readonly attribute nsIChannel channel;
-
- /**
- * The charset that onDetermineCharset returned, if that's been
- * called.
- */
- readonly attribute ACString charset;
-
- /**
- * Get the raw bytes as seen on the wire prior to character converstion.
- * Used by Subresource Integrity checker to generate the correct hash.
- */
- readonly attribute ACString rawBuffer;
-};
--- a/netwerk/base/nsNetUtil.cpp
+++ b/netwerk/base/nsNetUtil.cpp
@@ -56,17 +56,16 @@
#include "nsISocketProviderService.h"
#include "nsIStandardURL.h"
#include "nsIStreamLoader.h"
#include "nsIIncrementalStreamLoader.h"
#include "nsIStreamTransportService.h"
#include "nsStringStream.h"
#include "nsISyncStreamListener.h"
#include "nsITransport.h"
-#include "nsIUnicharStreamLoader.h"
#include "nsIURIWithPrincipal.h"
#include "nsIURLParser.h"
#include "nsIUUIDGenerator.h"
#include "nsIViewSourceChannel.h"
#include "nsInterfaceRequestorAgg.h"
#include "plstr.h"
#include "nsINestedURI.h"
#include "mozilla/dom/nsCSPUtils.h"
@@ -1132,33 +1131,16 @@ NS_NewStreamLoader(nsIStreamLoader
aContentPolicyType,
aLoadGroup,
aCallbacks,
aLoadFlags,
aReferrer);
}
nsresult
-NS_NewUnicharStreamLoader(nsIUnicharStreamLoader **result,
- nsIUnicharStreamLoaderObserver *observer)
-{
- nsresult rv;
- nsCOMPtr<nsIUnicharStreamLoader> loader =
- do_CreateInstance(NS_UNICHARSTREAMLOADER_CONTRACTID, &rv);
- if (NS_SUCCEEDED(rv)) {
- rv = loader->Init(observer);
- if (NS_SUCCEEDED(rv)) {
- *result = nullptr;
- loader.swap(*result);
- }
- }
- return rv;
-}
-
-nsresult
NS_NewSyncStreamListener(nsIStreamListener **result,
nsIInputStream **stream)
{
nsresult rv;
nsCOMPtr<nsISyncStreamListener> listener =
do_CreateInstance(NS_SYNCSTREAMLISTENER_CONTRACTID, &rv);
if (NS_SUCCEEDED(rv)) {
rv = listener->GetInputStream(stream);
--- a/netwerk/base/nsNetUtil.h
+++ b/netwerk/base/nsNetUtil.h
@@ -45,18 +45,16 @@ class nsIParentChannel;
class nsIPersistentProperties;
class nsIProxyInfo;
class nsIRequestObserver;
class nsIStreamListener;
class nsIStreamLoader;
class nsIStreamLoaderObserver;
class nsIIncrementalStreamLoader;
class nsIIncrementalStreamLoaderObserver;
-class nsIUnicharStreamLoader;
-class nsIUnicharStreamLoaderObserver;
namespace mozilla {
class Encoding;
class OriginAttributes;
namespace dom {
class ClientInfo;
class PerformanceStorage;
class ServiceWorkerDescriptor;
@@ -421,19 +419,16 @@ NS_NewStreamLoader(nsIStreamLoader
nsIPrincipal *aLoadingPrincipal,
nsSecurityFlags aSecurityFlags,
nsContentPolicyType aContentPolicyType,
nsILoadGroup *aLoadGroup = nullptr,
nsIInterfaceRequestor *aCallbacks = nullptr,
nsLoadFlags aLoadFlags = nsIRequest::LOAD_NORMAL,
nsIURI *aReferrer = nullptr);
-nsresult NS_NewUnicharStreamLoader(nsIUnicharStreamLoader **result,
- nsIUnicharStreamLoaderObserver *observer);
-
nsresult NS_NewSyncStreamListener(nsIStreamListener **result,
nsIInputStream **stream);
/**
* Implement the nsIChannel::Open(nsIInputStream**) method using the channel's
* AsyncOpen method.
*
* NOTE: Reading from the returned nsIInputStream may spin the current
deleted file mode 100644
--- a/netwerk/base/nsUnicharStreamLoader.cpp
+++ /dev/null
@@ -1,250 +0,0 @@
-/* -*- 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 "mozilla/DebugOnly.h"
-
-#include "nsUnicharStreamLoader.h"
-#include "nsIInputStream.h"
-#include <algorithm>
-#include "mozilla/Encoding.h"
-
-// 1024 bytes is specified in
-// http://www.whatwg.org/specs/web-apps/current-work/#charset for HTML; for
-// other resource types (e.g. CSS) typically fewer bytes are fine too, since
-// they only look at things right at the beginning of the data.
-#define SNIFFING_BUFFER_SIZE 1024
-
-using namespace mozilla;
-
-NS_IMETHODIMP
-nsUnicharStreamLoader::Init(nsIUnicharStreamLoaderObserver *aObserver)
-{
- NS_ENSURE_ARG_POINTER(aObserver);
-
- mObserver = aObserver;
-
- if (!mRawData.SetCapacity(SNIFFING_BUFFER_SIZE, fallible))
- return NS_ERROR_OUT_OF_MEMORY;
-
- return NS_OK;
-}
-
-nsresult
-nsUnicharStreamLoader::Create(nsISupports *aOuter,
- REFNSIID aIID,
- void **aResult)
-{
- if (aOuter) return NS_ERROR_NO_AGGREGATION;
-
- nsUnicharStreamLoader* it = new nsUnicharStreamLoader();
- NS_ADDREF(it);
- nsresult rv = it->QueryInterface(aIID, aResult);
- NS_RELEASE(it);
- return rv;
-}
-
-NS_IMPL_ISUPPORTS(nsUnicharStreamLoader, nsIUnicharStreamLoader,
- nsIRequestObserver, nsIStreamListener)
-
-NS_IMETHODIMP
-nsUnicharStreamLoader::GetChannel(nsIChannel **aChannel)
-{
- NS_IF_ADDREF(*aChannel = mChannel);
- return NS_OK;
-}
-
-NS_IMETHODIMP
-nsUnicharStreamLoader::GetCharset(nsACString& aCharset)
-{
- aCharset = mCharset;
- return NS_OK;
-}
-
-/* nsIRequestObserver implementation */
-NS_IMETHODIMP
-nsUnicharStreamLoader::OnStartRequest(nsIRequest*, nsISupports*)
-{
- return NS_OK;
-}
-
-NS_IMETHODIMP
-nsUnicharStreamLoader::OnStopRequest(nsIRequest *aRequest,
- nsISupports *aContext,
- nsresult aStatus)
-{
- if (!mObserver) {
- NS_ERROR("nsUnicharStreamLoader::OnStopRequest called before ::Init");
- return NS_ERROR_UNEXPECTED;
- }
-
- mContext = aContext;
- mChannel = do_QueryInterface(aRequest);
-
- nsresult rv = NS_OK;
- if (mRawData.Length() > 0 && NS_SUCCEEDED(aStatus)) {
- MOZ_ASSERT(mBuffer.Length() == 0,
- "should not have both decoded and raw data");
- rv = DetermineCharset();
- }
-
- if (NS_FAILED(rv)) {
- // Call the observer but pass it no data.
- mObserver->OnStreamComplete(this, mContext, rv, EmptyString());
- } else {
- mObserver->OnStreamComplete(this, mContext, aStatus, mBuffer);
- }
-
- mObserver = nullptr;
- mDecoder = nullptr;
- mContext = nullptr;
- mChannel = nullptr;
- mCharset.Truncate();
- mRawData.Truncate();
- mRawBuffer.Truncate();
- mBuffer.Truncate();
- return rv;
-}
-
-NS_IMETHODIMP
-nsUnicharStreamLoader::GetRawBuffer(nsACString& aRawBuffer)
-{
- aRawBuffer = mRawBuffer;
- return NS_OK;
-}
-
-/* nsIStreamListener implementation */
-NS_IMETHODIMP
-nsUnicharStreamLoader::OnDataAvailable(nsIRequest *aRequest,
- nsISupports *aContext,
- nsIInputStream *aInputStream,
- uint64_t aSourceOffset,
- uint32_t aCount)
-{
- if (!mObserver) {
- NS_ERROR("nsUnicharStreamLoader::OnDataAvailable called before ::Init");
- return NS_ERROR_UNEXPECTED;
- }
-
- mContext = aContext;
- mChannel = do_QueryInterface(aRequest);
-
- nsresult rv = NS_OK;
- if (mDecoder) {
- // process everything we've got
- uint32_t dummy;
- aInputStream->ReadSegments(WriteSegmentFun, this, aCount, &dummy);
- } else {
- // no decoder yet. Read up to SNIFFING_BUFFER_SIZE octets into
- // mRawData (this is the cutoff specified in
- // draft-abarth-mime-sniff-06). If we can get that much, then go
- // ahead and fire charset detection and read the rest. Otherwise
- // wait for more data.
-
- uint32_t haveRead = mRawData.Length();
- uint32_t toRead = std::min(SNIFFING_BUFFER_SIZE - haveRead, aCount);
- uint32_t n;
- char *here = mRawData.BeginWriting() + haveRead;
-
- rv = aInputStream->Read(here, toRead, &n);
- if (NS_SUCCEEDED(rv)) {
- mRawData.SetLength(haveRead + n);
- if (mRawData.Length() == SNIFFING_BUFFER_SIZE) {
- rv = DetermineCharset();
- if (NS_SUCCEEDED(rv)) {
- // process what's left
- uint32_t dummy;
- aInputStream->ReadSegments(WriteSegmentFun, this, aCount - n, &dummy);
- }
- } else {
- MOZ_ASSERT(n == aCount, "didn't read as much as was available");
- }
- }
- }
-
- mContext = nullptr;
- mChannel = nullptr;
- return rv;
-}
-
-nsresult
-nsUnicharStreamLoader::DetermineCharset()
-{
- nsresult rv = mObserver->OnDetermineCharset(this, mContext,
- mRawData, mCharset);
- if (NS_FAILED(rv) || mCharset.IsEmpty()) {
- // The observer told us nothing useful
- mCharset.AssignLiteral("UTF-8");
- }
-
- const Encoding* encoding = Encoding::ForLabel(mCharset);
- if (!encoding) {
- return NS_ERROR_UCONV_NOCONV;
- }
- mDecoder = encoding->NewDecoderWithBOMRemoval();
-
- // Process the data into mBuffer
- uint32_t dummy;
- rv = WriteSegmentFun(nullptr, this,
- mRawData.BeginReading(),
- 0, mRawData.Length(),
- &dummy);
- mRawData.Truncate();
- return rv;
-}
-
-nsresult
-nsUnicharStreamLoader::WriteSegmentFun(nsIInputStream *,
- void *aClosure,
- const char *aSegment,
- uint32_t,
- uint32_t aCount,
- uint32_t *aWriteCount)
-{
- nsUnicharStreamLoader* self = static_cast<nsUnicharStreamLoader*>(aClosure);
-
- nsAString::size_type haveRead(self->mBuffer.Length());
-
- CheckedInt<size_t> needed = self->mDecoder->MaxUTF16BufferLength(aCount);
- if (!needed.isValid()) {
- return NS_ERROR_OUT_OF_MEMORY;
- }
-
- CheckedInt<nsAString::size_type> capacity(needed.value());
- capacity += haveRead;
- if (!capacity.isValid()) {
- return NS_ERROR_OUT_OF_MEMORY;
- }
-
- if (!self->mBuffer.SetCapacity(capacity.value(), fallible)) {
- return NS_ERROR_OUT_OF_MEMORY;
- }
-
- if (!self->mRawBuffer.Append(aSegment, aCount, fallible)) {
- return NS_ERROR_OUT_OF_MEMORY;
- }
-
- uint32_t result;
- size_t read;
- size_t written;
- bool hadErrors;
-
- Tie(result, read, written, hadErrors) = self->mDecoder->DecodeToUTF16(
- AsBytes(MakeSpan(aSegment, aCount)),
- MakeSpan(self->mBuffer.BeginWriting() + haveRead, needed.value()),
- false);
- MOZ_ASSERT(result == kInputEmpty);
- MOZ_ASSERT(read == aCount);
- Unused << hadErrors;
-
- CheckedInt<nsAString::size_type> newLen(written);
- newLen += haveRead;
- if (!newLen.isValid()) {
- return NS_ERROR_OUT_OF_MEMORY;
- }
-
- self->mBuffer.SetLength(newLen.value());
- *aWriteCount = aCount;
- return NS_OK;
-}
deleted file mode 100644
--- a/netwerk/base/nsUnicharStreamLoader.h
+++ /dev/null
@@ -1,60 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; 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/. */
-
-#ifndef nsUnicharStreamLoader_h__
-#define nsUnicharStreamLoader_h__
-
-#include "nsIChannel.h"
-#include "nsIUnicharStreamLoader.h"
-#include "mozilla/Encoding.h"
-#include "nsCOMPtr.h"
-#include "nsString.h"
-
-class nsIInputStream;
-
-class nsUnicharStreamLoader : public nsIUnicharStreamLoader
-{
-public:
- NS_DECL_ISUPPORTS
- NS_DECL_NSIUNICHARSTREAMLOADER
- NS_DECL_NSIREQUESTOBSERVER
- NS_DECL_NSISTREAMLISTENER
-
- nsUnicharStreamLoader() {}
-
- static nsresult Create(nsISupports *aOuter, REFNSIID aIID, void **aResult);
-
-protected:
- virtual ~nsUnicharStreamLoader() {}
-
- nsresult DetermineCharset();
-
- /**
- * callback method used for ReadSegments
- */
- static nsresult WriteSegmentFun(nsIInputStream *, void *, const char *,
- uint32_t, uint32_t, uint32_t *);
-
- nsCOMPtr<nsIUnicharStreamLoaderObserver> mObserver;
- mozilla::UniquePtr<mozilla::Decoder> mDecoder;
- nsCOMPtr<nsISupports> mContext;
- nsCOMPtr<nsIChannel> mChannel;
- nsCString mCharset;
-
- // This holds the first up-to-512 bytes of the raw stream.
- // It will be passed to the OnDetermineCharset callback.
- nsCString mRawData;
-
- // Holds complete raw bytes as received so that SRI checks can be
- // calculated on the raw data prior to character conversion.
- nsCString mRawBuffer;
-
- // This holds the complete contents of the stream so far, after
- // decoding to UTF-16. It will be passed to the OnStreamComplete
- // callback.
- nsString mBuffer;
-};
-
-#endif // nsUnicharStreamLoader_h__
--- a/netwerk/build/nsNetModule.cpp
+++ b/netwerk/build/nsNetModule.cpp
@@ -17,17 +17,16 @@
#include "nsICategoryManager.h"
#include "nsSocketProviderService.h"
#include "nscore.h"
#include "nsSimpleURI.h"
#include "nsSimpleNestedURI.h"
#include "nsLoadGroup.h"
#include "nsStreamLoader.h"
#include "nsIncrementalStreamLoader.h"
-#include "nsUnicharStreamLoader.h"
#include "nsFileStreams.h"
#include "nsBufferedStreams.h"
#include "nsMIMEInputStream.h"
#include "nsSOCKSSocketProvider.h"
#include "nsCacheService.h"
#include "nsDiskCacheDeviceSQL.h"
#include "nsApplicationCache.h"
#include "nsApplicationCacheService.h"
@@ -680,17 +679,16 @@ NS_DEFINE_NAMED_CID(NS_SIMPLEURI_CID);
NS_DEFINE_NAMED_CID(NS_SIMPLEURIMUTATOR_CID);
NS_DEFINE_NAMED_CID(NS_SIMPLENESTEDURI_CID);
NS_DEFINE_NAMED_CID(NS_SIMPLENESTEDURIMUTATOR_CID);
NS_DEFINE_NAMED_CID(NS_ASYNCSTREAMCOPIER_CID);
NS_DEFINE_NAMED_CID(NS_INPUTSTREAMPUMP_CID);
NS_DEFINE_NAMED_CID(NS_INPUTSTREAMCHANNEL_CID);
NS_DEFINE_NAMED_CID(NS_STREAMLOADER_CID);
NS_DEFINE_NAMED_CID(NS_INCREMENTALSTREAMLOADER_CID);
-NS_DEFINE_NAMED_CID(NS_UNICHARSTREAMLOADER_CID);
NS_DEFINE_NAMED_CID(NS_DOWNLOADER_CID);
NS_DEFINE_NAMED_CID(NS_BACKGROUNDFILESAVEROUTPUTSTREAM_CID);
NS_DEFINE_NAMED_CID(NS_BACKGROUNDFILESAVERSTREAMLISTENER_CID);
NS_DEFINE_NAMED_CID(NS_SYNCSTREAMLISTENER_CID);
NS_DEFINE_NAMED_CID(NS_REQUESTOBSERVERPROXY_CID);
NS_DEFINE_NAMED_CID(NS_SIMPLESTREAMLISTENER_CID);
NS_DEFINE_NAMED_CID(NS_STREAMLISTENERTEE_CID);
NS_DEFINE_NAMED_CID(NS_LOADGROUP_CID);
@@ -803,17 +801,16 @@ static const mozilla::Module::CIDEntry k
{ &kNS_SIMPLEURIMUTATOR_CID, false, nullptr, nsSimpleURIMutatorConstructor },
{ &kNS_SIMPLENESTEDURI_CID, false, nullptr, nsSimpleNestedURIMutatorConstructor }, // do_CreateInstance returns mutator
{ &kNS_SIMPLENESTEDURIMUTATOR_CID, false, nullptr, nsSimpleNestedURIMutatorConstructor },
{ &kNS_ASYNCSTREAMCOPIER_CID, false, nullptr, nsAsyncStreamCopierConstructor },
{ &kNS_INPUTSTREAMPUMP_CID, false, nullptr, nsInputStreamPumpConstructor },
{ &kNS_INPUTSTREAMCHANNEL_CID, false, nullptr, nsInputStreamChannelConstructor },
{ &kNS_STREAMLOADER_CID, false, nullptr, mozilla::net::nsStreamLoader::Create },
{ &kNS_INCREMENTALSTREAMLOADER_CID, false, nullptr, nsIncrementalStreamLoader::Create },
- { &kNS_UNICHARSTREAMLOADER_CID, false, nullptr, nsUnicharStreamLoader::Create },
{ &kNS_DOWNLOADER_CID, false, nullptr, nsDownloaderConstructor },
{ &kNS_BACKGROUNDFILESAVEROUTPUTSTREAM_CID, false, nullptr,
mozilla::net::BackgroundFileSaverOutputStreamConstructor },
{ &kNS_BACKGROUNDFILESAVERSTREAMLISTENER_CID, false, nullptr,
mozilla::net::BackgroundFileSaverStreamListenerConstructor },
{ &kNS_SYNCSTREAMLISTENER_CID, false, nullptr, nsSyncStreamListenerConstructor },
{ &kNS_REQUESTOBSERVERPROXY_CID, false, nullptr, nsRequestObserverProxyConstructor },
{ &kNS_SIMPLESTREAMLISTENER_CID, false, nullptr, nsSimpleStreamListenerConstructor },
@@ -930,17 +927,16 @@ static const mozilla::Module::ContractID
{ NS_IDNSERVICE_CONTRACTID, &kNS_IDNSERVICE_CID },
{ NS_EFFECTIVETLDSERVICE_CONTRACTID, &kNS_EFFECTIVETLDSERVICE_CID },
{ NS_SIMPLEURIMUTATOR_CONTRACTID, &kNS_SIMPLEURIMUTATOR_CID },
{ NS_ASYNCSTREAMCOPIER_CONTRACTID, &kNS_ASYNCSTREAMCOPIER_CID },
{ NS_INPUTSTREAMPUMP_CONTRACTID, &kNS_INPUTSTREAMPUMP_CID },
{ NS_INPUTSTREAMCHANNEL_CONTRACTID, &kNS_INPUTSTREAMCHANNEL_CID },
{ NS_STREAMLOADER_CONTRACTID, &kNS_STREAMLOADER_CID },
{ NS_INCREMENTALSTREAMLOADER_CONTRACTID, &kNS_INCREMENTALSTREAMLOADER_CID },
- { NS_UNICHARSTREAMLOADER_CONTRACTID, &kNS_UNICHARSTREAMLOADER_CID },
{ NS_DOWNLOADER_CONTRACTID, &kNS_DOWNLOADER_CID },
{ NS_BACKGROUNDFILESAVEROUTPUTSTREAM_CONTRACTID, &kNS_BACKGROUNDFILESAVEROUTPUTSTREAM_CID },
{ NS_BACKGROUNDFILESAVERSTREAMLISTENER_CONTRACTID, &kNS_BACKGROUNDFILESAVERSTREAMLISTENER_CID },
{ NS_SYNCSTREAMLISTENER_CONTRACTID, &kNS_SYNCSTREAMLISTENER_CID },
{ NS_REQUESTOBSERVERPROXY_CONTRACTID, &kNS_REQUESTOBSERVERPROXY_CID },
{ NS_SIMPLESTREAMLISTENER_CONTRACTID, &kNS_SIMPLESTREAMLISTENER_CID },
{ NS_STREAMLISTENERTEE_CONTRACTID, &kNS_STREAMLISTENERTEE_CID },
{ NS_LOADGROUP_CONTRACTID, &kNS_LOADGROUP_CID },
deleted file mode 100644
--- a/netwerk/test/unit/test_bug376660.js
+++ /dev/null
@@ -1,69 +0,0 @@
-ChromeUtils.import("resource://gre/modules/NetUtil.jsm");
-
-var listener = {
- expect_failure: false,
- QueryInterface: function listener_qi(iid) {
- if (iid.equals(Ci.nsISupports) ||
- iid.equals(Ci.nsIUnicharStreamLoaderObserver)) {
- return this;
- }
- throw Cr.NS_ERROR_NO_INTERFACE;
- },
- onDetermineCharset : function onDetermineCharset(loader, context, data)
- {
- return "us-ascii";
- },
- onStreamComplete : function onStreamComplete (loader, context, status, data)
- {
- try {
- if (this.expect_failure)
- Assert.ok(!Components.isSuccessCode(status));
- else
- Assert.equal(status, Cr.NS_OK);
- Assert.equal(data, "");
- Assert.notEqual(loader.channel, null);
- tests[current_test++]();
- } finally {
- do_test_finished();
- }
- }
-};
-
-var current_test = 0;
-var tests = [test1, test2, done];
-
-function run_test() {
- tests[current_test++]();
-}
-
-function test1() {
- var f =
- Cc["@mozilla.org/network/unichar-stream-loader;1"].
- createInstance(Ci.nsIUnicharStreamLoader);
- f.init(listener);
-
- var chan = NetUtil.newChannel({
- uri: "data:text/plain,",
- loadUsingSystemPrincipal: true
- });
- chan.asyncOpen2(f);
- do_test_pending();
-}
-
-function test2() {
- var f =
- Cc["@mozilla.org/network/unichar-stream-loader;1"].
- createInstance(Ci.nsIUnicharStreamLoader);
- f.init(listener);
-
- var chan = NetUtil.newChannel({
- uri: "http://localhost:0/",
- loadUsingSystemPrincipal: true
- });
- listener.expect_failure = true;
- chan.asyncOpen2(f);
- do_test_pending();
-}
-
-function done() {
-}
--- a/netwerk/test/unit/xpcshell.ini
+++ b/netwerk/test/unit/xpcshell.ini
@@ -110,17 +110,16 @@ requesttimeoutfactor = 2
[test_bug321706.js]
[test_bug331825.js]
[test_bug336501.js]
[test_bug337744.js]
[test_bug365133.js]
[test_bug368702.js]
[test_bug369787.js]
[test_bug371473.js]
-[test_bug376660.js]
[test_bug376844.js]
[test_bug376865.js]
[test_bug379034.js]
[test_bug380994.js]
[test_bug388281.js]
[test_bug396389.js]
skip-if = (os == 'win' && ccov) # Bug 1423667
[test_bug401564.js]