2024-12-26 11:56:03 +13:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2024-2025, Shannon Booth <shannon@serenityos.org>
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <AK/HashMap.h>
|
|
|
|
#include <AK/String.h>
|
2025-06-11 18:51:22 +02:00
|
|
|
#include <LibGC/Ptr.h>
|
2024-12-26 11:56:03 +13:00
|
|
|
#include <LibWeb/StorageAPI/StorageBottle.h>
|
|
|
|
#include <LibWeb/StorageAPI/StorageType.h>
|
|
|
|
|
|
|
|
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.
|
2025-06-11 18:51:22 +02:00
|
|
|
using BucketMap = OrderedHashMap<String, GC::Ref<StorageBucket>>;
|
2024-12-26 11:56:03 +13:00
|
|
|
|
2025-06-11 18:51:22 +02:00
|
|
|
class StorageShelf : public GC::Cell {
|
|
|
|
GC_CELL(StorageShelf, GC::Cell);
|
|
|
|
GC_DECLARE_ALLOCATOR(StorageShelf);
|
|
|
|
|
|
|
|
public:
|
2025-06-08 23:35:46 +02:00
|
|
|
static GC::Ref<StorageShelf> create(GC::Heap& heap, GC::Ref<Page> page, StorageKey key, StorageType type) { return heap.allocate<StorageShelf>(page, key, type); }
|
2025-06-11 18:51:22 +02:00
|
|
|
|
|
|
|
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:
|
2025-06-08 23:35:46 +02:00
|
|
|
explicit StorageShelf(GC::Ref<Page>, StorageKey, StorageType);
|
2024-12-26 11:56:03 +13:00
|
|
|
|
2025-06-11 18:51:22 +02:00
|
|
|
BucketMap m_bucket_map;
|
2024-12-26 11:56:03 +13:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|