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

Http[s]Download: Make the constructor's initialization DRY

Problem:
- `HttpDownload()` and `HttpsDownload()` implementations are the same
  except for types and certificates.

Solution:
- Follow the "Don't Repeat Yourself" mantra and de-duplicate the code
  using templates.
This commit is contained in:
Lenny Maiorani 2021-01-14 12:06:54 -07:00 committed by Andreas Kling
parent 0f7efd5bf1
commit 9f64424661
4 changed files with 43 additions and 54 deletions

View file

@ -55,9 +55,6 @@ public:
void set_download_fd(int fd) { m_download_fd = fd; }
int download_fd() const { return m_download_fd; }
protected:
explicit Download(ClientConnection&, NonnullOwnPtr<OutputFileStream>&&);
void did_finish(bool success);
void did_progress(Optional<u32> total_size, u32 downloaded_size);
void set_status_code(u32 status_code) { m_status_code = status_code; }
@ -66,6 +63,9 @@ protected:
void set_downloaded_size(size_t size) { m_downloaded_size = size; }
const OutputFileStream& output_stream() const { return *m_output_stream; }
protected:
explicit Download(ClientConnection&, NonnullOwnPtr<OutputFileStream>&&);
private:
ClientConnection& m_client;
i32 m_id { 0 };