blob: 3d8117c754a267d6c1296b10131ca3695b2b7565 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
#pragma once
#include <AK/Function.h>
#include <LibCore/CObject.h>
class CNetworkResponse;
class CNetworkJob : public CObject {
public:
enum class Error
{
None,
ConnectionFailed,
TransmissionFailed,
ProtocolFailed,
};
virtual ~CNetworkJob() override;
Function<void(bool success)> on_finish;
bool has_error() const { return m_error != Error::None; }
Error error() const { return m_error; }
CNetworkResponse* response() { return m_response.ptr(); }
const CNetworkResponse* response() const { return m_response.ptr(); }
virtual void start() = 0;
virtual const char* class_name() const override { return "CNetworkJob"; }
protected:
CNetworkJob();
void did_finish(Retained<CNetworkResponse>&&);
void did_fail(Error);
private:
RetainPtr<CNetworkResponse> m_response;
Error m_error { Error::None };
};
|