зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1079335 - Blob/File headers should be used in Fetch API, r=peterv - CLOSED TREE
This commit is contained in:
Родитель
274873cbee
Коммит
227cb189b8
|
@ -281,7 +281,6 @@ File::File(nsISupports* aParent, FileImpl* aImpl)
|
|||
, mParent(aParent)
|
||||
{
|
||||
MOZ_ASSERT(mImpl);
|
||||
SetIsDOMBinding();
|
||||
|
||||
#ifdef DEBUG
|
||||
{
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
#include "nsIUnicodeDecoder.h"
|
||||
#include "nsIURI.h"
|
||||
|
||||
#include "nsDOMFile.h"
|
||||
#include "nsDOMString.h"
|
||||
#include "nsNetUtil.h"
|
||||
#include "nsPIDOMWindow.h"
|
||||
|
@ -17,6 +16,7 @@
|
|||
|
||||
#include "mozilla/ErrorResult.h"
|
||||
#include "mozilla/dom/EncodingUtils.h"
|
||||
#include "mozilla/dom/File.h"
|
||||
#include "mozilla/dom/Headers.h"
|
||||
#include "mozilla/dom/Fetch.h"
|
||||
#include "mozilla/dom/Promise.h"
|
||||
|
@ -24,7 +24,6 @@
|
|||
#include "mozilla/dom/workers/bindings/URL.h"
|
||||
|
||||
// dom/workers
|
||||
#include "File.h"
|
||||
#include "WorkerPrivate.h"
|
||||
|
||||
namespace mozilla {
|
||||
|
@ -358,26 +357,17 @@ Request::ConsumeBody(ConsumeType aType, ErrorResult& aRv)
|
|||
// with worker wrapping.
|
||||
uint32_t blobLen = buffer.Length();
|
||||
void* blobData = moz_malloc(blobLen);
|
||||
nsCOMPtr<nsIDOMBlob> blob;
|
||||
nsRefPtr<File> blob;
|
||||
if (blobData) {
|
||||
memcpy(blobData, buffer.BeginReading(), blobLen);
|
||||
blob = DOMFile::CreateMemoryFile(blobData, blobLen,
|
||||
NS_ConvertUTF8toUTF16(mMimeType));
|
||||
blob = File::CreateMemoryFile(GetParentObject(), blobData, blobLen,
|
||||
NS_ConvertUTF8toUTF16(mMimeType));
|
||||
} else {
|
||||
aRv = NS_ERROR_OUT_OF_MEMORY;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
JS::Rooted<JS::Value> jsBlob(cx);
|
||||
if (NS_IsMainThread()) {
|
||||
aRv = nsContentUtils::WrapNative(cx, blob, &jsBlob);
|
||||
if (aRv.Failed()) {
|
||||
return nullptr;
|
||||
}
|
||||
} else {
|
||||
jsBlob.setObject(*workers::file::CreateBlob(cx, blob));
|
||||
}
|
||||
promise->MaybeResolve(cx, jsBlob);
|
||||
promise->MaybeResolve(blob);
|
||||
return promise.forget();
|
||||
}
|
||||
case CONSUME_JSON: {
|
||||
|
|
Загрузка…
Ссылка в новой задаче