mirror of
https://github.com/RGBCube/serenity
synced 2025-07-23 09:07:41 +00:00
CNetworkJob: Automatically delete finished jobs after on_finish.
Also, pretty-print any failure messages.
This commit is contained in:
parent
639478391b
commit
af75ccee65
2 changed files with 19 additions and 1 deletions
|
@ -16,12 +16,28 @@ void CNetworkJob::did_finish(NonnullRefPtr<CNetworkResponse>&& response)
|
||||||
printf("%s{%p} job did_finish!\n", class_name(), this);
|
printf("%s{%p} job did_finish!\n", class_name(), this);
|
||||||
ASSERT(on_finish);
|
ASSERT(on_finish);
|
||||||
on_finish(true);
|
on_finish(true);
|
||||||
|
delete_later();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CNetworkJob::did_fail(Error error)
|
void CNetworkJob::did_fail(Error error)
|
||||||
{
|
{
|
||||||
m_error = error;
|
m_error = error;
|
||||||
dbgprintf("%s{%p} job did_fail! error=%u\n", class_name(), this, (unsigned)error);
|
dbgprintf("%s{%p} job did_fail! error: %u (%s)\n", class_name(), this, (unsigned)error, to_string(error));
|
||||||
ASSERT(on_finish);
|
ASSERT(on_finish);
|
||||||
on_finish(false);
|
on_finish(false);
|
||||||
|
delete_later();
|
||||||
|
}
|
||||||
|
|
||||||
|
const char* to_string(CNetworkJob::Error error)
|
||||||
|
{
|
||||||
|
switch (error) {
|
||||||
|
case CNetworkJob::Error::ProtocolFailed:
|
||||||
|
return "ProtocolFailed";
|
||||||
|
case CNetworkJob::Error::ConnectionFailed:
|
||||||
|
return "ConnectionFailed";
|
||||||
|
case CNetworkJob::Error::TransmissionFailed:
|
||||||
|
return "TransmissionFailed";
|
||||||
|
default:
|
||||||
|
return "(Unknown error)";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,3 +35,5 @@ private:
|
||||||
RefPtr<CNetworkResponse> m_response;
|
RefPtr<CNetworkResponse> m_response;
|
||||||
Error m_error { Error::None };
|
Error m_error { Error::None };
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const char* to_string(CNetworkJob::Error);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue