mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-15 11:13:29 +00:00
Backed out changeset abd96b988887 (bug 1202006)
This commit is contained in:
parent
6e58dff2dc
commit
c2b119130d
@ -12,7 +12,6 @@
|
||||
#endif
|
||||
#include "mozilla/ArrayUtils.h"
|
||||
#include "mozilla/CheckedInt.h"
|
||||
#include "mozilla/dom/BlobSet.h"
|
||||
#include "mozilla/dom/File.h"
|
||||
#include "mozilla/dom/FetchUtil.h"
|
||||
#include "mozilla/dom/FormData.h"
|
||||
@ -72,7 +71,6 @@
|
||||
#include "nsIUnicodeDecoder.h"
|
||||
#include "mozilla/dom/XMLHttpRequestBinding.h"
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "MultipartBlobImpl.h"
|
||||
#include "nsIPermissionManager.h"
|
||||
#include "nsMimeTypes.h"
|
||||
#include "nsIHttpChannelInternal.h"
|
||||
@ -294,7 +292,6 @@ XMLHttpRequestMainThread::ResetResponse()
|
||||
mResponseBlob = nullptr;
|
||||
mDOMBlob = nullptr;
|
||||
mBlobStorage = nullptr;
|
||||
mBlobSet = nullptr;
|
||||
mResultArrayBuffer = nullptr;
|
||||
mArrayBufferBuilder.reset();
|
||||
mResultJSON.setUndefined();
|
||||
@ -680,8 +677,8 @@ XMLHttpRequestMainThread::CreatePartialBlob(ErrorResult& aRv)
|
||||
return;
|
||||
}
|
||||
|
||||
// mBlobSet can be null if the request has been canceled
|
||||
if (!mBlobSet) {
|
||||
// mBlobStorage can be null if the request has been canceled
|
||||
if (!mBlobStorage) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -690,16 +687,7 @@ XMLHttpRequestMainThread::CreatePartialBlob(ErrorResult& aRv)
|
||||
mChannel->GetContentType(contentType);
|
||||
}
|
||||
|
||||
nsTArray<RefPtr<BlobImpl>> subImpls(mBlobSet->GetBlobImpls());
|
||||
RefPtr<BlobImpl> blobImpl =
|
||||
MultipartBlobImpl::Create(Move(subImpls),
|
||||
NS_ConvertASCIItoUTF16(contentType),
|
||||
aRv);
|
||||
if (NS_WARN_IF(aRv.Failed())) {
|
||||
return;
|
||||
}
|
||||
|
||||
mResponseBlob = Blob::Create(GetOwner(), blobImpl);
|
||||
mResponseBlob = mBlobStorage->GetBlob(GetOwner(), contentType, aRv);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP XMLHttpRequestMainThread::GetResponseType(nsAString& aResponseType)
|
||||
@ -1593,22 +1581,18 @@ XMLHttpRequestMainThread::StreamReaderFunc(nsIInputStream* in,
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
if (xmlHttpRequest->mResponseType == XMLHttpRequestResponseType::Blob) {
|
||||
if (xmlHttpRequest->mResponseType == XMLHttpRequestResponseType::Blob ||
|
||||
xmlHttpRequest->mResponseType == XMLHttpRequestResponseType::Moz_blob) {
|
||||
if (!xmlHttpRequest->mDOMBlob) {
|
||||
if (!xmlHttpRequest->mBlobStorage) {
|
||||
xmlHttpRequest->mBlobStorage = new MutableBlobStorage();
|
||||
}
|
||||
rv = xmlHttpRequest->mBlobStorage->Append(fromRawSegment, count);
|
||||
}
|
||||
} else if (xmlHttpRequest->mResponseType == XMLHttpRequestResponseType::Moz_blob) {
|
||||
if (!xmlHttpRequest->mDOMBlob) {
|
||||
if (!xmlHttpRequest->mBlobSet) {
|
||||
xmlHttpRequest->mBlobSet = new BlobSet();
|
||||
}
|
||||
rv = xmlHttpRequest->mBlobSet->AppendVoidPtr(fromRawSegment, count);
|
||||
}
|
||||
// Clear the cache so that the blob size is updated.
|
||||
xmlHttpRequest->mResponseBlob = nullptr;
|
||||
if (xmlHttpRequest->mResponseType == XMLHttpRequestResponseType::Moz_blob) {
|
||||
xmlHttpRequest->mResponseBlob = nullptr;
|
||||
}
|
||||
} else if ((xmlHttpRequest->mResponseType == XMLHttpRequestResponseType::Arraybuffer &&
|
||||
!xmlHttpRequest->mIsMappedArrayBuffer) ||
|
||||
xmlHttpRequest->mResponseType == XMLHttpRequestResponseType::Moz_chunked_arraybuffer) {
|
||||
@ -1685,7 +1669,6 @@ bool XMLHttpRequestMainThread::CreateDOMBlob(nsIRequest *request)
|
||||
NS_ConvertASCIItoUTF16(contentType));
|
||||
|
||||
mBlobStorage = nullptr;
|
||||
mBlobSet = nullptr;
|
||||
NS_ASSERTION(mResponseBody.IsEmpty(), "mResponseBody should be empty");
|
||||
return true;
|
||||
}
|
||||
@ -2055,48 +2038,24 @@ XMLHttpRequestMainThread::OnStopRequest(nsIRequest *request, nsISupports *ctxt,
|
||||
mResponseBlob = mDOMBlob;
|
||||
mDOMBlob = nullptr;
|
||||
} else {
|
||||
// mBlobStorage can be null if the channel is non-file non-cacheable
|
||||
// and if the response length is zero.
|
||||
if (!mBlobStorage) {
|
||||
mBlobStorage = new MutableBlobStorage();
|
||||
}
|
||||
// Smaller files may be written in cache map instead of separate files.
|
||||
// Also, no-store response cannot be written in persistent cache.
|
||||
nsAutoCString contentType;
|
||||
mChannel->GetContentType(contentType);
|
||||
|
||||
if (mResponseType == XMLHttpRequestResponseType::Blob) {
|
||||
// mBlobStorage can be null if the channel is non-file non-cacheable
|
||||
// and if the response length is zero.
|
||||
if (!mBlobStorage) {
|
||||
mBlobStorage = new MutableBlobStorage();
|
||||
}
|
||||
mResponseBlob = mBlobStorage->GetBlob(GetOwner(), contentType, rv);
|
||||
mBlobStorage = nullptr;
|
||||
|
||||
mResponseBlob = mBlobStorage->GetBlob(GetOwner(), contentType, rv);
|
||||
mBlobStorage = nullptr;
|
||||
|
||||
if (NS_WARN_IF(rv.Failed())) {
|
||||
return rv.StealNSResult();
|
||||
}
|
||||
} else {
|
||||
// mBlobSet can be null if the channel is non-file non-cacheable
|
||||
// and if the response length is zero.
|
||||
if (!mBlobSet) {
|
||||
mBlobSet = new BlobSet();
|
||||
}
|
||||
|
||||
nsTArray<RefPtr<BlobImpl>> subImpls(mBlobSet->GetBlobImpls());
|
||||
RefPtr<BlobImpl> blobImpl =
|
||||
MultipartBlobImpl::Create(Move(subImpls),
|
||||
NS_ConvertASCIItoUTF16(contentType),
|
||||
rv);
|
||||
mBlobSet = nullptr;
|
||||
|
||||
if (NS_WARN_IF(rv.Failed())) {
|
||||
return rv.StealNSResult();
|
||||
}
|
||||
|
||||
mResponseBlob = Blob::Create(GetOwner(), blobImpl);
|
||||
if (NS_WARN_IF(rv.Failed())) {
|
||||
return rv.StealNSResult();
|
||||
}
|
||||
}
|
||||
|
||||
MOZ_ASSERT(mResponseBlob);
|
||||
|
||||
mLoadTotal = mResponseBlob->GetSize(rv);
|
||||
if (NS_WARN_IF(rv.Failed())) {
|
||||
status = rv.StealNSResult();
|
||||
|
@ -55,7 +55,6 @@ namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
class Blob;
|
||||
class BlobSet;
|
||||
class FormData;
|
||||
class MutableBlobStorage;
|
||||
class URLSearchParams;
|
||||
@ -645,12 +644,9 @@ protected:
|
||||
// Non-null only when we are able to get a os-file representation of the
|
||||
// response, i.e. when loading from a file.
|
||||
RefPtr<Blob> mDOMBlob;
|
||||
// We stream data to mBlobStorage when response type is "blob" and mDOMBlob is
|
||||
// null.
|
||||
// We stream data to mBlobStorage when response type is "blob" or "moz-blob"
|
||||
// and mDOMBlob is null.
|
||||
nsAutoPtr<MutableBlobStorage> mBlobStorage;
|
||||
// We stream data to mBlobStorage when response type is "moz-blob" and
|
||||
// mDOMBlob is null.
|
||||
nsAutoPtr<BlobSet> mBlobSet;
|
||||
|
||||
nsString mOverrideMimeType;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user