зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1424809 - Get rid of NS_NewPostDataStream, r=valentin
This commit is contained in:
Родитель
3373df795c
Коммит
b32bea6044
|
@ -101,6 +101,7 @@
|
|||
#include "nsICookieService.h"
|
||||
#include "nsIConsoleReportCollector.h"
|
||||
#include "nsObjectLoadingContent.h"
|
||||
#include "nsStringStream.h"
|
||||
|
||||
// we want to explore making the document own the load group
|
||||
// so we can associate the document URI with the load group.
|
||||
|
@ -622,8 +623,8 @@ SendPing(void* aClosure, nsIContent* aContent, nsIURI* aURI,
|
|||
NS_NAMED_LITERAL_CSTRING(uploadData, "PING");
|
||||
|
||||
nsCOMPtr<nsIInputStream> uploadStream;
|
||||
NS_NewPostDataStream(getter_AddRefs(uploadStream), false, uploadData);
|
||||
if (!uploadStream) {
|
||||
rv = NS_NewCStringInputStream(getter_AddRefs(uploadStream), uploadData);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -1359,43 +1359,6 @@ NS_NewBufferedInputStream(nsIInputStream** aResult,
|
|||
return rv;
|
||||
}
|
||||
|
||||
nsresult
|
||||
NS_NewPostDataStream(nsIInputStream **result,
|
||||
bool isFile,
|
||||
const nsACString &data)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
if (isFile) {
|
||||
nsCOMPtr<nsIFile> file;
|
||||
nsCOMPtr<nsIInputStream> fileStream;
|
||||
|
||||
rv = NS_NewNativeLocalFile(data, false, getter_AddRefs(file));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
// otherwise, create a string stream for the data (copies)
|
||||
nsCOMPtr<nsIStringInputStream> stream
|
||||
(do_CreateInstance("@mozilla.org/io/string-input-stream;1", &rv));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
rv = stream->SetData(data.BeginReading(), data.Length());
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
stream.forget(result);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
#define BUFFER_SIZE 4096
|
||||
|
|
|
@ -510,11 +510,6 @@ nsresult NS_NewBufferedOutputStream(nsIOutputStream** aResult,
|
|||
already_AddRefed<nsIOutputStream> aOutputStream,
|
||||
uint32_t aBufferSize);
|
||||
|
||||
// returns an input stream compatible with nsIUploadChannel::SetUploadStream()
|
||||
nsresult NS_NewPostDataStream(nsIInputStream **result,
|
||||
bool isFile,
|
||||
const nsACString &data);
|
||||
|
||||
/**
|
||||
* This function reads an inputStream and stores its content into a buffer. In
|
||||
* general, you should avoid using this function because, it blocks the current
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
#include "nsNetUtil.h"
|
||||
#include "nsProtectedAuthThread.h"
|
||||
#include "nsProxyRelease.h"
|
||||
#include "nsStringStream.h"
|
||||
#include "pkix/pkixtypes.h"
|
||||
#include "ssl.h"
|
||||
#include "sslproto.h"
|
||||
|
@ -140,9 +141,8 @@ nsHTTPDownloadEvent::Run()
|
|||
if (mRequestSession->mHasPostData)
|
||||
{
|
||||
nsCOMPtr<nsIInputStream> uploadStream;
|
||||
rv = NS_NewPostDataStream(getter_AddRefs(uploadStream),
|
||||
false,
|
||||
mRequestSession->mPostData);
|
||||
rv = NS_NewCStringInputStream(getter_AddRefs(uploadStream),
|
||||
mRequestSession->mPostData);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIUploadChannel> uploadChannel(do_QueryInterface(chan));
|
||||
|
|
Загрузка…
Ссылка в новой задаче