mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-01 13:49:16 +00:00
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.
This commit is contained in:
parent
f53559cb55
commit
84b9224121
Notes:
github-actions[bot]
2025-06-12 15:05:54 +00:00
Author: https://github.com/kalenikaliaksandr
Commit: 84b9224121
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5052
Reviewed-by: https://github.com/shannonbooth ✅
Reviewed-by: https://github.com/trflynn89
24 changed files with 694 additions and 118 deletions
|
@ -66,6 +66,7 @@
|
|||
#include <LibWeb/RequestIdleCallback/IdleDeadline.h>
|
||||
#include <LibWeb/Selection/Selection.h>
|
||||
#include <LibWeb/StorageAPI/StorageBottle.h>
|
||||
#include <LibWeb/StorageAPI/StorageEndpoint.h>
|
||||
#include <LibWeb/WebIDL/AbstractOperations.h>
|
||||
|
||||
namespace Web::HTML {
|
||||
|
@ -464,7 +465,11 @@ WebIDL::ExceptionOr<GC::Ref<Storage>> Window::local_storage()
|
|||
return GC::Ref { *storage };
|
||||
|
||||
// 2. Let map be the result of running obtain a local storage bottle map with this's relevant settings object and "localStorage".
|
||||
auto map = StorageAPI::obtain_a_local_storage_bottle_map(relevant_settings_object(*this), "localStorage"sv);
|
||||
GC::Ptr<StorageAPI::LocalStorageBottle> map;
|
||||
auto storage_key = StorageAPI::obtain_a_storage_key(relevant_settings_object(*this));
|
||||
if (storage_key.has_value()) {
|
||||
map = StorageAPI::LocalStorageBottle::create(heap(), page(), storage_key.value(), StorageAPI::StorageEndpoint::LOCAL_STORAGE_QUOTA);
|
||||
}
|
||||
|
||||
// 3. If map is failure, then throw a "SecurityError" DOMException.
|
||||
if (!map)
|
||||
|
@ -491,7 +496,7 @@ WebIDL::ExceptionOr<GC::Ref<Storage>> Window::session_storage()
|
|||
return GC::Ref { *storage };
|
||||
|
||||
// 2. Let map be the result of running obtain a session storage bottle map with this's relevant settings object and "sessionStorage".
|
||||
auto map = StorageAPI::obtain_a_session_storage_bottle_map(relevant_settings_object(*this), "sessionStorage"sv);
|
||||
auto map = StorageAPI::obtain_a_session_storage_bottle_map(relevant_settings_object(*this), StorageAPI::StorageEndpointType::SessionStorage);
|
||||
|
||||
// 3. If map is failure, then throw a "SecurityError" DOMException.
|
||||
if (!map)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue