diff --git a/Applications/Browser/DownloadWidget.cpp b/Applications/Browser/DownloadWidget.cpp index b14672d533..b56afc3a7e 100644 --- a/Applications/Browser/DownloadWidget.cpp +++ b/Applications/Browser/DownloadWidget.cpp @@ -61,7 +61,7 @@ DownloadWidget::DownloadWidget(const URL& url) m_download->on_progress = [this](Optional total_size, u32 downloaded_size) { did_progress(total_size.value(), downloaded_size); }; - m_download->on_finish = [this](bool success, auto& payload, auto payload_storage, auto& response_headers, auto) { + m_download->on_finish = [this](bool success, auto payload, auto payload_storage, auto& response_headers, auto) { did_finish(success, payload, payload_storage, response_headers); }; @@ -156,7 +156,7 @@ void DownloadWidget::did_progress(Optional total_size, u32 downloaded_size) } } -void DownloadWidget::did_finish(bool success, const ByteBuffer& payload, RefPtr payload_storage, const HashMap& response_headers) +void DownloadWidget::did_finish(bool success, ReadonlyBytes payload, RefPtr payload_storage, const HashMap& response_headers) { (void)payload; (void)payload_storage; diff --git a/Applications/Browser/DownloadWidget.h b/Applications/Browser/DownloadWidget.h index 95fec634d5..2b69af5d26 100644 --- a/Applications/Browser/DownloadWidget.h +++ b/Applications/Browser/DownloadWidget.h @@ -44,7 +44,7 @@ private: explicit DownloadWidget(const URL&); void did_progress(Optional total_size, u32 downloaded_size); - void did_finish(bool success, const ByteBuffer& payload, RefPtr payload_storage, const HashMap& response_headers); + void did_finish(bool success, ReadonlyBytes payload, RefPtr payload_storage, const HashMap& response_headers); URL m_url; String m_destination_path; diff --git a/Libraries/LibProtocol/Download.cpp b/Libraries/LibProtocol/Download.cpp index 05260a9636..b71127951b 100644 --- a/Libraries/LibProtocol/Download.cpp +++ b/Libraries/LibProtocol/Download.cpp @@ -46,11 +46,11 @@ void Download::did_finish(Badge, bool success, Optional status_code if (!on_finish) return; - ByteBuffer payload; + ReadonlyBytes payload; RefPtr shared_buffer; if (success && shbuf_id != -1) { shared_buffer = SharedBuffer::create_from_shbuf_id(shbuf_id); - payload = ByteBuffer::wrap(shared_buffer->data(), total_size); + payload = { shared_buffer->data(), 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. diff --git a/Libraries/LibProtocol/Download.h b/Libraries/LibProtocol/Download.h index 9601ab06da..c8058a98c8 100644 --- a/Libraries/LibProtocol/Download.h +++ b/Libraries/LibProtocol/Download.h @@ -53,7 +53,7 @@ public: int id() const { return m_download_id; } bool stop(); - Function payload_storage, const HashMap& response_headers, Optional status_code)> on_finish; + Function payload_storage, const HashMap& response_headers, Optional status_code)> on_finish; Function total_size, u32 downloaded_size)> on_progress; Function on_certificate_requested; diff --git a/Libraries/LibWeb/Loader/ResourceLoader.cpp b/Libraries/LibWeb/Loader/ResourceLoader.cpp index 897c684ecb..53dbd60d7f 100644 --- a/Libraries/LibWeb/Loader/ResourceLoader.cpp +++ b/Libraries/LibWeb/Loader/ResourceLoader.cpp @@ -170,7 +170,7 @@ void ResourceLoader::load(const LoadRequest& request, Functionon_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(); diff --git a/Userland/pro.cpp b/Userland/pro.cpp index e86566a607..cca80971b6 100644 --- a/Userland/pro.cpp +++ b/Userland/pro.cpp @@ -116,12 +116,12 @@ private: bool m_might_be_wrong { false }; }; -static void do_write(const ByteBuffer& payload) +static void do_write(ReadonlyBytes payload) { size_t length_remaining = payload.size(); size_t length_written = 0; while (length_remaining > 0) { - auto nwritten = fwrite(payload.offset_pointer(length_written), sizeof(char), length_remaining, stdout); + auto nwritten = fwrite(payload.data() + length_written, sizeof(char), length_remaining, stdout); if (nwritten > 0) { length_remaining -= nwritten; length_written += nwritten; @@ -192,7 +192,7 @@ int main(int argc, char** argv) previous_downloaded_size = downloaded_size; prev_time = current_time; }; - download->on_finish = [&](bool success, auto& payload, auto, auto& response_headers, auto) { + download->on_finish = [&](bool success, auto payload, auto, auto& response_headers, auto) { fprintf(stderr, "\033]9;-1;\033\\"); fprintf(stderr, "\n"); if (success && save_at_provided_name) {