1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 11:48:10 +00:00

LibWeb: Add public get accessor function for Blob's internal ByteBuffer

Blob::bytes() returns the ReadonlyBytes representation of our internal
ByteBuffer.

This change requires us to ByteBuffer::copy() Blob's ReadonlyBytes to a
ByteBuffer in XHR::send() and corresponding error handling of the copy
operation.

This removes the need for Blob to declare XMLHttpRequest as a friend
class.
This commit is contained in:
Kenneth Myhra 2022-07-24 15:43:33 +02:00 committed by Linus Groh
parent 417a385db1
commit 622a4f29a7
3 changed files with 16 additions and 7 deletions

View file

@ -76,7 +76,7 @@ ErrorOr<ByteBuffer> Blob::process_blob_parts(Vector<BlobPart> const& blob_parts)
},
// 3. If element is a Blob, append the bytes it represents to bytes.
[&](NonnullRefPtr<Blob> const& blob) -> ErrorOr<void> {
return bytes.try_append(blob->m_byte_buffer.bytes());
return bytes.try_append(blob->bytes());
}));
}
return bytes;