mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-21 17:25:36 +00:00
Bug 1435899 - Use nsStringStream for the data channel buffer. r=bz
A pipe is no longer used for the input stream, instead we use a string stream which in most cases will be able to share the string data buffer rather than copying it. --HG-- extra : rebase_source : 592af1d2f55b7964d2b84c8e6f3def310557a866
This commit is contained in:
parent
888416a7cc
commit
78491d6518
@ -8,12 +8,10 @@
|
||||
#include "nsDataChannel.h"
|
||||
|
||||
#include "mozilla/Base64.h"
|
||||
#include "nsIOService.h"
|
||||
#include "nsDataHandler.h"
|
||||
#include "nsIPipe.h"
|
||||
#include "nsIInputStream.h"
|
||||
#include "nsIOutputStream.h"
|
||||
#include "nsEscape.h"
|
||||
#include "nsStringStream.h"
|
||||
|
||||
using namespace mozilla;
|
||||
|
||||
@ -86,26 +84,17 @@ nsDataChannel::OpenContentStream(bool async, nsIInputStream **result,
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIInputStream> bufInStream;
|
||||
nsCOMPtr<nsIOutputStream> bufOutStream;
|
||||
|
||||
// create an unbounded pipe.
|
||||
rv = NS_NewPipe(getter_AddRefs(bufInStream),
|
||||
getter_AddRefs(bufOutStream),
|
||||
net::nsIOService::gDefaultSegmentSize,
|
||||
UINT32_MAX,
|
||||
async, true);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
uint32_t contentLen;
|
||||
if (lBase64) {
|
||||
nsAutoCString decodedData;
|
||||
rv = Base64Decode(data, decodedData);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = bufOutStream->Write(decodedData.get(), decodedData.Length(), &contentLen);
|
||||
contentLen = decodedData.Length();
|
||||
rv = NS_NewCStringInputStream(getter_AddRefs(bufInStream), decodedData);
|
||||
} else {
|
||||
rv = bufOutStream->Write(data.Data(), data.Length(), &contentLen);
|
||||
contentLen = data.Length();
|
||||
rv = NS_NewCStringInputStream(getter_AddRefs(bufInStream), data);
|
||||
}
|
||||
|
||||
if (NS_FAILED(rv))
|
||||
|
Loading…
Reference in New Issue
Block a user