ladybird/Libraries/LibWeb/StorageAPI/StorageShelf.cpp
Shannon Booth 2066ed2318 LibWeb: Correctly initialize Storage objects on the Document
Instead of storing all storage objects in static memory, we now
follow the the spec by lazily creating a unique Storage object
on each document object.

Each Storage object now holds a 'proxy' to the underlying backing
storage. For now, this proxy is simply a reference to the backing
object. In the future, it will need to be some type of interface
object that stores on a SQLite database or similar.

Session storage is now correctly stored / tracked as part of the
TraversableNavigable object.

Local storage is still stored in a static map, but eventually this
should be factored into something that is stored at the user agent
level.
2025-01-02 11:31:15 +01:00

20 lines
540 B
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*
* Copyright (c) 2024-2025, Shannon Booth <shannon@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibWeb/StorageAPI/StorageShelf.h>
namespace Web::StorageAPI {
// https://storage.spec.whatwg.org/#create-a-storage-shelf
StorageShelf::StorageShelf(StorageType type)
{
// 1. Let shelf be a new storage shelf.
// 2. Set shelfs bucket map["default"] to the result of running create a storage bucket with type.
bucket_map.set("default"_string, StorageBucket { type });
// 3. Return shelf.
}
}