mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 18:57:34 +00:00
ProtocolServer+LibProtocol: Introduce a server for handling downloads
This patch adds ProtocolServer, a server that handles network requests on behalf of its clients. The first protocol implemented is HTTP. The idea here is to use a plug-in architecture where any number of protocols can be added and implemented without having to mess around with each client program that wants to use the protocol. A simple client API is provided through LibProtocol::Client. :^)
This commit is contained in:
parent
61f611bf3c
commit
fd4349a9f2
21 changed files with 475 additions and 0 deletions
35
Servers/ProtocolServer/Download.h
Normal file
35
Servers/ProtocolServer/Download.h
Normal file
|
@ -0,0 +1,35 @@
|
|||
#pragma once
|
||||
|
||||
#include <AK/RefCounted.h>
|
||||
#include <AK/URL.h>
|
||||
#include <AK/WeakPtr.h>
|
||||
|
||||
class PSClientConnection;
|
||||
|
||||
class Download : public RefCounted<Download> {
|
||||
public:
|
||||
virtual ~Download();
|
||||
|
||||
static Download* find_by_id(i32);
|
||||
|
||||
i32 id() const { return m_id; }
|
||||
URL url() const { return m_url; }
|
||||
|
||||
size_t total_size() const { return m_total_size; }
|
||||
size_t downloaded_size() const { return m_downloaded_size; }
|
||||
|
||||
void stop();
|
||||
|
||||
protected:
|
||||
explicit Download(PSClientConnection&);
|
||||
|
||||
void did_finish(bool success);
|
||||
void did_progress(size_t total_size, size_t downloaded_size);
|
||||
|
||||
private:
|
||||
i32 m_id;
|
||||
URL m_url;
|
||||
size_t m_total_size { 0 };
|
||||
size_t m_downloaded_size { 0 };
|
||||
WeakPtr<PSClientConnection> m_client;
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue