本文整理汇总了C++中Blob::blobDataHandle方法的典型用法代码示例。如果您正苦于以下问题:C++ Blob::blobDataHandle方法的具体用法?C++ Blob::blobDataHandle怎么用?C++ Blob::blobDataHandle使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Blob
的用法示例。
在下文中一共展示了Blob::blobDataHandle方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: create
Response* Response::create(ScriptState* scriptState, ScriptValue bodyValue, const Dictionary& init, ExceptionState& exceptionState)
{
v8::Local<v8::Value> body = bodyValue.v8Value();
ScriptValue reader;
v8::Isolate* isolate = scriptState->isolate();
ExecutionContext* executionContext = scriptState->executionContext();
OwnPtr<FetchDataConsumerHandle> bodyHandle;
String contentType;
if (bodyValue.isUndefined() || bodyValue.isNull()) {
// Note: The IDL processor cannot handle this situation. See
// https://crbug.com/335871.
} else if (V8Blob::hasInstance(body, isolate)) {
Blob* blob = V8Blob::toImpl(body.As<v8::Object>());
bodyHandle = FetchBlobDataConsumerHandle::create(executionContext, blob->blobDataHandle());
contentType = blob->type();
} else if (V8ArrayBuffer::hasInstance(body, isolate)) {
bodyHandle = FetchFormDataConsumerHandle::create(V8ArrayBuffer::toImpl(body.As<v8::Object>()));
} else if (V8ArrayBufferView::hasInstance(body, isolate)) {
bodyHandle = FetchFormDataConsumerHandle::create(V8ArrayBufferView::toImpl(body.As<v8::Object>()));
} else if (V8FormData::hasInstance(body, isolate)) {
RefPtr<EncodedFormData> formData = V8FormData::toImpl(body.As<v8::Object>())->encodeMultiPartFormData();
// Here we handle formData->boundary() as a C-style string. See
// FormDataEncoder::generateUniqueBoundaryString.
contentType = AtomicString("multipart/form-data; boundary=", AtomicString::ConstructFromLiteral) + formData->boundary().data();
bodyHandle = FetchFormDataConsumerHandle::create(executionContext, formData.release());
} else if (RuntimeEnabledFeatures::responseConstructedWithReadableStreamEnabled() && ReadableStreamOperations::isReadableStream(scriptState, bodyValue)) {
bodyHandle = ReadableStreamDataConsumerHandle::create(scriptState, bodyValue);
reader = ReadableStreamOperations::getReader(scriptState, bodyValue, exceptionState);
if (exceptionState.hadException()) {
reader = ScriptValue();
bodyHandle = createFetchDataConsumerHandleFromWebHandle(createUnexpectedErrorDataConsumerHandle());
exceptionState.clearException();
} else {
bodyHandle = ReadableStreamDataConsumerHandle::create(scriptState, reader);
}
} else {
String string = toUSVString(isolate, body, exceptionState);
if (exceptionState.hadException())
return nullptr;
bodyHandle = FetchFormDataConsumerHandle::create(string);
contentType = "text/plain;charset=UTF-8";
}
// TODO(yhirano): Add the URLSearchParams case.
Response* response = create(executionContext, bodyHandle.release(), contentType, ResponseInit(init, exceptionState), exceptionState);
if (!exceptionState.hadException() && !reader.isEmpty()) {
// Add a hidden reference so that the weak persistent in the
// ReadableStreamDataConsumerHandle will be valid as long as the
// Response is valid.
v8::Local<v8::Value> wrapper = toV8(response, scriptState);
if (wrapper.IsEmpty()) {
exceptionState.throwTypeError("Cannot create a Response wrapper");
return nullptr;
}
ASSERT(wrapper->IsObject());
V8HiddenValue::setHiddenValue(scriptState, wrapper.As<v8::Object>(), V8HiddenValue::readableStreamReaderInResponse(scriptState->isolate()), reader.v8Value());
}
return response;
}
示例2: startLoading
void FileReaderSync::startLoading(ExecutionContext* executionContext, FileReaderLoader& loader, const Blob& blob, ExceptionState& exceptionState)
{
loader.start(executionContext, blob.blobDataHandle());
if (loader.errorCode())
FileError::throwDOMException(exceptionState, loader.errorCode());
}