mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-01 00:32:11 +00:00
Backed out changeset 03e4f9175b16 (bug 1409329)
This commit is contained in:
parent
66e04dcde6
commit
b1cdb2af00
@ -2321,9 +2321,8 @@ nsWebBrowserPersist::MakeOutputStreamFromFile(
|
||||
rv = fileOutputStream->Init(aFile, ioFlags, -1, 0);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = NS_NewBufferedOutputStream(aOutputStream, fileOutputStream.forget(),
|
||||
BUFFERED_OUTPUT_SIZE);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
*aOutputStream = NS_BufferOutputStream(fileOutputStream,
|
||||
BUFFERED_OUTPUT_SIZE).take();
|
||||
|
||||
if (mPersistFlags & PERSIST_FLAGS_CLEANUP_ON_FAILURE)
|
||||
{
|
||||
|
@ -664,8 +664,8 @@ RespondWithHandler::ResolvedCallback(JSContext* aCx, JS::Handle<JS::Value> aValu
|
||||
// objects which may or many not play well with NS_InputStreamIsBuffered().
|
||||
if (!NS_OutputStreamIsBuffered(responseBody)) {
|
||||
nsCOMPtr<nsIOutputStream> buffered;
|
||||
rv = NS_NewBufferedOutputStream(getter_AddRefs(buffered),
|
||||
responseBody.forget(), kCopySegmentSize);
|
||||
rv = NS_NewBufferedOutputStream(getter_AddRefs(buffered), responseBody,
|
||||
kCopySegmentSize);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return;
|
||||
}
|
||||
|
@ -105,7 +105,7 @@ public:
|
||||
// Get a buffered output stream 4096 bytes big, to optimize writes.
|
||||
nsCOMPtr<nsIOutputStream> bufferedOutputStream;
|
||||
res = NS_NewBufferedOutputStream(getter_AddRefs(bufferedOutputStream),
|
||||
outStream.forget(), 4096);
|
||||
outStream, 4096);
|
||||
if (NS_FAILED(res)) {
|
||||
return res;
|
||||
}
|
||||
|
@ -270,9 +270,9 @@ NS_IMETHODIMP nsZipWriter::Open(nsIFile *aFile, int32_t aIoFlags)
|
||||
return rv;
|
||||
}
|
||||
|
||||
rv = NS_NewBufferedOutputStream(getter_AddRefs(mStream), stream.forget(),
|
||||
64 * 1024);
|
||||
rv = NS_NewBufferedOutputStream(getter_AddRefs(mStream), stream, 64 * 1024);
|
||||
if (NS_FAILED(rv)) {
|
||||
stream->Close();
|
||||
mHeaders.Clear();
|
||||
mEntryHash.Clear();
|
||||
return rv;
|
||||
|
@ -3534,7 +3534,7 @@ public:
|
||||
}
|
||||
|
||||
rv = NS_NewBufferedOutputStream(
|
||||
getter_AddRefs(outStream), outStreamSink.forget(), 4096);
|
||||
getter_AddRefs(outStream), outStreamSink, 4096);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
@ -620,9 +620,10 @@ BackgroundFileSaver::ProcessStateChange()
|
||||
PR_WRONLY | creationIoFlags, 0600);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = NS_NewBufferedOutputStream(getter_AddRefs(outputStream),
|
||||
outputStream.forget(), BUFFERED_IO_SIZE);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
outputStream = NS_BufferOutputStream(outputStream, BUFFERED_IO_SIZE);
|
||||
if (!outputStream) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
// Wrap the output stream so that it feeds the digest context if needed.
|
||||
if (mDigestContext) {
|
||||
|
@ -1337,24 +1337,38 @@ NS_NewLocalFileStream(nsIFileStream **result,
|
||||
}
|
||||
|
||||
nsresult
|
||||
NS_NewBufferedOutputStream(nsIOutputStream** aResult,
|
||||
already_AddRefed<nsIOutputStream> aOutputStream,
|
||||
uint32_t aBufferSize)
|
||||
NS_NewBufferedOutputStream(nsIOutputStream **result,
|
||||
nsIOutputStream *str,
|
||||
uint32_t bufferSize)
|
||||
{
|
||||
nsCOMPtr<nsIOutputStream> outputStream = Move(aOutputStream);
|
||||
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIBufferedOutputStream> out =
|
||||
do_CreateInstance(NS_BUFFEREDOUTPUTSTREAM_CONTRACTID, &rv);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
rv = out->Init(outputStream, aBufferSize);
|
||||
rv = out->Init(str, bufferSize);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
out.forget(aResult);
|
||||
out.forget(result);
|
||||
}
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
already_AddRefed<nsIOutputStream>
|
||||
NS_BufferOutputStream(nsIOutputStream *aOutputStream,
|
||||
uint32_t aBufferSize)
|
||||
{
|
||||
NS_ASSERTION(aOutputStream, "No output stream given!");
|
||||
|
||||
nsCOMPtr<nsIOutputStream> bos;
|
||||
nsresult rv = NS_NewBufferedOutputStream(getter_AddRefs(bos), aOutputStream,
|
||||
aBufferSize);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
return bos.forget();
|
||||
|
||||
bos = aOutputStream;
|
||||
return bos.forget();
|
||||
}
|
||||
|
||||
MOZ_MUST_USE nsresult
|
||||
NS_NewBufferedInputStream(nsIInputStream **result,
|
||||
nsIInputStream *str,
|
||||
|
@ -517,10 +517,24 @@ NS_NewBufferedInputStream(nsIInputStream **result,
|
||||
|
||||
// note: the resulting stream can be QI'ed to nsISafeOutputStream iff the
|
||||
// provided stream supports it.
|
||||
nsresult NS_NewBufferedOutputStream(nsIOutputStream** aResult,
|
||||
already_AddRefed<nsIOutputStream> aOutputStream,
|
||||
uint32_t aBufferSize);
|
||||
nsresult NS_NewBufferedOutputStream(nsIOutputStream **result,
|
||||
nsIOutputStream *str,
|
||||
uint32_t bufferSize);
|
||||
|
||||
/**
|
||||
* Attempts to buffer a given stream. If this fails, it returns the
|
||||
* passed-in stream.
|
||||
*
|
||||
* @param aOutputStream
|
||||
* The output stream we want to buffer. This cannot be null.
|
||||
* @param aBufferSize
|
||||
* The size of the buffer for the buffered output stream.
|
||||
* @returns an nsIOutputStream that is buffered with the specified buffer size,
|
||||
* or is aOutputStream if creating the new buffered stream failed.
|
||||
*/
|
||||
already_AddRefed<nsIOutputStream>
|
||||
NS_BufferOutputStream(nsIOutputStream *aOutputStream,
|
||||
uint32_t aBufferSize);
|
||||
already_AddRefed<nsIInputStream>
|
||||
NS_BufferInputStream(nsIInputStream *aInputStream,
|
||||
uint32_t aBufferSize);
|
||||
|
3
netwerk/cache/nsDiskCacheDeviceSQL.cpp
vendored
3
netwerk/cache/nsDiskCacheDeviceSQL.cpp
vendored
@ -1815,8 +1815,7 @@ nsOfflineCacheDevice::OpenOutputStreamForEntry(nsCacheEntry *entry,
|
||||
|
||||
nsCOMPtr<nsIOutputStream> bufferedOut;
|
||||
nsresult rv =
|
||||
NS_NewBufferedOutputStream(getter_AddRefs(bufferedOut), out.forget(),
|
||||
16 * 1024);
|
||||
NS_NewBufferedOutputStream(getter_AddRefs(bufferedOut), out, 16 * 1024);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
bufferedOut.swap(*result);
|
||||
|
@ -766,8 +766,7 @@ RDFXMLDataSourceImpl::rdfXMLFlush(nsIURI *aURI)
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCOMPtr<nsIOutputStream> bufferedOut;
|
||||
rv = NS_NewBufferedOutputStream(getter_AddRefs(bufferedOut),
|
||||
out.forget(), 4096);
|
||||
rv = NS_NewBufferedOutputStream(getter_AddRefs(bufferedOut), out, 4096);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = Serialize(bufferedOut);
|
||||
|
@ -281,8 +281,7 @@ nsCertOverrideService::Write(const MutexAutoLock& aProofOfLock)
|
||||
|
||||
// get a buffered output stream 4096 bytes big, to optimize writes
|
||||
nsCOMPtr<nsIOutputStream> bufferedOutputStream;
|
||||
rv = NS_NewBufferedOutputStream(getter_AddRefs(bufferedOutputStream),
|
||||
fileOutputStream.forget(), 4096);
|
||||
rv = NS_NewBufferedOutputStream(getter_AddRefs(bufferedOutputStream), fileOutputStream, 4096);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
@ -275,10 +275,8 @@ VariableLengthPrefixSet::StoreToFile(nsIFile* aFile)
|
||||
}
|
||||
|
||||
// Convert to buffered stream
|
||||
nsCOMPtr<nsIOutputStream> out;
|
||||
rv = NS_NewBufferedOutputStream(getter_AddRefs(out), localOutFile.forget(),
|
||||
std::min(fileSize, MAX_BUFFER_SIZE));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
nsCOMPtr<nsIOutputStream> out =
|
||||
NS_BufferOutputStream(localOutFile, std::min(fileSize, MAX_BUFFER_SIZE));
|
||||
|
||||
rv = mFixedPrefixSet->WritePrefixes(out);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
@ -385,10 +385,8 @@ nsUrlClassifierPrefixSet::StoreToFile(nsIFile* aFile)
|
||||
}
|
||||
|
||||
// Convert to buffered stream
|
||||
nsCOMPtr<nsIOutputStream> out;
|
||||
rv = NS_NewBufferedOutputStream(getter_AddRefs(out), localOutFile.forget(),
|
||||
std::min(fileSize, MAX_BUFFER_SIZE));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
nsCOMPtr<nsIOutputStream> out =
|
||||
NS_BufferOutputStream(localOutFile, std::min(fileSize, MAX_BUFFER_SIZE));
|
||||
|
||||
rv = WritePrefixes(out);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
Loading…
Reference in New Issue
Block a user