WebDriver: Stop using the ancient Core::EventReceiver parent/child API

Before this change, clients were kept alive by making them children of
the TCPServer object. This ownership model is going away (and this was
the only remaining use of it!) so let's just put the clients in a hash
table instead.
This commit is contained in:
Andreas Kling 2025-08-10 16:34:51 +02:00 committed by Andreas Kling
commit dfe776b722
Notes: github-actions[bot] 2025-08-11 14:57:31 +00:00
5 changed files with 24 additions and 12 deletions

View file

@ -176,9 +176,8 @@ static JsonValue make_success_response(JsonValue value)
return result;
}
Client::Client(NonnullOwnPtr<Core::BufferedTCPSocket> socket, Core::EventReceiver* parent)
: Core::EventReceiver(parent)
, m_socket(move(socket))
Client::Client(NonnullOwnPtr<Core::BufferedTCPSocket> socket)
: m_socket(move(socket))
{
m_socket->on_ready_to_read = [this] {
if (auto result = on_ready_to_read(); result.is_error())
@ -194,7 +193,10 @@ Client::~Client()
void Client::die()
{
// We defer removing this connection to avoid closing its socket while we are inside the on_ready_to_read callback.
deferred_invoke([this] { remove_from_parent(); });
deferred_invoke([this] {
if (on_death)
on_death();
});
}
ErrorOr<void, Client::WrappedError> Client::on_ready_to_read()