void ReadableStreamToSharedBufferSink::enqueue(const BufferSource& buffer)
{
    if (!buffer.length())
        return;

    if (m_callback) {
        ReadableStreamChunk chunk { buffer.data(), buffer.length() };
        m_callback(&chunk);
    }
}
Example #2
0
String TextDecoder::decode(const BufferSource& input, const TextDecodeOptions& options, ExceptionState& exceptionState)
{
    ASSERT(!input.isNull());
    if (input.isArrayBufferView()) {
        const char* start = static_cast<const char*>(input.getAsArrayBufferView()->baseAddress());
        size_t length = input.getAsArrayBufferView()->byteLength();
        return decode(start, length, options, exceptionState);
    }
    ASSERT(input.isArrayBuffer());
    const char* start = static_cast<const char*>(input.getAsArrayBuffer()->data());
    size_t length = input.getAsArrayBuffer()->byteLength();
    return decode(start, length, options, exceptionState);
}
Example #3
0
DOMArrayPiece::DOMArrayPiece(const BufferSource& bufferSource)
{
    void* data = nullptr;
    unsigned len = 0;

    if (bufferSource.isArrayBuffer()) {
        data = bufferSource.getAsArrayBuffer()->data();
        len = bufferSource.getAsArrayBuffer()->byteLength();
    } else if (bufferSource.isArrayBufferView()) {
        data = bufferSource.getAsArrayBufferView()->baseAddress();
        len = bufferSource.getAsArrayBufferView()->byteLength();
    }
    initWithData(data, len);
}