void SourceBuffer::appendBuffer(PassRefPtr<DOMArrayBufferView> data, ExceptionState& exceptionState) { WTF_LOG(Media, "SourceBuffer(%p)::appendBuffer size=%u", this, data->byteLength()); // Section 3.2 appendBuffer() // https://dvcs.w3.org/hg/html-media/raw-file/default/media-source/media-source.html#widl-SourceBuffer-appendBuffer-void-ArrayBufferView-data appendBufferInternal(static_cast<const unsigned char*>(data->baseAddress()), data->byteLength(), exceptionState); }
PassRefPtr<DataView> DataView::create(PassRefPtr<ArrayBuffer> buffer, unsigned byteOffset, unsigned byteLength) { RELEASE_ASSERT(byteOffset <= buffer->byteLength()); CheckedInt<uint32_t> checkedOffset(byteOffset); CheckedInt<uint32_t> checkedLength(byteLength); CheckedInt<uint32_t> checkedMax = checkedOffset + checkedLength; RELEASE_ASSERT(checkedMax.isValid()); RELEASE_ASSERT(checkedMax.value() <= buffer->byteLength()); return adoptRef(new DataView(buffer, byteOffset, byteLength)); }
PassRefPtr<DataView> DataView::create(PassRefPtr<ArrayBuffer> buffer, unsigned byteOffset, unsigned byteLength) { if (byteOffset > buffer->byteLength()) return 0; Checked<uint32_t, RecordOverflow> checkedOffset(byteOffset); Checked<uint32_t, RecordOverflow> checkedLength(byteLength); Checked<uint32_t, RecordOverflow> checkedMax = checkedOffset + checkedLength; if (checkedMax.hasOverflowed() || checkedMax.unsafeGet() > buffer->byteLength()) return 0; return adoptRef(new DataView(buffer, byteOffset, byteLength)); }
PassRefPtr<DataView> DataView::create(PassRefPtr<ArrayBuffer> buffer, unsigned byteOffset, unsigned byteLength) { if (byteOffset > buffer->byteLength()) return 0; CheckedInt<uint32_t> checkedOffset(byteOffset); CheckedInt<uint32_t> checkedLength(byteLength); CheckedInt<uint32_t> checkedMax = checkedOffset + checkedLength; if (!checkedMax.isValid() || checkedMax.value() > buffer->byteLength()) return 0; return adoptRef(new DataView(buffer, byteOffset, byteLength)); }
void RTCDataChannel::send(PassRefPtr<ArrayBufferView> data, ExceptionState& exceptionState) { if (!m_handler->sendRawData(static_cast<const char*>(data->baseAddress()), data->byteLength())) { // FIXME: This should not throw an exception but instead forcefully close the data channel. throwCouldNotSendDataException(exceptionState); } }
PassRefPtr<FontFace> FontFace::create(ExecutionContext* context, const AtomicString& family, PassRefPtr<ArrayBuffer> source, const Dictionary& descriptors, ExceptionState& exceptionState) { RefPtr<FontFace> fontFace = adoptRefWillBeRefCountedGarbageCollected<FontFace>(new FontFace()); if (initFontFace(fontFace.get(), context, family, descriptors, exceptionState)) fontFace->initCSSFontFace(static_cast<const unsigned char*>(source->data()), source->byteLength()); return fontFace.release(); }
ScriptPromise MediaKeys::setServerCertificateInternal(ScriptState* scriptState, PassRefPtr<ArrayBuffer> serverCertificate) { // From https://dvcs.w3.org/hg/html-media/raw-file/default/encrypted-media/encrypted-media.html#dom-setservercertificate: // The setServerCertificate(serverCertificate) method provides a server // certificate to be used to encrypt messages to the license server. // It must run the following steps: // 1. If serverCertificate is an empty array, return a promise rejected // with a new DOMException whose name is "InvalidAccessError". if (!serverCertificate->byteLength()) { return ScriptPromise::rejectWithDOMException( scriptState, DOMException::create(InvalidAccessError, "The serverCertificate parameter is empty.")); } // 2. If the keySystem does not support server certificates, return a // promise rejected with a new DOMException whose name is // "NotSupportedError". // (Let the CDM decide whether to support this or not.) // 3. Let certificate be a copy of the contents of the serverCertificate // parameter. // (Done in caller.) // 4. Let promise be a new promise. SimpleContentDecryptionModuleResult* result = new SimpleContentDecryptionModuleResult(scriptState); ScriptPromise promise = result->promise(); // 5. Run the following steps asynchronously (documented in timerFired()). m_pendingActions.append(PendingAction::CreatePendingSetServerCertificate(result, serverCertificate)); if (!m_timer.isActive()) m_timer.startOneShot(0, FROM_HERE); // 6. Return promise. return promise; }
v8::Handle<v8::Object> V8ArrayBuffer::createWrapper(PassRefPtr<ArrayBuffer> impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate) { ASSERT(impl.get()); ASSERT(!DOMDataStore::containsWrapper<V8ArrayBuffer>(impl.get(), isolate)); v8::Handle<v8::Object> wrapper = v8::ArrayBuffer::New(isolate, impl->data(), impl->byteLength()); impl->setDeallocationObserver(V8ArrayBufferDeallocationObserver::instanceTemplate()); V8DOMWrapper::associateObjectWithWrapper<V8ArrayBuffer>(impl, &wrapperTypeInfo, wrapper, isolate); return wrapper; }
void SourceBuffer::appendBuffer(PassRefPtr<ArrayBufferView> data, ExceptionState& es) { // Section 3.2 appendBuffer() // https://dvcs.w3.org/hg/html-media/raw-file/default/media-source/media-source.html#widl-SourceBuffer-appendBuffer-void-ArrayBufferView-data // 1. If data is null then throw an InvalidAccessError exception and abort these steps. if (!data) { es.throwDOMException(InvalidAccessError); return; } appendBufferInternal(static_cast<const unsigned char*>(data->baseAddress()), data->byteLength(), es); }
bool BeaconLoader::sendBeacon(LocalFrame* frame, int allowance, const KURL& beaconURL, PassRefPtr<ArrayBufferView>& data, int& payloadLength) { ASSERT(data); unsigned long long entitySize = data->byteLength(); if (allowance > 0 && static_cast<unsigned long long>(allowance) < entitySize) return false; ResourceRequest request(beaconURL); prepareRequest(frame, request); RefPtr<FormData> entityBody = FormData::create(data->baseAddress(), data->byteLength()); request.setHTTPBody(entityBody.release()); // FIXME: a reasonable choice, but not in the spec; should it give a default? AtomicString contentType = AtomicString("application/octet-stream"); request.setHTTPContentType(contentType); issueRequest(frame, request); payloadLength = entitySize; return true; }
PassRefPtr<WebGLUnsignedByteArray> WebGLUnsignedByteArray::create(PassRefPtr<WebGLArrayBuffer> buffer, int byteOffset, unsigned length) { if (buffer) { // Check to make sure we are talking about a valid region of // the given WebGLArrayBuffer's storage. if ((byteOffset + (length * sizeof(unsigned char))) > buffer->byteLength()) return NULL; } return adoptRef(new WebGLUnsignedByteArray(buffer, byteOffset, length)); }
PassRefPtr<CanvasFloatArray> CanvasFloatArray::create(PassRefPtr<CanvasArrayBuffer> buffer, int offset, unsigned length) { // Make sure the offset results in valid alignment. if ((offset % sizeof(float)) != 0) return NULL; if (buffer) { // Check to make sure we are talking about a valid region of // the given CanvasArrayBuffer's storage. if ((offset + (length * sizeof(float))) > buffer->byteLength()) return NULL; } return adoptRef(new CanvasFloatArray(buffer, offset, length)); }
PassRefPtr<WebGLUnsignedShortArray> WebGLUnsignedShortArray::create(PassRefPtr<WebGLArrayBuffer> buffer, int byteOffset, unsigned length) { // Make sure the offset results in valid alignment. if ((byteOffset % sizeof(unsigned short)) != 0) { return NULL; } if (buffer) { // Check to make sure we are talking about a valid region of // the given WebGLArrayBuffer's storage. if ((byteOffset + (length * sizeof(unsigned short))) > buffer->byteLength()) return NULL; } return adoptRef(new WebGLUnsignedShortArray(buffer, byteOffset, length)); }
void SourceBuffer::appendBuffer(PassRefPtr<DOMArrayBuffer> data, ExceptionState& exceptionState) { // Section 3.2 appendBuffer() // https://dvcs.w3.org/hg/html-media/raw-file/default/media-source/media-source.html#widl-SourceBuffer-appendBuffer-void-ArrayBufferView-data appendBufferInternal(static_cast<const unsigned char*>(data->data()), data->byteLength(), exceptionState); }
PassRefPtrWillBeRawPtr<FontFace> FontFace::create(ExecutionContext* context, const AtomicString& family, PassRefPtr<DOMArrayBuffer> source, const FontFaceDescriptors& descriptors) { RefPtrWillBeRawPtr<FontFace> fontFace = adoptRefWillBeNoop(new FontFace(context, family, descriptors)); fontFace->initCSSFontFace(static_cast<const unsigned char*>(source->data()), source->byteLength()); return fontFace.release(); }