mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-05 07:41:01 +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
|
@ -7,6 +7,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <AK/HashMap.h>
|
||||
#include <LibGC/Ptr.h>
|
||||
#include <LibWeb/Forward.h>
|
||||
#include <LibWeb/StorageAPI/StorageKey.h>
|
||||
#include <LibWeb/StorageAPI/StorageShelf.h>
|
||||
|
@ -16,14 +17,23 @@ namespace Web::StorageAPI {
|
|||
|
||||
// https://storage.spec.whatwg.org/#storage-shed
|
||||
// A storage shed is a map of storage keys to storage shelves. It is initially empty.
|
||||
class StorageShed {
|
||||
class StorageShed : public GC::Cell {
|
||||
GC_CELL(StorageShed, GC::Cell);
|
||||
GC_DECLARE_ALLOCATOR(StorageShed);
|
||||
|
||||
public:
|
||||
Optional<StorageShelf&> obtain_a_storage_shelf(HTML::EnvironmentSettingsObject const&, StorageType);
|
||||
static GC::Ref<StorageShed> create(GC::Heap& heap) { return heap.allocate<StorageShed>(); }
|
||||
|
||||
GC::Ptr<StorageShelf> obtain_a_storage_shelf(HTML::EnvironmentSettingsObject const&, StorageType);
|
||||
|
||||
virtual void visit_edges(GC::Cell::Visitor& visitor) override;
|
||||
|
||||
private:
|
||||
OrderedHashMap<StorageKey, StorageShelf> m_data;
|
||||
StorageShed() = default;
|
||||
|
||||
OrderedHashMap<StorageKey, GC::Ref<StorageShelf>> m_data;
|
||||
};
|
||||
|
||||
StorageShed& user_agent_storage_shed();
|
||||
GC::Ref<StorageShed> user_agent_storage_shed(GC::Heap&);
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue