LibDevTools: Move message data into a structure

This is to prepare for an upcoming change where we will need to track
replies to messages by ID. We will be able to add parameters to this
structure without having to edit every single actor subclass header
file.
This commit is contained in:
Timothy Flynn 2025-03-12 08:01:23 -04:00 committed by Tim Flynn
commit 24a5e4e7d5
Notes: github-actions[bot] 2025-03-13 20:57:59 +00:00
42 changed files with 162 additions and 146 deletions

View file

@ -39,18 +39,18 @@ ConsoleActor::ConsoleActor(DevToolsServer& devtools, String name, WeakPtr<TabAct
ConsoleActor::~ConsoleActor() = default;
void ConsoleActor::handle_message(StringView type, JsonObject const& message)
void ConsoleActor::handle_message(Message const& message)
{
JsonObject response;
if (type == "autocomplete"sv) {
if (message.type == "autocomplete"sv) {
response.set("matches"sv, JsonArray {});
response.set("matchProp"sv, String {});
send_message(move(response));
return;
}
if (type == "evaluateJSAsync"sv) {
if (message.type == "evaluateJSAsync"sv) {
auto text = get_required_parameter<String>(message, "text"sv);
if (!text.has_value())
return;
@ -61,7 +61,7 @@ void ConsoleActor::handle_message(StringView type, JsonObject const& message)
send_message(move(response));
// FIXME: We do not support eager evaluation of scripts. Just bail for now.
if (message.get_bool("eager"sv).value_or(false)) {
if (message.data.get_bool("eager"sv).value_or(false)) {
return;
}
@ -75,7 +75,7 @@ void ConsoleActor::handle_message(StringView type, JsonObject const& message)
return;
}
send_unrecognized_packet_type_error(type);
send_unrecognized_packet_type_error(message);
}
}