ladybird/Libraries/LibDevTools/Actors/IndexedDBActor.h
Sam Atkins e667aaaab1 LibDevTools+LibWeb: Send IndexedDB change updates
The Storage panel expects storesUpdate messages after watched storage
changes. Summarize committed IndexedDB mutation logs into DevTools paths
and forward them through WebContent so Firefox can refresh database,
object-store, and record rows without polling.

Firefox's behaviour is less than ideal here. A lot of things don't
update automatically even inspecting a page in Firefox. Some
things (like new databases) won't show up until you fully refresh the
page. So that makes it a bit hard to know that we're doing things
correctly. As far as I can tell, we are at least behaving as well as
Firefox requires.

We do have one workaround: Firefox doesn't display record updates
without a manual refresh, and in fact any change messages for them show
up as rows in the host's database table. So for now, we filter them out
to avoid visual weirdness in the inspector.
2026-06-19 14:25:39 +02:00

39 lines
988 B
C++

/*
* Copyright (c) 2026, Ladybird contributors
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/Function.h>
#include <LibDevTools/Actor.h>
namespace DevTools {
class DEVTOOLS_API IndexedDBActor final : public Actor {
public:
static constexpr auto base_name = "indexed-db"sv;
static NonnullRefPtr<IndexedDBActor> create(DevToolsServer&, String name, WeakPtr<TabActor>);
virtual ~IndexedDBActor() override;
void get_storage_resource(Function<void(JsonObject)>);
private:
IndexedDBActor(DevToolsServer&, String name, WeakPtr<TabActor>);
virtual void handle_message(Message const&) override;
void get_fields(Message const&);
void get_store_objects(Message const&);
void on_indexed_database_changed(JsonObject);
JsonObject serialize_storage(JsonObject hosts) const;
void send_inspection_error(Message const&, Error const&);
WeakPtr<TabActor> m_tab;
u64 m_indexed_database_change_listener_id { 0 };
};
}