| Index: Source/bindings/v8/custom/V8BlobCustom.cpp
|
| diff --git a/Source/bindings/v8/custom/V8BlobCustom.cpp b/Source/bindings/v8/custom/V8BlobCustom.cpp
|
| index 1ed83165853396ff0b7e670b835b889c4f69aae3..418cb24b1e7172bd80273b2351efe0c131d0158c 100644
|
| --- a/Source/bindings/v8/custom/V8BlobCustom.cpp
|
| +++ b/Source/bindings/v8/custom/V8BlobCustom.cpp
|
| @@ -31,12 +31,7 @@
|
| #include "config.h"
|
| #include "V8Blob.h"
|
|
|
| -#include "bindings/v8/Dictionary.h"
|
| -#include "bindings/v8/ExceptionMessages.h"
|
| -#include "bindings/v8/V8Binding.h"
|
| -#include "bindings/v8/V8Utilities.h"
|
| -#include "bindings/v8/custom/V8ArrayBufferCustom.h"
|
| -#include "bindings/v8/custom/V8ArrayBufferViewCustom.h"
|
| +#include "bindings/v8/custom/V8BlobCustomHelpers.h"
|
| #include "core/fileapi/BlobBuilder.h"
|
| #include "wtf/RefPtr.h"
|
|
|
| @@ -61,60 +56,25 @@ void V8Blob::constructorCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
|
| }
|
| }
|
|
|
| - String type;
|
| + String contentType;
|
| String endings = "transparent";
|
| -
|
| if (info.Length() > 1) {
|
| if (!info[1]->IsObject()) {
|
| throwTypeError(ExceptionMessages::failedToConstruct("Blob", "The 2nd argument is not of type Object."), info.GetIsolate());
|
| return;
|
| }
|
|
|
| - V8TRYCATCH_VOID(Dictionary, dictionary, Dictionary(info[1], info.GetIsolate()));
|
| -
|
| - V8TRYCATCH_VOID(bool, containsEndings, dictionary.get("endings", endings));
|
| - if (containsEndings) {
|
| - if (endings != "transparent" && endings != "native") {
|
| - throwTypeError(ExceptionMessages::failedToConstruct("Blob", "The 2nd argument's \"endings\" property must be either \"transparent\" or \"native\"."), info.GetIsolate());
|
| - return;
|
| - }
|
| - }
|
| -
|
| - V8TRYCATCH_VOID(bool, containsType, dictionary.get("type", type));
|
| - UNUSED_PARAM(containsType);
|
| - if (!type.containsOnlyASCII()) {
|
| - throwError(v8SyntaxError, ExceptionMessages::failedToConstruct("Blob", "The 2nd argument's \"type\" property must consist of ASCII characters."), info.GetIsolate());
|
| + if (!V8BlobCustomHelpers::processBlobPropertyBag(info[1], info.GetIsolate(), "Blob", contentType, endings))
|
| return;
|
| - }
|
| - type = type.lower();
|
| }
|
| -
|
| ASSERT(endings == "transparent" || endings == "native");
|
|
|
| BlobBuilder blobBuilder;
|
| v8::Local<v8::Object> blobParts = v8::Local<v8::Object>::Cast(info[0]);
|
| - for (uint32_t i = 0; i < length; ++i) {
|
| - v8::Local<v8::Value> item = blobParts->Get(v8::Uint32::New(i, info.GetIsolate()));
|
| - ASSERT(!item.IsEmpty());
|
| - if (V8ArrayBuffer::hasInstance(item, info.GetIsolate(), worldType(info.GetIsolate()))) {
|
| - ArrayBuffer* arrayBuffer = V8ArrayBuffer::toNative(v8::Handle<v8::Object>::Cast(item));
|
| - ASSERT(arrayBuffer);
|
| - blobBuilder.append(arrayBuffer);
|
| - } else if (V8ArrayBufferView::hasInstance(item, info.GetIsolate(), worldType(info.GetIsolate()))) {
|
| - ArrayBufferView* arrayBufferView = V8ArrayBufferView::toNative(v8::Handle<v8::Object>::Cast(item));
|
| - ASSERT(arrayBufferView);
|
| - blobBuilder.append(arrayBufferView);
|
| - } else if (V8Blob::hasInstance(item, info.GetIsolate(), worldType(info.GetIsolate()))) {
|
| - Blob* blob = V8Blob::toNative(v8::Handle<v8::Object>::Cast(item));
|
| - ASSERT(blob);
|
| - blobBuilder.append(blob);
|
| - } else {
|
| - V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, stringValue, item);
|
| - blobBuilder.append(stringValue, endings);
|
| - }
|
| - }
|
| + if (!V8BlobCustomHelpers::processBlobParts(blobParts, length, info.GetIsolate(), endings, blobBuilder))
|
| + return;
|
|
|
| - RefPtr<Blob> blob = blobBuilder.getBlob(type);
|
| + RefPtr<Blob> blob = blobBuilder.createBlob(contentType);
|
| info.GetReturnValue().Set(toV8(blob.get(), info.Holder(), info.GetIsolate()));
|
| }
|
|
|
|
|