/* static */ bool PushUtil::CopyArrayBufferToArray(const ArrayBuffer& aBuffer, nsTArray<uint8_t>& aArray) { aBuffer.ComputeLengthAndData(); return aArray.SetLength(aBuffer.Length(), fallible) && aArray.ReplaceElementsAt(0, aBuffer.Length(), aBuffer.Data(), aBuffer.Length(), fallible); }
/* static */ bool PushUtil::CopyBufferSourceToArray( const OwningArrayBufferViewOrArrayBuffer& aSource, nsTArray<uint8_t>& aArray) { if (aSource.IsArrayBuffer()) { return CopyArrayBufferToArray(aSource.GetAsArrayBuffer(), aArray); } if (aSource.IsArrayBufferView()) { const ArrayBufferView& view = aSource.GetAsArrayBufferView(); view.ComputeLengthAndData(); return aArray.SetLength(view.Length(), fallible) && aArray.ReplaceElementsAt(0, view.Length(), view.Data(), view.Length(), fallible); } MOZ_CRASH("Uninitialized union: expected buffer or view"); }