mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-07 00:29:15 +00:00
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:
parent
70a29f36c6
commit
f53559cb55
Notes:
github-actions[bot]
2025-06-12 15:06:02 +00:00
Author: https://github.com/kalenikaliaksandr
Commit: f53559cb55
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5052
Reviewed-by: https://github.com/shannonbooth ✅
Reviewed-by: https://github.com/trflynn89
12 changed files with 117 additions and 44 deletions
|
@ -8,7 +8,7 @@
|
|||
|
||||
#include <AK/HashMap.h>
|
||||
#include <AK/String.h>
|
||||
#include <LibWeb/Forward.h>
|
||||
#include <LibGC/Ptr.h>
|
||||
#include <LibWeb/StorageAPI/StorageBottle.h>
|
||||
#include <LibWeb/StorageAPI/StorageType.h>
|
||||
|
||||
|
@ -16,12 +16,24 @@ namespace Web::StorageAPI {
|
|||
|
||||
// https://storage.spec.whatwg.org/#storage-shelf
|
||||
// A storage shelf exists for each storage key within a storage shed. It holds a bucket map, which is a map of strings to storage buckets.
|
||||
using BucketMap = OrderedHashMap<String, StorageBucket>;
|
||||
using BucketMap = OrderedHashMap<String, GC::Ref<StorageBucket>>;
|
||||
|
||||
struct StorageShelf {
|
||||
class StorageShelf : public GC::Cell {
|
||||
GC_CELL(StorageShelf, GC::Cell);
|
||||
GC_DECLARE_ALLOCATOR(StorageShelf);
|
||||
|
||||
public:
|
||||
static GC::Ref<StorageShelf> create(GC::Heap& heap, StorageType type) { return heap.allocate<StorageShelf>(type); }
|
||||
|
||||
BucketMap& bucket_map() { return m_bucket_map; }
|
||||
BucketMap const& bucket_map() const { return m_bucket_map; }
|
||||
|
||||
virtual void visit_edges(GC::Cell::Visitor& visitor) override;
|
||||
|
||||
private:
|
||||
explicit StorageShelf(StorageType);
|
||||
|
||||
BucketMap bucket_map;
|
||||
BucketMap m_bucket_map;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue