mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-29 11:57:32 +09:00
Issue #1442 - Part 10b - Use nsIXHRSendable instead Blob/FormData/URLSearchParams. https://bugzilla.mozilla.org/show_bug.cgi?id=1329298 Pre-requisite for Part 11.
This commit is contained in:
parent
a4146b60a4
commit
a9520b2a7a
5 changed files with 18 additions and 50 deletions
|
|
@ -40,6 +40,7 @@
|
|||
#include "mozilla/dom/ServiceWorkerContainer.h"
|
||||
#include "mozilla/dom/StorageManager.h"
|
||||
#include "mozilla/dom/TCPSocket.h"
|
||||
#include "mozilla/dom/URLSearchParams.h"
|
||||
#include "mozilla/dom/workers/RuntimeService.h"
|
||||
#include "mozilla/Hal.h"
|
||||
#include "nsISiteSpecificUserAgent.h"
|
||||
|
|
@ -877,12 +878,12 @@ Navigator::SendBeacon(const nsAString& aUrl,
|
|||
}
|
||||
|
||||
if (aData.Value().IsBlob()) {
|
||||
BodyExtractor<Blob> body(&aData.Value().GetAsBlob());
|
||||
BodyExtractor<nsIXHRSendable> body(&aData.Value().GetAsBlob());
|
||||
return SendBeaconInternal(aUrl, &body, /* isBlob */ true, aRv);
|
||||
}
|
||||
|
||||
if (aData.Value().IsFormData()) {
|
||||
BodyExtractor<FormData> body(&aData.Value().GetAsFormData());
|
||||
BodyExtractor<nsIXHRSendable> body(&aData.Value().GetAsFormData());
|
||||
return SendBeaconInternal(aUrl, &body, /* isBlob */ false, aRv);
|
||||
}
|
||||
|
||||
|
|
@ -892,7 +893,7 @@ Navigator::SendBeacon(const nsAString& aUrl,
|
|||
}
|
||||
|
||||
if (aData.Value().IsURLSearchParams()) {
|
||||
BodyExtractor<URLSearchParams> body(&aData.Value().GetAsURLSearchParams());
|
||||
BodyExtractor<nsIXHRSendable> body(&aData.Value().GetAsURLSearchParams());
|
||||
return SendBeaconInternal(aUrl, &body, /* isBlob */ false, aRv);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -192,36 +192,6 @@ BodyExtractor<nsIInputStream>::GetAsStream(nsIInputStream** aResult,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
template<> nsresult
|
||||
BodyExtractor<Blob>::GetAsStream(nsIInputStream** aResult,
|
||||
uint64_t* aContentLength,
|
||||
nsACString& aContentTypeWithCharset,
|
||||
nsACString& aCharset) const
|
||||
{
|
||||
return mBody->GetSendInfo(aResult, aContentLength, aContentTypeWithCharset,
|
||||
aCharset);
|
||||
}
|
||||
|
||||
template<> nsresult
|
||||
BodyExtractor<FormData>::GetAsStream(nsIInputStream** aResult,
|
||||
uint64_t* aContentLength,
|
||||
nsACString& aContentTypeWithCharset,
|
||||
nsACString& aCharset) const
|
||||
{
|
||||
return mBody->GetSendInfo(aResult, aContentLength, aContentTypeWithCharset,
|
||||
aCharset);
|
||||
}
|
||||
|
||||
template<> nsresult
|
||||
BodyExtractor<URLSearchParams>::GetAsStream(nsIInputStream** aResult,
|
||||
uint64_t* aContentLength,
|
||||
nsACString& aContentTypeWithCharset,
|
||||
nsACString& aCharset) const
|
||||
{
|
||||
return mBody->GetSendInfo(aResult, aContentLength, aContentTypeWithCharset,
|
||||
aCharset);
|
||||
}
|
||||
|
||||
template<> nsresult
|
||||
BodyExtractor<nsIXHRSendable>::GetAsStream(nsIInputStream** aResult,
|
||||
uint64_t* aContentLength,
|
||||
|
|
|
|||
|
|
@ -24,8 +24,8 @@ public:
|
|||
};
|
||||
|
||||
// The implementation versions of this template are:
|
||||
// ArrayBuffer, ArrayBufferView, Blob, FormData, nsAString, nsIDocument,
|
||||
// nsIInputStream, nsIXHRSendable, URLSearchParams
|
||||
// ArrayBuffer, ArrayBufferView, nsIXHRSendable (Blob, FormData,
|
||||
// URLSearchParams), nsAString, nsIDocument, nsIInputStream
|
||||
template<typename Type>
|
||||
class BodyExtractor final : public BodyExtractorBase
|
||||
{
|
||||
|
|
|
|||
|
|
@ -746,13 +746,13 @@ ExtractByteStreamFromBody(const OwningArrayBufferOrArrayBufferViewOrBlobOrFormDa
|
|||
}
|
||||
if (aBodyInit.IsBlob()) {
|
||||
Blob& blob = aBodyInit.GetAsBlob();
|
||||
BodyExtractor<Blob> body(&blob);
|
||||
BodyExtractor<nsIXHRSendable> body(&blob);
|
||||
return body.GetAsStream(aStream, &aContentLength, aContentTypeWithCharset,
|
||||
charset);
|
||||
}
|
||||
if (aBodyInit.IsFormData()) {
|
||||
FormData& formData = aBodyInit.GetAsFormData();
|
||||
BodyExtractor<FormData> body(&formData);
|
||||
BodyExtractor<nsIXHRSendable> body(&formData);
|
||||
return body.GetAsStream(aStream, &aContentLength, aContentTypeWithCharset,
|
||||
charset);
|
||||
}
|
||||
|
|
@ -763,7 +763,7 @@ ExtractByteStreamFromBody(const OwningArrayBufferOrArrayBufferViewOrBlobOrFormDa
|
|||
}
|
||||
if (aBodyInit.IsURLSearchParams()) {
|
||||
URLSearchParams& usp = aBodyInit.GetAsURLSearchParams();
|
||||
BodyExtractor<URLSearchParams> body(&usp);
|
||||
BodyExtractor<nsIXHRSendable> body(&usp);
|
||||
return body.GetAsStream(aStream, &aContentLength, aContentTypeWithCharset,
|
||||
charset);
|
||||
}
|
||||
|
|
@ -795,14 +795,12 @@ ExtractByteStreamFromBody(const ArrayBufferOrArrayBufferViewOrBlobOrFormDataOrUS
|
|||
charset);
|
||||
}
|
||||
if (aBodyInit.IsBlob()) {
|
||||
Blob& blob = aBodyInit.GetAsBlob();
|
||||
BodyExtractor<Blob> body(&blob);
|
||||
BodyExtractor<nsIXHRSendable> body(&aBodyInit.GetAsBlob());
|
||||
return body.GetAsStream(aStream, &aContentLength, aContentTypeWithCharset,
|
||||
charset);
|
||||
}
|
||||
if (aBodyInit.IsFormData()) {
|
||||
FormData& formData = aBodyInit.GetAsFormData();
|
||||
BodyExtractor<FormData> body(&formData);
|
||||
BodyExtractor<nsIXHRSendable> body(&aBodyInit.GetAsFormData());
|
||||
return body.GetAsStream(aStream, &aContentLength, aContentTypeWithCharset,
|
||||
charset);
|
||||
}
|
||||
|
|
@ -812,8 +810,7 @@ ExtractByteStreamFromBody(const ArrayBufferOrArrayBufferViewOrBlobOrFormDataOrUS
|
|||
charset);
|
||||
}
|
||||
if (aBodyInit.IsURLSearchParams()) {
|
||||
URLSearchParams& usp = aBodyInit.GetAsURLSearchParams();
|
||||
BodyExtractor<URLSearchParams> body(&usp);
|
||||
BodyExtractor<nsIXHRSendable> body(&aBodyInit.GetAsURLSearchParams());
|
||||
return body.GetAsStream(aStream, &aContentLength, aContentTypeWithCharset,
|
||||
charset);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,6 +36,9 @@
|
|||
#include "mozilla/dom/MutableBlobStorage.h"
|
||||
#include "mozilla/dom/BodyExtractor.h"
|
||||
#include "mozilla/dom/TypedArray.h"
|
||||
#include "mozilla/dom/File.h"
|
||||
#include "mozilla/dom/FormData.h"
|
||||
#include "mozilla/dom/URLSearchParams.h"
|
||||
#include "mozilla/dom/XMLHttpRequest.h"
|
||||
#include "mozilla/dom/XMLHttpRequestBinding.h"
|
||||
#include "mozilla/dom/XMLHttpRequestEventTarget.h"
|
||||
|
|
@ -55,11 +58,8 @@ class nsIJSID;
|
|||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
class Blob;
|
||||
class BlobSet;
|
||||
class DOMString;
|
||||
class FormData;
|
||||
class URLSearchParams;
|
||||
class XMLHttpRequestUpload;
|
||||
struct OriginAttributesDictionary;
|
||||
|
||||
|
|
@ -325,14 +325,14 @@ public:
|
|||
virtual void
|
||||
Send(JSContext* /*aCx*/, Blob& aBlob, ErrorResult& aRv) override
|
||||
{
|
||||
BodyExtractor<Blob> body(&aBlob);
|
||||
BodyExtractor<nsIXHRSendable> body(&aBlob);
|
||||
aRv = SendInternal(&body);
|
||||
}
|
||||
|
||||
virtual void Send(JSContext* /*aCx*/, URLSearchParams& aURLSearchParams,
|
||||
ErrorResult& aRv) override
|
||||
{
|
||||
BodyExtractor<URLSearchParams> body(&aURLSearchParams);
|
||||
BodyExtractor<nsIXHRSendable> body(&aURLSearchParams);
|
||||
aRv = SendInternal(&body);
|
||||
}
|
||||
|
||||
|
|
@ -357,7 +357,7 @@ public:
|
|||
virtual void
|
||||
Send(JSContext* /*aCx*/, FormData& aFormData, ErrorResult& aRv) override
|
||||
{
|
||||
BodyExtractor<FormData> body(&aFormData);
|
||||
BodyExtractor<nsIXHRSendable> body(&aFormData);
|
||||
aRv = SendInternal(&body);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue