Bug 1079335 - Blob/File headers should be used in Fetch API, r=peterv - CLOSED TREE
☠☠ backed out by 47a1219c6324 ☠ ☠
authorAndrea Marchesini <amarchesini@mozilla.com>
Tue, 07 Oct 2014 17:02:28 +0100
changeset 209195 7d06b68c44d08db324aba6173f0c2681e82bd390
parent 209194 9a8039fb50557f576e7f8b6cb8c4f3c1ce574136
child 209196 47a1219c63246bd760e74c88ed67a722c0230367
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewerspeterv
bugs1079335
milestone35.0a1
Bug 1079335 - Blob/File headers should be used in Fetch API, r=peterv - CLOSED TREE
content/base/src/File.cpp
dom/fetch/Request.cpp
--- 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;
       }