ladybird/Libraries/LibWeb/StorageAPI/StorageShelf.cpp
Aliaksandr Kalenik 84b9224121 Everywhere: Implement persistence of localStorage using sqlite
This change follows the pattern of our cookies persistence
implementation: the "browser" process is responsible for interacting
with the sqlite database, and WebContent communicates all storage
operations via IPC.

The new database table uses (storage_endpoint, storage_key, bottle_key)
as the primary key. This design follows concepts from the
https://storage.spec.whatwg.org/ and is intended to support reuse of the
persistence layer for other APIs (e.g., CacheStorage, IndexedDB). For
now, `storage_endpoint` is always "localStorage", `storage_key` is the
website's origin, and `bottle_key` is the name of the localStorage key.
2025-06-12 17:04:35 +02:00

29 lines
791 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 <LibGC/Heap.h>
#include <LibWeb/StorageAPI/StorageShelf.h>
namespace Web::StorageAPI {
GC_DEFINE_ALLOCATOR(StorageShelf);
void StorageShelf::visit_edges(GC::Cell::Visitor& visitor)
{
Base::visit_edges(visitor);
visitor.visit(m_bucket_map);
}
// https://storage.spec.whatwg.org/#create-a-storage-shelf
StorageShelf::StorageShelf(GC::Ref<Page> page, StorageKey key, 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.
m_bucket_map.set("default"_string, StorageBucket::create(heap(), page, key, type));
// 3. Return shelf.
}
}