1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 23:17:46 +00:00

Everywhere: Correctly report progress of downloads larger than 4GiB

This commit changes the variables used to represent the size and
progress of downloads from u32 to u64. This allows `pro` and
`Browser` to report the total size and progress of a download
correctly for downloads larger than 4GiB.
This commit is contained in:
Tim Ledbetter 2023-06-11 00:56:35 +01:00 committed by Andreas Kling
parent c5e0547377
commit 1a17e08f87
18 changed files with 40 additions and 42 deletions

View file

@ -88,7 +88,7 @@ void Request::set_should_buffer_all_input(bool value)
m_internal_buffered_data->response_code = move(response_code);
};
on_finish = [this](auto success, u32 total_size) {
on_finish = [this](auto success, auto total_size) {
auto output_buffer = ByteBuffer::create_uninitialized(m_internal_buffered_data->payload_stream.used_buffer_size()).release_value_but_fixme_should_propagate_errors();
m_internal_buffered_data->payload_stream.read_until_filled(output_buffer).release_value_but_fixme_should_propagate_errors();
on_buffered_request_finish(
@ -102,7 +102,7 @@ void Request::set_should_buffer_all_input(bool value)
stream_into(m_internal_buffered_data->payload_stream);
}
void Request::did_finish(Badge<RequestClient>, bool success, u32 total_size)
void Request::did_finish(Badge<RequestClient>, bool success, u64 total_size)
{
if (!on_finish)
return;
@ -110,7 +110,7 @@ void Request::did_finish(Badge<RequestClient>, bool success, u32 total_size)
on_finish(success, total_size);
}
void Request::did_progress(Badge<RequestClient>, Optional<u32> total_size, u32 downloaded_size)
void Request::did_progress(Badge<RequestClient>, Optional<u64> total_size, u64 downloaded_size)
{
if (on_progress)
on_progress(total_size, downloaded_size);

View file

@ -43,14 +43,14 @@ public:
void set_should_buffer_all_input(bool);
/// Note: Must be set before `set_should_buffer_all_input(true)`.
Function<void(bool success, u32 total_size, HashMap<DeprecatedString, DeprecatedString, CaseInsensitiveStringTraits> const& response_headers, Optional<u32> response_code, ReadonlyBytes payload)> on_buffered_request_finish;
Function<void(bool success, u32 total_size)> on_finish;
Function<void(Optional<u32> total_size, u32 downloaded_size)> on_progress;
Function<void(bool success, u64 total_size, HashMap<DeprecatedString, DeprecatedString, CaseInsensitiveStringTraits> const& response_headers, Optional<u32> response_code, ReadonlyBytes payload)> on_buffered_request_finish;
Function<void(bool success, u64 total_size)> on_finish;
Function<void(Optional<u64> total_size, u64 downloaded_size)> on_progress;
Function<void(HashMap<DeprecatedString, DeprecatedString, CaseInsensitiveStringTraits> const& response_headers, Optional<u32> response_code)> on_headers_received;
Function<CertificateAndKey()> on_certificate_requested;
void did_finish(Badge<RequestClient>, bool success, u32 total_size);
void did_progress(Badge<RequestClient>, Optional<u32> total_size, u32 downloaded_size);
void did_finish(Badge<RequestClient>, bool success, u64 total_size);
void did_progress(Badge<RequestClient>, Optional<u64> total_size, u64 downloaded_size);
void did_receive_headers(Badge<RequestClient>, HashMap<DeprecatedString, DeprecatedString, CaseInsensitiveStringTraits> const& response_headers, Optional<u32> response_code);
void did_request_certificates(Badge<RequestClient>);

View file

@ -54,7 +54,7 @@ bool RequestClient::set_certificate(Badge<Request>, Request& request, Deprecated
return IPCProxy::set_certificate(request.id(), move(certificate), move(key));
}
void RequestClient::request_finished(i32 request_id, bool success, u32 total_size)
void RequestClient::request_finished(i32 request_id, bool success, u64 total_size)
{
RefPtr<Request> request;
if ((request = m_requests.get(request_id).value_or(nullptr))) {
@ -63,7 +63,7 @@ void RequestClient::request_finished(i32 request_id, bool success, u32 total_siz
m_requests.remove(request_id);
}
void RequestClient::request_progress(i32 request_id, Optional<u32> const& total_size, u32 downloaded_size)
void RequestClient::request_progress(i32 request_id, Optional<u64> const& total_size, u64 downloaded_size)
{
if (auto request = const_cast<Request*>(m_requests.get(request_id).value_or(nullptr))) {
request->did_progress({}, total_size, downloaded_size);

View file

@ -32,8 +32,8 @@ public:
private:
RequestClient(NonnullOwnPtr<Core::LocalSocket>);
virtual void request_progress(i32, Optional<u32> const&, u32) override;
virtual void request_finished(i32, bool, u32) override;
virtual void request_progress(i32, Optional<u64> const&, u64) override;
virtual void request_finished(i32, bool, u64) override;
virtual void certificate_requested(i32) override;
virtual void headers_became_available(i32, HashMap<DeprecatedString, DeprecatedString, CaseInsensitiveStringTraits> const&, Optional<u32> const&) override;