Bug 1377589 - FileReader should create a pipe if the stream is blocking, r=smaug

This commit is contained in:
Andrea Marchesini 2017-07-14 15:31:23 +02:00
parent 10b5520799
commit 178c9eeabc

View File

@ -373,22 +373,30 @@ FileReader::ReadFileContent(Blob& aBlob,
mDataFormat = aDataFormat;
CopyUTF16toUTF8(aCharset, mCharset);
nsresult rv;
nsCOMPtr<nsIStreamTransportService> sts =
do_GetService(kStreamTransportServiceCID, &rv);
if (NS_WARN_IF(NS_FAILED(rv))) {
aRv.Throw(rv);
return;
}
nsCOMPtr<nsIInputStream> stream;
mBlob->GetInternalStream(getter_AddRefs(stream), aRv);
if (NS_WARN_IF(aRv.Failed())) {
return;
}
bool nonBlocking = false;
aRv = stream->IsNonBlocking(&nonBlocking);
if (NS_WARN_IF(aRv.Failed())) {
return;
}
mAsyncStream = do_QueryInterface(stream);
if (!mAsyncStream) {
// We want to have a non-blocking nsIAsyncInputStream.
if (!mAsyncStream || !nonBlocking) {
nsresult rv;
nsCOMPtr<nsIStreamTransportService> sts =
do_GetService(kStreamTransportServiceCID, &rv);
if (NS_WARN_IF(NS_FAILED(rv))) {
aRv.Throw(rv);
return;
}
nsCOMPtr<nsITransport> transport;
aRv = sts->CreateInputTransport(stream,
/* aStartOffset */ 0,