Bug 1079335 - Blob/File headers should be used in Fetch API, r=peterv - CLOSED TREE
--- a/content/base/src/File.cpp
+++ b/content/base/src/File.cpp
@@ -276,17 +276,16 @@ File::CreateFromFile(nsISupports* aParen
return file.forget();
}
File::File(nsISupports* aParent, FileImpl* aImpl)
: mImpl(aImpl)
, mParent(aParent)
{
MOZ_ASSERT(mImpl);
- SetIsDOMBinding();
#ifdef DEBUG
{
nsCOMPtr<nsPIDOMWindow> win = do_QueryInterface(aParent);
if (win) {
MOZ_ASSERT(win->IsInnerWindow());
}
}
--- a/dom/fetch/Request.cpp
+++ b/dom/fetch/Request.cpp
@@ -3,33 +3,32 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "Request.h"
#include "nsIUnicodeDecoder.h"
#include "nsIURI.h"
-#include "nsDOMFile.h"
#include "nsDOMString.h"
#include "nsNetUtil.h"
#include "nsPIDOMWindow.h"
#include "nsStreamUtils.h"
#include "nsStringStream.h"
#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"
#include "mozilla/dom/URL.h"
#include "mozilla/dom/workers/bindings/URL.h"
// dom/workers
-#include "File.h"
#include "WorkerPrivate.h"
namespace mozilla {
namespace dom {
NS_IMPL_CYCLE_COLLECTING_ADDREF(Request)
NS_IMPL_CYCLE_COLLECTING_RELEASE(Request)
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(Request, mOwner)
@@ -353,36 +352,27 @@ Request::ConsumeBody(ConsumeType aType,
// XXXnsm it is actually possible to avoid these duplicate allocations
// for the Blob case by having the Blob adopt the stream's memory
// directly, but I've not added a special case for now.
//
// This is similar to nsContentUtils::CreateBlobBuffer, but also deals
// 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: {
nsString decoded;
aRv = DecodeUTF8(buffer, decoded);
if (aRv.Failed()) {
return nullptr;
}