/* * Copyright (c) 2024-2025, Shannon Booth * * SPDX-License-Identifier: BSD-2-Clause */ #pragma once #include #include #include #include namespace Web::StorageAPI { // https://storage.spec.whatwg.org/#storage-bottle struct StorageBottle : public RefCounted { static NonnullRefPtr create(Optional quota) { return adopt_ref(*new StorageBottle(quota)); } // A storage bottle has a map, which is initially an empty map OrderedHashMap map; // A storage bottle also has a proxy map reference set, which is initially an empty set NonnullRefPtr proxy() { return *this; } // A storage bottle also has a quota, which is null or a number representing a conservative estimate of // the total amount of bytes it can hold. Null indicates the lack of a limit. Optional quota; private: explicit StorageBottle(Optional quota_) : quota(quota_) { } }; using BottleMap = OrderedHashMap>; // https://storage.spec.whatwg.org/#storage-bucket // A storage bucket is a place for storage endpoints to store data. struct StorageBucket { explicit StorageBucket(StorageType); // A storage bucket has a bottle map of storage identifiers to storage bottles. BottleMap bottle_map; }; RefPtr obtain_a_session_storage_bottle_map(HTML::EnvironmentSettingsObject&, StringView storage_identifier); RefPtr obtain_a_local_storage_bottle_map(HTML::EnvironmentSettingsObject&, StringView storage_identifier); RefPtr obtain_a_storage_bottle_map(StorageType, HTML::EnvironmentSettingsObject&, StringView storage_identifier); }