1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 15:27:34 +00:00

LibProtocol: Remove use of ByteBuffer::wrap() in protocol API

This commit is contained in:
Andreas Kling 2020-12-19 13:09:02 +01:00
parent 77515fead2
commit 685d5f4e25
6 changed files with 10 additions and 10 deletions

View file

@ -46,11 +46,11 @@ void Download::did_finish(Badge<Client>, bool success, Optional<u32> status_code
if (!on_finish)
return;
ByteBuffer payload;
ReadonlyBytes payload;
RefPtr<SharedBuffer> shared_buffer;
if (success && shbuf_id != -1) {
shared_buffer = SharedBuffer::create_from_shbuf_id(shbuf_id);
payload = ByteBuffer::wrap(shared_buffer->data<void>(), total_size);
payload = { shared_buffer->data<void>(), total_size };
}
// FIXME: It's a bit silly that we copy the response headers here just so we can move them into a HashMap with different traits.

View file

@ -53,7 +53,7 @@ public:
int id() const { return m_download_id; }
bool stop();
Function<void(bool success, const ByteBuffer& payload, RefPtr<SharedBuffer> payload_storage, const HashMap<String, String, CaseInsensitiveStringTraits>& response_headers, Optional<u32> status_code)> on_finish;
Function<void(bool success, ReadonlyBytes payload, RefPtr<SharedBuffer> payload_storage, const HashMap<String, String, CaseInsensitiveStringTraits>& response_headers, Optional<u32> status_code)> on_finish;
Function<void(Optional<u32> total_size, u32 downloaded_size)> on_progress;
Function<CertificateAndKey()> on_certificate_requested;

View file

@ -170,7 +170,7 @@ void ResourceLoader::load(const LoadRequest& request, Function<void(const ByteBu
error_callback("Failed to initiate load");
return;
}
download->on_finish = [this, success_callback = move(success_callback), error_callback = move(error_callback)](bool success, const ByteBuffer& payload, auto, auto& response_headers, auto status_code) {
download->on_finish = [this, success_callback = move(success_callback), error_callback = move(error_callback)](bool success, ReadonlyBytes payload, auto, auto& response_headers, auto status_code) {
--m_pending_loads;
if (on_load_counter_change)
on_load_counter_change();