summaryrefslogtreecommitdiff
path: root/Servers/ProtocolServer/Download.h
diff options
context:
space:
mode:
Diffstat (limited to 'Servers/ProtocolServer/Download.h')
-rw-r--r--Servers/ProtocolServer/Download.h35
1 files changed, 35 insertions, 0 deletions
diff --git a/Servers/ProtocolServer/Download.h b/Servers/ProtocolServer/Download.h
new file mode 100644
index 0000000000..d12a6b7e52
--- /dev/null
+++ b/Servers/ProtocolServer/Download.h
@@ -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;
+};