This source file includes following definitions.
- constructorCustom
#include "config.h"
#include "V8Blob.h"
#include "bindings/v8/ExceptionState.h"
#include "bindings/v8/custom/V8BlobCustomHelpers.h"
namespace WebCore {
void V8Blob::constructorCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
{
ExceptionState exceptionState(ExceptionState::ConstructionContext, "Blob", info.Holder(), info.GetIsolate());
if (!info.Length()) {
RefPtrWillBeRawPtr<Blob> blob = Blob::create();
v8SetReturnValue(info, blob.release());
return;
}
uint32_t length = 0;
if (info[0]->IsArray()) {
length = v8::Local<v8::Array>::Cast(info[0])->Length();
} else {
const int sequenceArgumentIndex = 0;
if (toV8Sequence(info[sequenceArgumentIndex], length, info.GetIsolate()).IsEmpty()) {
exceptionState.throwTypeError(ExceptionMessages::notAnArrayTypeArgumentOrValue(sequenceArgumentIndex + 1));
exceptionState.throwIfNeeded();
return;
}
}
V8BlobCustomHelpers::ParsedProperties properties(false);
if (info.Length() > 1) {
if (!info[1]->IsObject()) {
exceptionState.throwTypeError("The 2nd argument is not of type Object.");
exceptionState.throwIfNeeded();
return;
}
if (!properties.parseBlobPropertyBag(info[1], "Blob", exceptionState, info.GetIsolate())) {
exceptionState.throwIfNeeded();
return;
}
}
OwnPtr<BlobData> blobData = BlobData::create();
blobData->setContentType(properties.contentType());
v8::Local<v8::Object> blobParts = v8::Local<v8::Object>::Cast(info[0]);
if (!V8BlobCustomHelpers::processBlobParts(blobParts, length, properties.normalizeLineEndingsToNative(), *blobData, info.GetIsolate()))
return;
long long blobSize = blobData->length();
RefPtrWillBeRawPtr<Blob> blob = Blob::create(BlobDataHandle::create(blobData.release(), blobSize));
v8SetReturnValue(info, blob.release());
}
}