LibWeb: Change Storage{Bottle,Bucket,Shelf} to be GC-allocated

In upcoming changes StorageBottle will own pointers to GC-allocated
objects, so it needs to be a GC-allocated object itself to avoid
introducing more GC roots.
This commit is contained in:
Aliaksandr Kalenik 2025-06-11 18:51:22 +02:00 committed by Alexander Kalenik
commit f53559cb55
Notes: github-actions[bot] 2025-06-12 15:06:02 +00:00
12 changed files with 117 additions and 44 deletions

View file

@ -27,7 +27,7 @@ public:
Session,
};
[[nodiscard]] static GC::Ref<Storage> create(JS::Realm&, Type, NonnullRefPtr<StorageAPI::StorageBottle>);
[[nodiscard]] static GC::Ref<Storage> create(JS::Realm&, Type, GC::Ref<StorageAPI::StorageBottle>);
~Storage();
@ -44,10 +44,11 @@ public:
void dump() const;
private:
Storage(JS::Realm&, Type, NonnullRefPtr<StorageAPI::StorageBottle>);
Storage(JS::Realm&, Type, GC::Ref<StorageAPI::StorageBottle>);
virtual void initialize(JS::Realm&) override;
virtual void finalize() override;
virtual void visit_edges(GC::Cell::Visitor&) override;
// ^PlatformObject
virtual Optional<JS::Value> item_value(size_t index) const override;
@ -61,7 +62,7 @@ private:
void broadcast(Optional<String> const& key, Optional<String> const& old_value, Optional<String> const& new_value);
Type m_type {};
NonnullRefPtr<StorageAPI::StorageBottle> m_storage_bottle;
GC::Ref<StorageAPI::StorageBottle> m_storage_bottle;
u64 m_stored_bytes { 0 };
};