1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-30 22:48:11 +00:00
serenity/Libraries/LibProtocol/Client.h
Andreas Kling eb85103271 ProtocolServer: Send the download payload to clients as a shared buffer
The DownloadFinished message from the server now includes a buffer ID
that can be mapped into the client program.

To avoid prematurely destroying the buffer, the server will hang on to
it until the client lets it know that they're all good. That's what the
ProtocolServer::DisownSharedBuffer message is about.

In the future it would be nice if the kernel had a mechanism to allow
passing ownership of a shared buffer along with an IPC message somehow.
2019-11-23 22:11:44 +01:00

29 lines
896 B
C++

#pragma once
#include <LibCore/CoreIPCClient.h>
#include <ProtocolServer/ProtocolClientEndpoint.h>
#include <ProtocolServer/ProtocolServerEndpoint.h>
namespace LibProtocol {
class Client : public IPC::Client::ConnectionNG<ProtocolClientEndpoint, ProtocolServerEndpoint>
, public ProtocolClientEndpoint {
C_OBJECT(Client)
public:
Client();
virtual void handshake() override;
bool is_supported_protocol(const String&);
i32 start_download(const String& url);
bool stop_download(i32 download_id);
Function<void(i32 download_id, bool success, u32 total_size, i32 shared_buffer_id)> on_download_finish;
Function<void(i32 download_id, u64 total_size, u64 downloaded_size)> on_download_progress;
private:
virtual void handle(const ProtocolClient::DownloadProgress&) override;
virtual void handle(const ProtocolClient::DownloadFinished&) override;
};
}