Backed out changeset 4666cde20909 (bug 1409327)

This commit is contained in:
Sebastian Hengst 2017-10-17 22:03:33 +02:00
Родитель a42ae45a57
Коммит 66e04dcde6
33 изменённых файлов: 122 добавлений и 136 удалений

Просмотреть файл

@ -196,36 +196,35 @@ DOMParser::ParseFromStream(nsIInputStream* aStream,
}
NS_IMETHODIMP
DOMParser::ParseFromStream(nsIInputStream* aStream,
const char* aCharset,
int32_t aContentLength,
const char* aContentType,
nsIDOMDocument** aResult)
DOMParser::ParseFromStream(nsIInputStream *stream,
const char *charset,
int32_t contentLength,
const char *contentType,
nsIDOMDocument **aResult)
{
NS_ENSURE_ARG(aStream);
NS_ENSURE_ARG(aContentType);
NS_ENSURE_ARG(stream);
NS_ENSURE_ARG(contentType);
NS_ENSURE_ARG_POINTER(aResult);
*aResult = nullptr;
bool svg = nsCRT::strcmp(aContentType, "image/svg+xml") == 0;
bool svg = nsCRT::strcmp(contentType, "image/svg+xml") == 0;
// For now, we can only create XML documents.
//XXXsmaug Should we create an HTMLDocument (in XHTML mode)
// for "application/xhtml+xml"?
if ((nsCRT::strcmp(aContentType, "text/xml") != 0) &&
(nsCRT::strcmp(aContentType, "application/xml") != 0) &&
(nsCRT::strcmp(aContentType, "application/xhtml+xml") != 0) &&
if ((nsCRT::strcmp(contentType, "text/xml") != 0) &&
(nsCRT::strcmp(contentType, "application/xml") != 0) &&
(nsCRT::strcmp(contentType, "application/xhtml+xml") != 0) &&
!svg)
return NS_ERROR_NOT_IMPLEMENTED;
nsresult rv;
// Put the nsCOMPtr out here so we hold a ref to the stream as needed
nsCOMPtr<nsIInputStream> stream = aStream;
nsCOMPtr<nsIInputStream> bufferedStream;
if (!NS_InputStreamIsBuffered(stream)) {
nsCOMPtr<nsIInputStream> bufferedStream;
rv = NS_NewBufferedInputStream(getter_AddRefs(bufferedStream),
stream.forget(), 4096);
rv = NS_NewBufferedInputStream(getter_AddRefs(bufferedStream), stream,
4096);
NS_ENSURE_SUCCESS(rv, rv);
stream = bufferedStream;
@ -244,11 +243,11 @@ DOMParser::ParseFromStream(nsIInputStream* aStream,
mPrincipal,
nsILoadInfo::SEC_FORCE_INHERIT_PRINCIPAL,
nsIContentPolicy::TYPE_OTHER,
nsDependentCString(aContentType));
nsDependentCString(contentType));
NS_ENSURE_STATE(parserChannel);
if (aCharset) {
parserChannel->SetContentCharset(nsDependentCString(aCharset));
if (charset) {
parserChannel->SetContentCharset(nsDependentCString(charset));
}
// Tell the document to start loading
@ -285,7 +284,7 @@ DOMParser::ParseFromStream(nsIInputStream* aStream,
if (NS_SUCCEEDED(rv) && NS_SUCCEEDED(status)) {
rv = listener->OnDataAvailable(parserChannel, nullptr, stream, 0,
aContentLength);
contentLength);
if (NS_FAILED(rv))
parserChannel->Cancel(rv);
parserChannel->GetStatus(&status);

Просмотреть файл

@ -252,8 +252,7 @@ nsSyncLoader::PushSyncStream(nsIStreamListener* aListener)
NS_ENSURE_SUCCESS(rv, rv);
mLoading = true;
rv = nsSyncLoadService::PushSyncStreamToListener(in.forget(), aListener,
mChannel);
rv = nsSyncLoadService::PushSyncStreamToListener(in, aListener, mChannel);
mLoading = false;
return rv;
@ -339,16 +338,14 @@ nsSyncLoadService::LoadDocument(nsIURI *aURI,
/* static */
nsresult
nsSyncLoadService::PushSyncStreamToListener(already_AddRefed<nsIInputStream> aIn,
nsSyncLoadService::PushSyncStreamToListener(nsIInputStream* aIn,
nsIStreamListener* aListener,
nsIChannel* aChannel)
{
nsCOMPtr<nsIInputStream> in = Move(aIn);
// Set up buffering stream
nsresult rv;
nsCOMPtr<nsIInputStream> bufferedStream;
if (!NS_InputStreamIsBuffered(in)) {
if (!NS_InputStreamIsBuffered(aIn)) {
int64_t chunkSize;
rv = aChannel->GetContentLength(&chunkSize);
if (NS_FAILED(rv) || chunkSize < 1) {
@ -356,11 +353,11 @@ nsSyncLoadService::PushSyncStreamToListener(already_AddRefed<nsIInputStream> aIn
}
chunkSize = std::min(int64_t(UINT16_MAX), chunkSize);
rv = NS_NewBufferedInputStream(getter_AddRefs(bufferedStream),
in.forget(), chunkSize);
rv = NS_NewBufferedInputStream(getter_AddRefs(bufferedStream), aIn,
chunkSize);
NS_ENSURE_SUCCESS(rv, rv);
in = bufferedStream;
aIn = bufferedStream;
}
// Load
@ -369,7 +366,7 @@ nsSyncLoadService::PushSyncStreamToListener(already_AddRefed<nsIInputStream> aIn
uint64_t sourceOffset = 0;
while (1) {
uint64_t readCount = 0;
rv = in->Available(&readCount);
rv = aIn->Available(&readCount);
if (NS_FAILED(rv) || !readCount) {
if (rv == NS_BASE_STREAM_CLOSED) {
// End of file, but not an error
@ -381,7 +378,7 @@ nsSyncLoadService::PushSyncStreamToListener(already_AddRefed<nsIInputStream> aIn
if (readCount > UINT32_MAX)
readCount = UINT32_MAX;
rv = aListener->OnDataAvailable(aChannel, nullptr, in,
rv = aListener->OnDataAvailable(aChannel, nullptr, aIn,
(uint32_t)std::min(sourceOffset, (uint64_t)UINT32_MAX),
(uint32_t)readCount);
if (NS_FAILED(rv)) {

Просмотреть файл

@ -51,13 +51,13 @@ public:
/**
* Read input stream aIn in chunks and deliver synchronously to aListener.
*
* @param aIn The stream to be read. The ownership of this stream is taken.
* @param aIn The stream to be read.
* @param aListener The listener that will receive
* OnStartRequest/OnDataAvailable/OnStopRequest
* notifications.
* @param aChannel The channel that aIn was opened from.
*/
static nsresult PushSyncStreamToListener(already_AddRefed<nsIInputStream> aIn,
static nsresult PushSyncStreamToListener(nsIInputStream* aIn,
nsIStreamListener* aListener,
nsIChannel* aChannel);
};

3
dom/cache/FileUtils.cpp поставляемый
Просмотреть файл

@ -737,8 +737,7 @@ LockedDirectoryPaddingGet(nsIFile* aBaseDir, int64_t* aPaddingSizeOut)
if (NS_WARN_IF(NS_FAILED(rv))) { return rv; }
nsCOMPtr<nsIInputStream> bufferedStream;
rv = NS_NewBufferedInputStream(getter_AddRefs(bufferedStream), stream.forget(),
512);
rv = NS_NewBufferedInputStream(getter_AddRefs(bufferedStream), stream, 512);
if (NS_WARN_IF(NS_FAILED(rv))) { return rv; }
nsCOMPtr<nsIObjectInputStream> objectStream =

Просмотреть файл

@ -529,7 +529,7 @@ FSMultipartFormData::AddNameBlobOrNullPair(const nsAString& aName, Blob* aBlob)
// Create buffered stream (for efficiency)
nsCOMPtr<nsIInputStream> bufferedStream;
rv = NS_NewBufferedInputStream(getter_AddRefs(bufferedStream),
fileStream.forget(), 8192);
fileStream, 8192);
NS_ENSURE_SUCCESS(rv, rv);
fileStream = bufferedStream;

Просмотреть файл

@ -2454,8 +2454,7 @@ GetBinaryInputStream(nsIFile* aDirectory,
}
nsCOMPtr<nsIInputStream> bufferedStream;
rv = NS_NewBufferedInputStream(getter_AddRefs(bufferedStream),
stream.forget(), 512);
rv = NS_NewBufferedInputStream(getter_AddRefs(bufferedStream), stream, 512);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}

Просмотреть файл

@ -1491,8 +1491,7 @@ nsresult nsWebBrowserPersist::SaveChannelInternal(
getter_AddRefs(fileInputStream));
NS_ENSURE_SUCCESS(rv, rv);
rv = NS_NewBufferedInputStream(getter_AddRefs(bufferedInputStream),
fileInputStream.forget(),
BUFFERED_OUTPUT_SIZE);
fileInputStream, BUFFERED_OUTPUT_SIZE);
NS_ENSURE_SUCCESS(rv, rv);
nsAutoCString contentType;
aChannel->GetContentType(contentType);

Просмотреть файл

@ -215,7 +215,7 @@ FileReaderSync::ReadAsText(Blob& aBlob,
}
nsCOMPtr<nsIInputStream> syncStream;
aRv = ConvertAsyncToSyncStream(blobSize - sniffBuf.Length(), stream.forget(),
aRv = ConvertAsyncToSyncStream(blobSize - sniffBuf.Length(), stream,
getter_AddRefs(syncStream));
if (NS_WARN_IF(aRv.Failed())) {
return;
@ -269,8 +269,7 @@ FileReaderSync::ReadAsDataURL(Blob& aBlob, nsAString& aResult,
}
nsCOMPtr<nsIInputStream> syncStream;
aRv = ConvertAsyncToSyncStream(blobSize, stream.forget(),
getter_AddRefs(syncStream));
aRv = ConvertAsyncToSyncStream(blobSize, stream, getter_AddRefs(syncStream));
if (NS_WARN_IF(aRv.Failed())) {
return;
}
@ -476,15 +475,13 @@ FileReaderSync::SyncRead(nsIInputStream* aStream, char* aBuffer,
nsresult
FileReaderSync::ConvertAsyncToSyncStream(uint64_t aStreamSize,
already_AddRefed<nsIInputStream> aAsyncStream,
nsIInputStream* aAsyncStream,
nsIInputStream** aSyncStream)
{
nsCOMPtr<nsIInputStream> asyncInputStream = Move(aAsyncStream);
// If the stream is not async, we just need it to be bufferable.
nsCOMPtr<nsIAsyncInputStream> asyncStream = do_QueryInterface(asyncInputStream);
nsCOMPtr<nsIAsyncInputStream> asyncStream = do_QueryInterface(aAsyncStream);
if (!asyncStream) {
return NS_NewBufferedInputStream(aSyncStream, asyncInputStream.forget(), 4096);
return NS_NewBufferedInputStream(aSyncStream, aAsyncStream, 4096);
}
nsAutoCString buffer;
@ -494,7 +491,7 @@ FileReaderSync::ConvertAsyncToSyncStream(uint64_t aStreamSize,
uint32_t read;
nsresult rv =
SyncRead(asyncInputStream, buffer.BeginWriting(), aStreamSize, &read);
SyncRead(aAsyncStream, buffer.BeginWriting(), aStreamSize, &read);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}

Просмотреть файл

@ -33,7 +33,7 @@ private:
nsAString &aResult);
nsresult ConvertAsyncToSyncStream(uint64_t aStreamSize,
already_AddRefed<nsIInputStream> aAsyncStream,
nsIInputStream* aAsyncStream,
nsIInputStream** aSyncStream);
nsresult SyncRead(nsIInputStream* aStream, char* aBuffer,

Просмотреть файл

@ -1116,8 +1116,7 @@ nsXBLService::FetchBindingDocument(nsIContent* aBoundElement, nsIDocument* aBoun
rv = channel->Open2(getter_AddRefs(in));
NS_ENSURE_SUCCESS(rv, rv);
rv = nsSyncLoadService::PushSyncStreamToListener(in.forget(), listener,
channel);
rv = nsSyncLoadService::PushSyncStreamToListener(in, listener, channel);
NS_ENSURE_SUCCESS(rv, rv);
doc.swap(*aResult);

Просмотреть файл

@ -2561,12 +2561,11 @@ XMLHttpRequestMainThread::MaybeLowerChannelPriority()
}
nsresult
XMLHttpRequestMainThread::InitiateFetch(already_AddRefed<nsIInputStream> aUploadStream,
XMLHttpRequestMainThread::InitiateFetch(nsIInputStream* aUploadStream,
int64_t aUploadLength,
nsACString& aUploadContentType)
{
nsresult rv;
nsCOMPtr<nsIInputStream> uploadStream = Move(aUploadStream);
// nsIRequest::LOAD_BACKGROUND prevents throbber from becoming active, which
// in turn keeps STOP button from becoming active. If the consumer passed in
@ -2616,16 +2615,16 @@ XMLHttpRequestMainThread::InitiateFetch(already_AddRefed<nsIInputStream> aUpload
}
}
if (uploadStream) {
if (aUploadStream) {
// If necessary, wrap the stream in a buffered stream so as to guarantee
// support for our upload when calling ExplicitSetUploadStream.
if (!NS_InputStreamIsBuffered(uploadStream)) {
nsCOMPtr<nsIInputStream> bufferedStream;
nsCOMPtr<nsIInputStream> bufferedStream;
if (!NS_InputStreamIsBuffered(aUploadStream)) {
rv = NS_NewBufferedInputStream(getter_AddRefs(bufferedStream),
uploadStream.forget(), 4096);
aUploadStream, 4096);
NS_ENSURE_SUCCESS(rv, rv);
uploadStream = bufferedStream;
aUploadStream = bufferedStream;
}
// We want to use a newer version of the upload channel that won't
@ -2634,7 +2633,7 @@ XMLHttpRequestMainThread::InitiateFetch(already_AddRefed<nsIInputStream> aUpload
// This assertion will fire if buggy extensions are installed
NS_ASSERTION(uploadChannel2, "http must support nsIUploadChannel2");
if (uploadChannel2) {
uploadChannel2->ExplicitSetUploadStream(uploadStream,
uploadChannel2->ExplicitSetUploadStream(aUploadStream,
aUploadContentType,
mUploadTotal, mRequestMethod,
false);
@ -2646,7 +2645,7 @@ XMLHttpRequestMainThread::InitiateFetch(already_AddRefed<nsIInputStream> aUpload
}
nsCOMPtr<nsIUploadChannel> uploadChannel =
do_QueryInterface(httpChannel);
uploadChannel->SetUploadStream(uploadStream, aUploadContentType,
uploadChannel->SetUploadStream(aUploadStream, aUploadContentType,
mUploadTotal);
// Reset the method to its original value
rv = httpChannel->SetRequestMethod(mRequestMethod);
@ -3054,7 +3053,7 @@ XMLHttpRequestMainThread::SendInternal(const BodyExtractorBase* aBody)
}
}
rv = InitiateFetch(uploadStream.forget(), mUploadTotal, uploadContentType);
rv = InitiateFetch(uploadStream, mUploadTotal, uploadContentType);
NS_ENSURE_SUCCESS(rv, rv);
// Start our timeout

Просмотреть файл

@ -261,7 +261,7 @@ public:
// request
nsresult CreateChannel();
nsresult InitiateFetch(already_AddRefed<nsIInputStream> aUploadStream,
nsresult InitiateFetch(nsIInputStream* aUploadStream,
int64_t aUploadLength,
nsACString& aUploadContentType);

Просмотреть файл

@ -333,8 +333,7 @@ CreateBufferedStream(const uint8_t *aBuffer, uint32_t aBufLen,
nsCOMPtr<nsIInputStream> aBufferedStream;
if (!NS_InputStreamIsBuffered(stream)) {
rv = NS_NewBufferedInputStream(getter_AddRefs(aBufferedStream),
stream.forget(), 4096);
rv = NS_NewBufferedInputStream(getter_AddRefs(aBufferedStream), stream, 4096);
NS_ENSURE_SUCCESS(rv, rv);
stream = aBufferedStream;
}

Просмотреть файл

@ -100,20 +100,20 @@ private:
};
/* static */ already_AddRefed<ImageOps::ImageBuffer>
ImageOps::CreateImageBuffer(already_AddRefed<nsIInputStream> aInputStream)
ImageOps::CreateImageBuffer(nsIInputStream* aInputStream)
{
nsCOMPtr<nsIInputStream> inputStream = Move(aInputStream);
MOZ_ASSERT(inputStream);
MOZ_ASSERT(aInputStream);
nsresult rv;
// Prepare the input stream.
if (!NS_InputStreamIsBuffered(inputStream)) {
nsCOMPtr<nsIInputStream> inputStream = aInputStream;
if (!NS_InputStreamIsBuffered(aInputStream)) {
nsCOMPtr<nsIInputStream> bufStream;
rv = NS_NewBufferedInputStream(getter_AddRefs(bufStream),
inputStream.forget(), 1024);
if (NS_WARN_IF(NS_FAILED(rv))) {
return nullptr;
aInputStream, 1024);
if (NS_SUCCEEDED(rv)) {
inputStream = bufStream;
}
}
@ -145,12 +145,11 @@ ImageOps::CreateImageBuffer(already_AddRefed<nsIInputStream> aInputStream)
}
/* static */ nsresult
ImageOps::DecodeMetadata(already_AddRefed<nsIInputStream> aInputStream,
ImageOps::DecodeMetadata(nsIInputStream* aInputStream,
const nsACString& aMimeType,
ImageMetadata& aMetadata)
{
nsCOMPtr<nsIInputStream> inputStream = Move(aInputStream);
RefPtr<ImageBuffer> buffer = CreateImageBuffer(inputStream.forget());
RefPtr<ImageBuffer> buffer = CreateImageBuffer(aInputStream);
return DecodeMetadata(buffer, aMimeType, aMetadata);
}
@ -194,13 +193,12 @@ ImageOps::DecodeMetadata(ImageBuffer* aBuffer,
}
/* static */ already_AddRefed<gfx::SourceSurface>
ImageOps::DecodeToSurface(already_AddRefed<nsIInputStream> aInputStream,
ImageOps::DecodeToSurface(nsIInputStream* aInputStream,
const nsACString& aMimeType,
uint32_t aFlags,
const Maybe<IntSize>& aSize /* = Nothing() */)
{
nsCOMPtr<nsIInputStream> inputStream = Move(aInputStream);
RefPtr<ImageBuffer> buffer = CreateImageBuffer(inputStream.forget());
RefPtr<ImageBuffer> buffer = CreateImageBuffer(aInputStream);
return DecodeToSurface(buffer, aMimeType, aFlags, aSize);
}

Просмотреть файл

@ -93,25 +93,23 @@ public:
* an ImageBuffer representing the given input stream is more efficient if one
* has multiple Decode* calls to make on that stream.
*
* @param aInputStream An input stream containing an encoded image. The
* ownership is taken.
* @param aInputStream An input stream containing an encoded image.
* @return An image buffer derived from the input stream.
*/
static already_AddRefed<ImageBuffer>
CreateImageBuffer(already_AddRefed<nsIInputStream> aInputStream);
CreateImageBuffer(nsIInputStream* aInputStream);
/**
* Decodes an image's metadata from an nsIInputStream into the given
* structure. This function may be called off-main-thread.
*
* @param aInputStream An input stream containing an encoded image. Ownership
* is taken.
* @param aInputStream An input stream containing an encoded image.
* @param aMimeType The MIME type of the image.
* @param aMetadata Where the image metadata is stored upon success.
* @return The status of the operation.
*/
static nsresult
DecodeMetadata(already_AddRefed<nsIInputStream> aInputStream,
DecodeMetadata(nsIInputStream* aInputStream,
const nsACString& aMimeType,
ImageMetadata& aMetadata);
@ -129,15 +127,14 @@ public:
* main-thread-only). That means that this function may be called
* off-main-thread.
*
* @param aInputStream An input stream containing an encoded image. The
* ownership is taken.
* @param aInputStream An input stream containing an encoded image.
* @param aMimeType The MIME type of the image.
* @param aFlags Flags of the imgIContainer::FLAG_DECODE_* variety.
* @return A SourceSurface containing the first frame of the image at its
* intrinsic size, or nullptr if the image cannot be decoded.
*/
static already_AddRefed<gfx::SourceSurface>
DecodeToSurface(already_AddRefed<nsIInputStream> aInputStream,
DecodeToSurface(nsIInputStream* aInputStream,
const nsACString& aMimeType,
uint32_t aFlags,
const Maybe<gfx::IntSize>& aSize = Nothing());

Просмотреть файл

@ -61,8 +61,7 @@ imgTools::DecodeImage(nsIInputStream* aInStr,
nsCOMPtr<nsIInputStream> inStream = aInStr;
if (!NS_InputStreamIsBuffered(aInStr)) {
nsCOMPtr<nsIInputStream> bufStream;
rv = NS_NewBufferedInputStream(getter_AddRefs(bufStream),
inStream.forget(), 1024);
rv = NS_NewBufferedInputStream(getter_AddRefs(bufStream), aInStr, 1024);
if (NS_SUCCEEDED(rv)) {
inStream = bufStream;
}

Просмотреть файл

@ -52,7 +52,7 @@ public:
void Go()
{
mSurface =
ImageOps::DecodeToSurface(mInputStream.forget(),
ImageOps::DecodeToSurface(mInputStream,
nsDependentCString(mimeType.c_str()),
imgIContainer::DECODE_FLAGS_DEFAULT);
if (!mSurface)

Просмотреть файл

@ -125,7 +125,7 @@ LoadFile(const char* aRelativePath)
if (!NS_InputStreamIsBuffered(inputStream)) {
nsCOMPtr<nsIInputStream> bufStream;
rv = NS_NewBufferedInputStream(getter_AddRefs(bufStream),
inputStream.forget(), 1024);
inputStream, 1024);
ASSERT_TRUE_OR_RETURN(NS_SUCCEEDED(rv), nullptr);
inputStream = bufStream;
}

Просмотреть файл

@ -57,7 +57,7 @@ public:
outputSize);
} else {
mSurface =
ImageOps::DecodeToSurface(mInputStream.forget(),
ImageOps::DecodeToSurface(mInputStream,
nsDependentCString(mTestCase.mMimeType),
imgIContainer::DECODE_FLAGS_DEFAULT,
outputSize);
@ -144,7 +144,7 @@ TEST_F(ImageDecodeToSurface, Corrupt)
ASSERT_TRUE(inputStream != nullptr);
RefPtr<SourceSurface> surface =
ImageOps::DecodeToSurface(inputStream.forget(),
ImageOps::DecodeToSurface(inputStream,
nsDependentCString(testCase.mMimeType),
imgIContainer::DECODE_FLAGS_DEFAULT);
EXPECT_TRUE(surface == nullptr);
@ -158,7 +158,7 @@ TEST_F(ImageDecodeToSurface, ICOMultipleSizes)
ASSERT_TRUE(inputStream != nullptr);
RefPtr<ImageOps::ImageBuffer> buffer =
ImageOps::CreateImageBuffer(inputStream.forget());
ImageOps::CreateImageBuffer(inputStream);
ASSERT_TRUE(buffer != nullptr);
ImageMetadata metadata;

Просмотреть файл

@ -1404,7 +1404,7 @@ Loader::LoadSheet(SheetLoadData* aLoadData,
// This will call back into OnStreamComplete
// and thence to ParseSheet. Regardless of whether this fails,
// SheetComplete has been called.
return nsSyncLoadService::PushSyncStreamToListener(stream.forget(),
return nsSyncLoadService::PushSyncStreamToListener(stream,
streamLoader,
channel);
}

Просмотреть файл

@ -727,9 +727,8 @@ nsInputStreamPump::CreateBufferedStreamIfNeeded()
return NS_OK;
}
nsCOMPtr<nsIAsyncInputStream> stream = mAsyncStream;
nsresult rv = NS_NewBufferedInputStream(getter_AddRefs(mBufferedStream),
stream.forget(), 4096);
mAsyncStream, 4096);
NS_ENSURE_SUCCESS(rv, rv);
return NS_OK;

Просмотреть файл

@ -1356,24 +1356,38 @@ NS_NewBufferedOutputStream(nsIOutputStream** aResult,
}
MOZ_MUST_USE nsresult
NS_NewBufferedInputStream(nsIInputStream** aResult,
already_AddRefed<nsIInputStream> aInputStream,
uint32_t aBufferSize)
NS_NewBufferedInputStream(nsIInputStream **result,
nsIInputStream *str,
uint32_t bufferSize)
{
nsCOMPtr<nsIInputStream> inputStream = Move(aInputStream);
nsresult rv;
nsCOMPtr<nsIBufferedInputStream> in =
do_CreateInstance(NS_BUFFEREDINPUTSTREAM_CONTRACTID, &rv);
if (NS_SUCCEEDED(rv)) {
rv = in->Init(inputStream, aBufferSize);
rv = in->Init(str, bufferSize);
if (NS_SUCCEEDED(rv)) {
in.forget(aResult);
in.forget(result);
}
}
return rv;
}
already_AddRefed<nsIInputStream>
NS_BufferInputStream(nsIInputStream *aInputStream,
uint32_t aBufferSize)
{
NS_ASSERTION(aInputStream, "No input stream given!");
nsCOMPtr<nsIInputStream> bis;
nsresult rv = NS_NewBufferedInputStream(getter_AddRefs(bis), aInputStream,
aBufferSize);
if (NS_SUCCEEDED(rv))
return bis.forget();
bis = aInputStream;
return bis.forget();
}
nsresult
NS_NewPostDataStream(nsIInputStream **result,
bool isFile,
@ -1390,8 +1404,7 @@ NS_NewPostDataStream(nsIInputStream **result,
rv = NS_NewLocalFileInputStream(getter_AddRefs(fileStream), file);
if (NS_SUCCEEDED(rv)) {
// wrap the file stream with a buffered input stream
rv = NS_NewBufferedInputStream(result, fileStream.forget(),
8192);
rv = NS_NewBufferedInputStream(result, fileStream, 8192);
}
}
return rv;

Просмотреть файл

@ -511,9 +511,9 @@ nsresult NS_NewLocalFileStream(nsIFileStream **result,
int32_t behaviorFlags = 0);
MOZ_MUST_USE nsresult
NS_NewBufferedInputStream(nsIInputStream** aResult,
already_AddRefed<nsIInputStream> aInputStream,
uint32_t aBufferSize);
NS_NewBufferedInputStream(nsIInputStream **result,
nsIInputStream *str,
uint32_t bufferSize);
// note: the resulting stream can be QI'ed to nsISafeOutputStream iff the
// provided stream supports it.
@ -521,6 +521,10 @@ nsresult NS_NewBufferedOutputStream(nsIOutputStream** aResult,
already_AddRefed<nsIOutputStream> aOutputStream,
uint32_t aBufferSize);
already_AddRefed<nsIInputStream>
NS_BufferInputStream(nsIInputStream *aInputStream,
uint32_t aBufferSize);
// returns an input stream compatible with nsIUploadChannel::SetUploadStream()
nsresult NS_NewPostDataStream(nsIInputStream **result,
bool isFile,

Просмотреть файл

@ -929,8 +929,7 @@ HttpBaseChannel::EnsureUploadStreamIsCloneable(nsIRunnable* aCallback)
if (NS_InputStreamIsBuffered(mUploadStream)) {
source = mUploadStream;
} else {
rv = NS_NewBufferedInputStream(getter_AddRefs(source),
mUploadStream.forget(), 4096);
rv = NS_NewBufferedInputStream(getter_AddRefs(source), mUploadStream, 4096);
NS_ENSURE_SUCCESS(rv, rv);
}

Просмотреть файл

@ -383,8 +383,7 @@ nsHttpTransaction::Init(uint32_t caps,
// that we write data in the largest chunks possible. this is actually
// necessary to workaround some common server bugs (see bug 137155).
nsCOMPtr<nsIInputStream> stream(do_QueryInterface(multi));
rv = NS_NewBufferedInputStream(getter_AddRefs(mRequestStream),
stream.forget(),
rv = NS_NewBufferedInputStream(getter_AddRefs(mRequestStream), stream,
nsIOService::gDefaultSegmentSize);
if (NS_FAILED(rv)) return rv;
} else {

Просмотреть файл

@ -486,13 +486,12 @@ nsSAXXMLReader::ParseFromStream(nsIInputStream *aStream,
// Put the nsCOMPtr out here so we hold a ref to the stream as needed
nsresult rv;
nsCOMPtr<nsIInputStream> stream = aStream;
if (!NS_InputStreamIsBuffered(stream)) {
nsCOMPtr<nsIInputStream> bufferedStream;
nsCOMPtr<nsIInputStream> bufferedStream;
if (!NS_InputStreamIsBuffered(aStream)) {
rv = NS_NewBufferedInputStream(getter_AddRefs(bufferedStream),
stream.forget(), 4096);
aStream, 4096);
NS_ENSURE_SUCCESS(rv, rv);
stream = bufferedStream;
aStream = bufferedStream;
}
rv = EnsureBaseURI();
@ -505,7 +504,7 @@ nsSAXXMLReader::ParseFromStream(nsIInputStream *aStream,
nsCOMPtr<nsIChannel> parserChannel;
rv = NS_NewInputStreamChannel(getter_AddRefs(parserChannel),
mBaseURI,
stream,
aStream,
nullPrincipal,
nsILoadInfo::SEC_REQUIRE_SAME_ORIGIN_DATA_IS_BLOCKED,
nsIContentPolicy::TYPE_OTHER,
@ -537,7 +536,7 @@ nsSAXXMLReader::ParseFromStream(nsIInputStream *aStream,
uint64_t offset = 0;
while (NS_SUCCEEDED(rv) && NS_SUCCEEDED(status)) {
uint64_t available;
rv = stream->Available(&available);
rv = aStream->Available(&available);
if (rv == NS_BASE_STREAM_CLOSED) {
rv = NS_OK;
available = 0;
@ -553,7 +552,7 @@ nsSAXXMLReader::ParseFromStream(nsIInputStream *aStream,
available = UINT32_MAX;
rv = mListener->OnDataAvailable(parserChannel, nullptr,
stream,
aStream,
offset,
(uint32_t)available);
if (NS_SUCCEEDED(rv))

Просмотреть файл

@ -497,7 +497,7 @@ RDFXMLDataSourceImpl::BlockingParse(nsIURI* aURL, nsIStreamListener* aConsumer)
// Wrap the channel's input stream in a buffered stream to ensure that
// ReadSegments is implemented (which OnDataAvailable expects).
nsCOMPtr<nsIInputStream> bufStream;
rv = NS_NewBufferedInputStream(getter_AddRefs(bufStream), in.forget(),
rv = NS_NewBufferedInputStream(getter_AddRefs(bufStream), in,
4096 /* buffer size */);
if (NS_FAILED(rv)) return rv;

Просмотреть файл

@ -1295,7 +1295,7 @@ FetchAndConvertUnsupportedPayloads::ConvertPayload(int64_t aId,
// Decode the input stream to a surface.
RefPtr<gfx::SourceSurface> surface =
image::ImageOps::DecodeToSurface(stream.forget(),
image::ImageOps::DecodeToSurface(stream,
aMimeType,
imgIContainer::DECODE_FLAGS_DEFAULT);
NS_ENSURE_STATE(surface);

Просмотреть файл

@ -339,9 +339,7 @@ HashStore::Open()
}
mFileSize = static_cast<uint32_t>(fileSize);
rv = NS_NewBufferedInputStream(getter_AddRefs(mInputStream),
origStream.forget(), mFileSize);
NS_ENSURE_SUCCESS(rv, rv);
mInputStream = NS_BufferInputStream(origStream, mFileSize);
rv = ReadHeader();
NS_ENSURE_SUCCESS(rv, rv);

Просмотреть файл

@ -239,10 +239,7 @@ VariableLengthPrefixSet::LoadFromFile(nsIFile* aFile)
MAX_BUFFER_SIZE);
// Convert to buffered stream
nsCOMPtr<nsIInputStream> in;
rv = NS_NewBufferedInputStream(getter_AddRefs(in), localInFile.forget(),
bufferSize);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIInputStream> in = NS_BufferInputStream(localInFile, bufferSize);
rv = mFixedPrefixSet->LoadPrefixes(in);
NS_ENSURE_SUCCESS(rv, rv);

Просмотреть файл

@ -352,10 +352,7 @@ nsUrlClassifierPrefixSet::LoadFromFile(nsIFile* aFile)
MAX_BUFFER_SIZE);
// Convert to buffered stream
nsCOMPtr<nsIInputStream> in;
rv = NS_NewBufferedInputStream(getter_AddRefs(in), localInFile.forget(),
bufferSize);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIInputStream> in = NS_BufferInputStream(localInFile, bufferSize);
rv = LoadPrefixes(in);
NS_ENSURE_SUCCESS(rv, rv);

Просмотреть файл

@ -31,7 +31,7 @@ void afl_interface_stream(const char* testFile, FuzzingTestFuncStream testFunc)
if (!NS_InputStreamIsBuffered(inputStream)) {
nsCOMPtr<nsIInputStream> bufStream;
rv = NS_NewBufferedInputStream(getter_AddRefs(bufStream),
inputStream.forget(), 1024);
inputStream, 1024);
MOZ_RELEASE_ASSERT(NS_SUCCEEDED(rv));
inputStream = bufStream;
}

Просмотреть файл

@ -54,7 +54,7 @@ TEST(CloneInputStream, NonCloneableInput_NoFallback)
// now. If this changes in the future, then we need a different stream
// type in this test.
nsCOMPtr<nsIInputStream> stream;
rv = NS_NewBufferedInputStream(getter_AddRefs(stream), base.forget(), 4096);
rv = NS_NewBufferedInputStream(getter_AddRefs(stream), base, 4096);
ASSERT_TRUE(NS_SUCCEEDED(rv));
nsCOMPtr<nsICloneableInputStream> cloneable = do_QueryInterface(stream);
@ -82,7 +82,7 @@ TEST(CloneInputStream, NonCloneableInput_Fallback)
// now. If this changes in the future, then we need a different stream
// type in this test.
nsCOMPtr<nsIInputStream> stream;
rv = NS_NewBufferedInputStream(getter_AddRefs(stream), base.forget(), 4096);
rv = NS_NewBufferedInputStream(getter_AddRefs(stream), base, 4096);
ASSERT_TRUE(NS_SUCCEEDED(rv));
nsCOMPtr<nsICloneableInputStream> cloneable = do_QueryInterface(stream);