mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-28 13:18:19 +00:00
LibDevTools: Add a helper to acquire required message parameters
This is just to help make the message handlers a bit briefer. I had considered adding a TRY-like macro to auto-return when the lookup fails, but since statement expressions cannot return references, that would result in a copy of all e.g. object and array lookups.
This commit is contained in:
parent
4ce10f3bf4
commit
e1ed8722e0
Notes:
github-actions[bot]
2025-03-12 16:49:03 +00:00
Author: https://github.com/trflynn89
Commit: e1ed8722e0
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3904
12 changed files with 85 additions and 121 deletions
|
@ -65,11 +65,9 @@ void RootActor::handle_message(StringView type, JsonObject const& message)
|
|||
}
|
||||
|
||||
if (type == "getProcess"sv) {
|
||||
auto id = message.get_integer<u64>("id"sv);
|
||||
if (!id.has_value()) {
|
||||
send_missing_parameter_error("id"sv);
|
||||
auto id = get_required_parameter<u64>(message, "id"sv);
|
||||
if (!id.has_value())
|
||||
return;
|
||||
}
|
||||
|
||||
for (auto const& actor : devtools().actor_registry()) {
|
||||
auto const* process_actor = as_if<ProcessActor>(*actor.value);
|
||||
|
@ -87,11 +85,9 @@ void RootActor::handle_message(StringView type, JsonObject const& message)
|
|||
}
|
||||
|
||||
if (type == "getTab"sv) {
|
||||
auto browser_id = message.get_integer<u64>("browserId"sv);
|
||||
if (!browser_id.has_value()) {
|
||||
send_missing_parameter_error("browserId"sv);
|
||||
auto browser_id = get_required_parameter<u64>(message, "browserId"sv);
|
||||
if (!browser_id.has_value())
|
||||
return;
|
||||
}
|
||||
|
||||
for (auto const& actor : devtools().actor_registry()) {
|
||||
auto const* tab_actor = as_if<TabActor>(*actor.value);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue