1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 04:17:35 +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

@ -41,7 +41,7 @@ GeminiRequest::GeminiRequest(ConnectionFromClient& client, NonnullRefPtr<Gemini:
did_finish(success);
};
m_job->on_progress = [this](Optional<u32> total, u32 current) {
m_job->on_progress = [this](Optional<u64> total, u64 current) {
did_progress(move(total), current);
};
}

View file

@ -46,7 +46,7 @@ void init(TSelf* self, TJob job)
self->did_finish(success);
};
job->on_progress = [self](Optional<u32> total, u32 current) {
job->on_progress = [self](Optional<u64> total, u64 current) {
self->did_progress(total, current);
};
if constexpr (requires { job->on_certificate_requested; }) {

View file

@ -39,7 +39,7 @@ void Request::did_finish(bool success)
m_client.did_finish_request({}, *this, success);
}
void Request::did_progress(Optional<u32> total_size, u32 downloaded_size)
void Request::did_progress(Optional<u64> total_size, u64 downloaded_size)
{
m_total_size = total_size;
m_downloaded_size = downloaded_size;

View file

@ -23,7 +23,7 @@ public:
virtual URL url() const = 0;
Optional<u32> status_code() const { return m_status_code; }
Optional<u32> total_size() const { return m_total_size; }
Optional<u64> total_size() const { return m_total_size; }
size_t downloaded_size() const { return m_downloaded_size; }
HashMap<DeprecatedString, DeprecatedString, CaseInsensitiveStringTraits> const& response_headers() const { return m_response_headers; }
@ -35,7 +35,7 @@ public:
int request_fd() const { return m_request_fd; }
void did_finish(bool success);
void did_progress(Optional<u32> total_size, u32 downloaded_size);
void did_progress(Optional<u64> total_size, u64 downloaded_size);
void set_status_code(u32 status_code) { m_status_code = status_code; }
void did_request_certificates();
void set_response_headers(HashMap<DeprecatedString, DeprecatedString, CaseInsensitiveStringTraits> const&);
@ -50,7 +50,7 @@ private:
i32 m_id { 0 };
int m_request_fd { -1 }; // Passed to client.
Optional<u32> m_status_code;
Optional<u32> m_total_size {};
Optional<u64> m_total_size {};
size_t m_downloaded_size { 0 };
NonnullOwnPtr<Core::File> m_output_stream;
HashMap<DeprecatedString, DeprecatedString, CaseInsensitiveStringTraits> m_response_headers;

View file

@ -2,8 +2,8 @@
endpoint RequestClient
{
request_progress(i32 request_id, Optional<u32> total_size, u32 downloaded_size) =|
request_finished(i32 request_id, bool success, u32 total_size) =|
request_progress(i32 request_id, Optional<u64> total_size, u64 downloaded_size) =|
request_finished(i32 request_id, bool success, u64 total_size) =|
headers_became_available(i32 request_id, HashMap<DeprecatedString,DeprecatedString,CaseInsensitiveStringTraits> response_headers, Optional<u32> status_code) =|
// Certificate requests