2025-02-15 09:57:36 -03:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2025, Tim Flynn <trflynn89@ladybird.org>
|
|
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
|
*/
|
|
|
|
|
|
2025-02-24 13:55:46 -03:00
|
|
|
#include <AK/Debug.h>
|
2025-02-15 09:57:36 -03:00
|
|
|
#include <AK/JsonObject.h>
|
|
|
|
|
#include <LibCore/EventLoop.h>
|
2025-10-13 07:37:36 -03:00
|
|
|
#include <LibDevTools/Actors/AccessibilityActor.h>
|
2025-02-15 09:57:36 -03:00
|
|
|
#include <LibDevTools/Actors/CSSPropertiesActor.h>
|
2025-02-24 13:55:46 -03:00
|
|
|
#include <LibDevTools/Actors/ConsoleActor.h>
|
2026-06-11 06:15:14 -03:00
|
|
|
#include <LibDevTools/Actors/CookiesActor.h>
|
2025-02-15 09:57:36 -03:00
|
|
|
#include <LibDevTools/Actors/FrameActor.h>
|
|
|
|
|
#include <LibDevTools/Actors/InspectorActor.h>
|
2026-01-14 14:43:48 -03:00
|
|
|
#include <LibDevTools/Actors/NetworkParentActor.h>
|
2026-06-10 12:15:21 -03:00
|
|
|
#include <LibDevTools/Actors/StorageActor.h>
|
2025-03-11 18:14:54 -03:00
|
|
|
#include <LibDevTools/Actors/StyleSheetsActor.h>
|
2025-02-15 09:57:36 -03:00
|
|
|
#include <LibDevTools/Actors/TabActor.h>
|
|
|
|
|
#include <LibDevTools/Actors/TargetConfigurationActor.h>
|
|
|
|
|
#include <LibDevTools/Actors/ThreadActor.h>
|
|
|
|
|
#include <LibDevTools/Actors/ThreadConfigurationActor.h>
|
|
|
|
|
#include <LibDevTools/Actors/WatcherActor.h>
|
2026-05-28 11:26:37 -03:00
|
|
|
#include <LibDevTools/DevToolsDelegate.h>
|
2025-02-15 09:57:36 -03:00
|
|
|
#include <LibDevTools/DevToolsServer.h>
|
|
|
|
|
|
|
|
|
|
namespace DevTools {
|
|
|
|
|
|
2025-02-19 11:28:02 -03:00
|
|
|
NonnullRefPtr<WatcherActor> WatcherActor::create(DevToolsServer& devtools, String name, WeakPtr<TabActor> tab)
|
2025-02-15 09:57:36 -03:00
|
|
|
{
|
|
|
|
|
return adopt_ref(*new WatcherActor(devtools, move(name), move(tab)));
|
|
|
|
|
}
|
|
|
|
|
|
2025-02-19 11:28:02 -03:00
|
|
|
WatcherActor::WatcherActor(DevToolsServer& devtools, String name, WeakPtr<TabActor> tab)
|
2025-02-15 09:57:36 -03:00
|
|
|
: Actor(devtools, move(name))
|
|
|
|
|
, m_tab(move(tab))
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2026-05-28 11:26:37 -03:00
|
|
|
WatcherActor::~WatcherActor()
|
|
|
|
|
{
|
|
|
|
|
if (!m_is_watching_frame_targets)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (auto tab = m_tab.strong_ref())
|
|
|
|
|
devtools().delegate().did_disconnect_devtools_client(tab->description());
|
|
|
|
|
}
|
2025-02-15 09:57:36 -03:00
|
|
|
|
2025-03-12 09:01:23 -03:00
|
|
|
void WatcherActor::handle_message(Message const& message)
|
2025-02-15 09:57:36 -03:00
|
|
|
{
|
|
|
|
|
JsonObject response;
|
|
|
|
|
|
2026-01-14 14:43:48 -03:00
|
|
|
if (message.type == "getNetworkParentActor"sv) {
|
|
|
|
|
if (!m_network_parent)
|
|
|
|
|
m_network_parent = devtools().register_actor<NetworkParentActor>();
|
|
|
|
|
|
|
|
|
|
response.set("network"sv, m_network_parent->name());
|
|
|
|
|
send_response(message, move(response));
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2025-03-12 09:01:23 -03:00
|
|
|
if (message.type == "getParentBrowsingContextID"sv) {
|
2025-03-11 10:05:01 -03:00
|
|
|
auto browsing_context_id = get_required_parameter<u64>(message, "browsingContextID"sv);
|
|
|
|
|
if (!browsing_context_id.has_value())
|
2025-02-15 09:57:36 -03:00
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
response.set("browsingContextID"sv, *browsing_context_id);
|
LibDevTools: Re-implement how we handle ordered responses
We must reply to requests received from the client in the order they are
received. The wrench in this requirement is handling requests that must
be performed asynchronously, such as fetching the serialized DOM tree
from the WebContent process.
We currently handle this with a "block token". Async request handlers
hold a token that blocks any subsequent responses from being sent. When
that token is removed (i.e. the async request now has a response to be
sent), the async response is then sent followed by the blocked responses
in-order.
This strategy had a limitation that we could not handle an actor trying
to take 2 block tokens, meaning only one async request could be handled
at a time. This has been fine so far, but an upcoming feature (style
sheet sources) will break this limitation. The client will request N
sources at a time, which would try to take N block tokens.
The new strategy is to assign all requests an ID, and store a list of
request IDs that are awaiting a response. When the server wants to send
a reply, we match the ID of the replied-to message to this list of IDs.
If it is not the first in this list, then we are blocked waiting for an
earlier reply, and just store the response. When the earlier request(s)
receive their response, we can then send out all blocked replies (up to
the next request that has not yet received a response).
2025-03-12 13:26:58 -03:00
|
|
|
send_response(message, move(response));
|
2025-02-15 09:57:36 -03:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2025-03-12 09:01:23 -03:00
|
|
|
if (message.type == "getTargetConfigurationActor"sv) {
|
2025-02-15 09:57:36 -03:00
|
|
|
if (!m_target_configuration)
|
|
|
|
|
m_target_configuration = devtools().register_actor<TargetConfigurationActor>();
|
|
|
|
|
|
|
|
|
|
response.set("configuration"sv, m_target_configuration->serialize_configuration());
|
LibDevTools: Re-implement how we handle ordered responses
We must reply to requests received from the client in the order they are
received. The wrench in this requirement is handling requests that must
be performed asynchronously, such as fetching the serialized DOM tree
from the WebContent process.
We currently handle this with a "block token". Async request handlers
hold a token that blocks any subsequent responses from being sent. When
that token is removed (i.e. the async request now has a response to be
sent), the async response is then sent followed by the blocked responses
in-order.
This strategy had a limitation that we could not handle an actor trying
to take 2 block tokens, meaning only one async request could be handled
at a time. This has been fine so far, but an upcoming feature (style
sheet sources) will break this limitation. The client will request N
sources at a time, which would try to take N block tokens.
The new strategy is to assign all requests an ID, and store a list of
request IDs that are awaiting a response. When the server wants to send
a reply, we match the ID of the replied-to message to this list of IDs.
If it is not the first in this list, then we are blocked waiting for an
earlier reply, and just store the response. When the earlier request(s)
receive their response, we can then send out all blocked replies (up to
the next request that has not yet received a response).
2025-03-12 13:26:58 -03:00
|
|
|
send_response(message, move(response));
|
2025-02-15 09:57:36 -03:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2025-03-12 09:01:23 -03:00
|
|
|
if (message.type == "getThreadConfigurationActor"sv) {
|
2025-02-15 09:57:36 -03:00
|
|
|
if (!m_thread_configuration)
|
|
|
|
|
m_thread_configuration = devtools().register_actor<ThreadConfigurationActor>();
|
|
|
|
|
|
|
|
|
|
response.set("configuration"sv, m_thread_configuration->serialize_configuration());
|
LibDevTools: Re-implement how we handle ordered responses
We must reply to requests received from the client in the order they are
received. The wrench in this requirement is handling requests that must
be performed asynchronously, such as fetching the serialized DOM tree
from the WebContent process.
We currently handle this with a "block token". Async request handlers
hold a token that blocks any subsequent responses from being sent. When
that token is removed (i.e. the async request now has a response to be
sent), the async response is then sent followed by the blocked responses
in-order.
This strategy had a limitation that we could not handle an actor trying
to take 2 block tokens, meaning only one async request could be handled
at a time. This has been fine so far, but an upcoming feature (style
sheet sources) will break this limitation. The client will request N
sources at a time, which would try to take N block tokens.
The new strategy is to assign all requests an ID, and store a list of
request IDs that are awaiting a response. When the server wants to send
a reply, we match the ID of the replied-to message to this list of IDs.
If it is not the first in this list, then we are blocked waiting for an
earlier reply, and just store the response. When the earlier request(s)
receive their response, we can then send out all blocked replies (up to
the next request that has not yet received a response).
2025-03-12 13:26:58 -03:00
|
|
|
send_response(message, move(response));
|
2025-02-15 09:57:36 -03:00
|
|
|
return;
|
|
|
|
|
}
|
2025-03-12 09:01:23 -03:00
|
|
|
if (message.type == "watchResources"sv) {
|
2025-03-11 10:05:01 -03:00
|
|
|
auto resource_types = get_required_parameter<JsonArray>(message, "resourceTypes"sv);
|
|
|
|
|
if (!resource_types.has_value())
|
2025-02-24 13:55:46 -03:00
|
|
|
return;
|
|
|
|
|
|
2026-06-11 06:15:14 -03:00
|
|
|
bool should_send_cookie_resources = false;
|
2026-06-10 12:15:21 -03:00
|
|
|
bool should_send_local_storage_resources = false;
|
|
|
|
|
bool should_send_session_storage_resources = false;
|
2025-02-24 13:55:46 -03:00
|
|
|
if constexpr (DEVTOOLS_DEBUG) {
|
|
|
|
|
for (auto const& resource_type : resource_types->values()) {
|
|
|
|
|
if (!resource_type.is_string())
|
|
|
|
|
continue;
|
2026-06-10 12:15:21 -03:00
|
|
|
if (!first_is_one_of(resource_type.as_string(), "console-message"sv, "cookies"sv, "local-storage"sv, "session-storage"sv))
|
2025-02-24 13:55:46 -03:00
|
|
|
dbgln("Unrecognized `watchResources` resource type: '{}'", resource_type.as_string());
|
|
|
|
|
}
|
|
|
|
|
}
|
2026-06-11 06:15:14 -03:00
|
|
|
for (auto const& resource_type : resource_types->values()) {
|
|
|
|
|
if (!resource_type.is_string())
|
|
|
|
|
continue;
|
|
|
|
|
if (resource_type.as_string() == "cookies"sv) {
|
|
|
|
|
m_is_watching_cookie_resources = true;
|
|
|
|
|
should_send_cookie_resources = true;
|
2026-06-10 12:15:21 -03:00
|
|
|
} else if (resource_type.as_string() == "local-storage"sv) {
|
|
|
|
|
m_is_watching_local_storage_resources = true;
|
|
|
|
|
should_send_local_storage_resources = true;
|
|
|
|
|
} else if (resource_type.as_string() == "session-storage"sv) {
|
|
|
|
|
m_is_watching_session_storage_resources = true;
|
|
|
|
|
should_send_session_storage_resources = true;
|
2026-06-11 06:15:14 -03:00
|
|
|
}
|
|
|
|
|
}
|
2025-02-24 13:55:46 -03:00
|
|
|
|
LibDevTools: Re-implement how we handle ordered responses
We must reply to requests received from the client in the order they are
received. The wrench in this requirement is handling requests that must
be performed asynchronously, such as fetching the serialized DOM tree
from the WebContent process.
We currently handle this with a "block token". Async request handlers
hold a token that blocks any subsequent responses from being sent. When
that token is removed (i.e. the async request now has a response to be
sent), the async response is then sent followed by the blocked responses
in-order.
This strategy had a limitation that we could not handle an actor trying
to take 2 block tokens, meaning only one async request could be handled
at a time. This has been fine so far, but an upcoming feature (style
sheet sources) will break this limitation. The client will request N
sources at a time, which would try to take N block tokens.
The new strategy is to assign all requests an ID, and store a list of
request IDs that are awaiting a response. When the server wants to send
a reply, we match the ID of the replied-to message to this list of IDs.
If it is not the first in this list, then we are blocked waiting for an
earlier reply, and just store the response. When the earlier request(s)
receive their response, we can then send out all blocked replies (up to
the next request that has not yet received a response).
2025-03-12 13:26:58 -03:00
|
|
|
send_response(message, move(response));
|
2026-06-11 06:15:14 -03:00
|
|
|
if (should_send_cookie_resources)
|
|
|
|
|
send_cookies_resource_available_message();
|
2026-06-10 12:15:21 -03:00
|
|
|
if (should_send_local_storage_resources)
|
|
|
|
|
send_storage_resource_available_message(local_storage_actor());
|
|
|
|
|
if (should_send_session_storage_resources)
|
|
|
|
|
send_storage_resource_available_message(session_storage_actor());
|
2025-02-24 13:55:46 -03:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2025-03-12 09:01:23 -03:00
|
|
|
if (message.type == "watchTargets"sv) {
|
2025-03-11 10:05:01 -03:00
|
|
|
auto target_type = get_required_parameter<String>(message, "targetType"sv);
|
|
|
|
|
if (!target_type.has_value())
|
2025-02-15 09:57:36 -03:00
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (target_type == "frame"sv) {
|
2026-05-28 11:26:37 -03:00
|
|
|
if (!m_is_watching_frame_targets) {
|
|
|
|
|
if (auto tab = m_tab.strong_ref())
|
|
|
|
|
devtools().delegate().did_connect_devtools_client(tab->description());
|
|
|
|
|
m_is_watching_frame_targets = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
auto& target = create_frame_target();
|
|
|
|
|
|
LibDevTools: Re-implement how we handle ordered responses
We must reply to requests received from the client in the order they are
received. The wrench in this requirement is handling requests that must
be performed asynchronously, such as fetching the serialized DOM tree
from the WebContent process.
We currently handle this with a "block token". Async request handlers
hold a token that blocks any subsequent responses from being sent. When
that token is removed (i.e. the async request now has a response to be
sent), the async response is then sent followed by the blocked responses
in-order.
This strategy had a limitation that we could not handle an actor trying
to take 2 block tokens, meaning only one async request could be handled
at a time. This has been fine so far, but an upcoming feature (style
sheet sources) will break this limitation. The client will request N
sources at a time, which would try to take N block tokens.
The new strategy is to assign all requests an ID, and store a list of
request IDs that are awaiting a response. When the server wants to send
a reply, we match the ID of the replied-to message to this list of IDs.
If it is not the first in this list, then we are blocked waiting for an
earlier reply, and just store the response. When the earlier request(s)
receive their response, we can then send out all blocked replies (up to
the next request that has not yet received a response).
2025-03-12 13:26:58 -03:00
|
|
|
send_response(message, move(response));
|
2025-02-15 09:57:36 -03:00
|
|
|
|
2026-05-28 11:26:37 -03:00
|
|
|
send_frame_target_available_message(target);
|
2025-02-15 09:57:36 -03:00
|
|
|
target.send_frame_update_message();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-03-12 09:01:23 -03:00
|
|
|
send_unrecognized_packet_type_error(message);
|
2025-02-15 09:57:36 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
JsonObject WatcherActor::serialize_description() const
|
|
|
|
|
{
|
|
|
|
|
JsonObject resources;
|
|
|
|
|
resources.set("Cache"sv, false);
|
2025-02-24 13:55:46 -03:00
|
|
|
resources.set("console-message"sv, true);
|
2026-06-11 06:15:14 -03:00
|
|
|
resources.set("cookies"sv, true);
|
2025-02-15 09:57:36 -03:00
|
|
|
resources.set("css-change"sv, false);
|
|
|
|
|
resources.set("css-message"sv, false);
|
|
|
|
|
resources.set("css-registered-properties"sv, false);
|
2026-01-14 15:03:16 -03:00
|
|
|
resources.set("document-event"sv, true);
|
2025-02-15 09:57:36 -03:00
|
|
|
resources.set("error-message"sv, false);
|
|
|
|
|
resources.set("extension-storage"sv, false);
|
|
|
|
|
resources.set("indexed-db"sv, false);
|
|
|
|
|
resources.set("jstracer-state"sv, false);
|
|
|
|
|
resources.set("jstracer-trace"sv, false);
|
|
|
|
|
resources.set("last-private-context-exit"sv, false);
|
2026-06-10 12:15:21 -03:00
|
|
|
resources.set("local-storage"sv, true);
|
2026-01-14 14:43:48 -03:00
|
|
|
resources.set("network-event"sv, true);
|
2025-02-15 09:57:36 -03:00
|
|
|
resources.set("network-event-stacktrace"sv, false);
|
|
|
|
|
resources.set("platform-message"sv, false);
|
|
|
|
|
resources.set("reflow"sv, false);
|
|
|
|
|
resources.set("server-sent-event"sv, false);
|
2026-06-10 12:15:21 -03:00
|
|
|
resources.set("session-storage"sv, true);
|
2025-02-15 09:57:36 -03:00
|
|
|
resources.set("source"sv, false);
|
|
|
|
|
resources.set("stylesheet"sv, false);
|
|
|
|
|
resources.set("thread-state"sv, false);
|
|
|
|
|
resources.set("websocket"sv, false);
|
|
|
|
|
|
|
|
|
|
JsonObject description;
|
|
|
|
|
description.set("shared_worker"sv, false);
|
|
|
|
|
description.set("service_worker"sv, false);
|
|
|
|
|
description.set("frame"sv, true);
|
|
|
|
|
description.set("process"sv, false);
|
|
|
|
|
description.set("worker"sv, false);
|
|
|
|
|
description.set("resources"sv, move(resources));
|
|
|
|
|
|
|
|
|
|
return description;
|
|
|
|
|
}
|
|
|
|
|
|
2026-05-28 11:26:37 -03:00
|
|
|
FrameActor& WatcherActor::create_frame_target()
|
|
|
|
|
{
|
|
|
|
|
auto& css_properties = devtools().register_actor<CSSPropertiesActor>();
|
|
|
|
|
auto& console = devtools().register_actor<ConsoleActor>(m_tab);
|
|
|
|
|
auto& style_sheets = devtools().register_actor<StyleSheetsActor>(m_tab);
|
2026-06-03 09:07:55 -03:00
|
|
|
auto& inspector = devtools().register_actor<InspectorActor>(m_tab, style_sheets);
|
2026-05-28 11:26:37 -03:00
|
|
|
auto& thread = devtools().register_actor<ThreadActor>();
|
|
|
|
|
auto& accessibility = devtools().register_actor<AccessibilityActor>(m_tab);
|
|
|
|
|
|
|
|
|
|
auto& target = devtools().register_actor<FrameActor>(m_tab, make_weak_ptr<WatcherActor>(), css_properties, console, inspector, style_sheets, thread, accessibility);
|
|
|
|
|
m_target = target;
|
|
|
|
|
return target;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void WatcherActor::send_frame_target_available_message()
|
|
|
|
|
{
|
|
|
|
|
auto& target = create_frame_target();
|
|
|
|
|
send_frame_target_available_message(target);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void WatcherActor::switch_frame_target(FrameActor& previous_target, String const& url, String const& title)
|
|
|
|
|
{
|
|
|
|
|
auto previous_target_ref = m_target.strong_ref();
|
|
|
|
|
if (!previous_target_ref || previous_target_ref.ptr() != &previous_target)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
send_frame_target_destroyed_message(*previous_target_ref);
|
|
|
|
|
previous_target_ref->stop_listening();
|
|
|
|
|
devtools().unregister_actor(previous_target_ref->name());
|
|
|
|
|
|
|
|
|
|
auto& target = create_frame_target();
|
|
|
|
|
send_frame_target_available_message(target);
|
|
|
|
|
target.send_frame_update_message();
|
|
|
|
|
target.set_pending_navigation_document_events_after_target_switch(url, title);
|
2026-06-11 06:15:14 -03:00
|
|
|
if (m_is_watching_cookie_resources)
|
|
|
|
|
send_cookies_resource_available_message();
|
2026-06-10 12:15:21 -03:00
|
|
|
if (m_is_watching_local_storage_resources)
|
|
|
|
|
send_storage_resource_available_message(local_storage_actor());
|
|
|
|
|
if (m_is_watching_session_storage_resources)
|
|
|
|
|
send_storage_resource_available_message(session_storage_actor());
|
2026-05-28 11:26:37 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void WatcherActor::send_frame_target_available_message(FrameActor& target)
|
|
|
|
|
{
|
|
|
|
|
JsonObject message;
|
|
|
|
|
message.set("type"sv, "target-available-form"sv);
|
|
|
|
|
message.set("target"sv, target.serialize_target());
|
|
|
|
|
send_message(move(message));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void WatcherActor::send_frame_target_destroyed_message(FrameActor& target)
|
|
|
|
|
{
|
|
|
|
|
JsonObject options;
|
|
|
|
|
options.set("isTargetSwitching"sv, true);
|
|
|
|
|
options.set("shouldDestroyTargetFront"sv, true);
|
|
|
|
|
|
|
|
|
|
JsonObject message;
|
|
|
|
|
message.set("type"sv, "target-destroyed-form"sv);
|
|
|
|
|
message.set("target"sv, target.serialize_target());
|
|
|
|
|
message.set("options"sv, move(options));
|
|
|
|
|
send_message(move(message));
|
|
|
|
|
}
|
|
|
|
|
|
2026-06-11 06:15:14 -03:00
|
|
|
CookiesActor& WatcherActor::cookies_actor()
|
|
|
|
|
{
|
|
|
|
|
if (auto cookies = m_cookies.strong_ref())
|
|
|
|
|
return *cookies;
|
|
|
|
|
|
|
|
|
|
m_cookies = devtools().register_actor<CookiesActor>(m_tab);
|
|
|
|
|
return *m_cookies.strong_ref();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void WatcherActor::send_cookies_resource_available_message()
|
|
|
|
|
{
|
|
|
|
|
JsonArray cookies;
|
|
|
|
|
cookies.must_append(cookies_actor().serialize_storage());
|
|
|
|
|
|
|
|
|
|
JsonArray cookie_resources;
|
|
|
|
|
cookie_resources.must_append("cookies"sv);
|
|
|
|
|
cookie_resources.must_append(move(cookies));
|
|
|
|
|
|
|
|
|
|
JsonArray array;
|
|
|
|
|
array.must_append(move(cookie_resources));
|
|
|
|
|
|
|
|
|
|
JsonObject message;
|
|
|
|
|
message.set("type"sv, "resources-available-array"sv);
|
|
|
|
|
message.set("array"sv, move(array));
|
|
|
|
|
send_message(move(message));
|
|
|
|
|
}
|
|
|
|
|
|
2026-06-10 12:15:21 -03:00
|
|
|
StorageActor& WatcherActor::local_storage_actor()
|
|
|
|
|
{
|
|
|
|
|
if (auto storage = m_local_storage.strong_ref())
|
|
|
|
|
return *storage;
|
|
|
|
|
|
|
|
|
|
m_local_storage = devtools().register_actor<StorageActor>(m_tab, Web::StorageAPI::StorageEndpointType::LocalStorage);
|
|
|
|
|
return *m_local_storage.strong_ref();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
StorageActor& WatcherActor::session_storage_actor()
|
|
|
|
|
{
|
|
|
|
|
if (auto storage = m_session_storage.strong_ref())
|
|
|
|
|
return *storage;
|
|
|
|
|
|
|
|
|
|
m_session_storage = devtools().register_actor<StorageActor>(m_tab, Web::StorageAPI::StorageEndpointType::SessionStorage);
|
|
|
|
|
return *m_session_storage.strong_ref();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void WatcherActor::send_storage_resource_available_message(StorageActor& storage)
|
|
|
|
|
{
|
|
|
|
|
JsonArray resources;
|
|
|
|
|
resources.must_append(storage.serialize_storage());
|
|
|
|
|
|
|
|
|
|
JsonArray typed_resources;
|
|
|
|
|
typed_resources.must_append(storage.resource_type());
|
|
|
|
|
typed_resources.must_append(move(resources));
|
|
|
|
|
|
|
|
|
|
JsonArray array;
|
|
|
|
|
array.must_append(move(typed_resources));
|
|
|
|
|
|
|
|
|
|
JsonObject message;
|
|
|
|
|
message.set("type"sv, "resources-available-array"sv);
|
|
|
|
|
message.set("array"sv, move(array));
|
|
|
|
|
send_message(move(message));
|
|
|
|
|
}
|
|
|
|
|
|
2025-02-15 09:57:36 -03:00
|
|
|
}
|