LibWeb/IDB: Move Records and give more descriptive names

This commit is contained in:
stelar7 2025-07-09 11:49:05 +02:00 committed by Jelle Raaijmakers
commit fe5d5639ef
Notes: github-actions[bot] 2025-08-27 14:15:50 +00:00
5 changed files with 55 additions and 38 deletions

View file

@ -18,17 +18,12 @@
#include <LibWeb/IndexedDB/Internal/Database.h>
#include <LibWeb/IndexedDB/Internal/Index.h>
#include <LibWeb/IndexedDB/Internal/KeyGenerator.h>
#include <LibWeb/IndexedDB/Internal/Record.h>
namespace Web::IndexedDB {
using KeyPath = Variant<String, Vector<String>>;
// https://w3c.github.io/IndexedDB/#object-store-record
struct Record {
GC::Ref<Key> key;
HTML::SerializationRecord value;
};
// https://w3c.github.io/IndexedDB/#object-store-construct
class ObjectStore : public JS::Cell {
GC_CELL(ObjectStore, JS::Cell);
@ -48,15 +43,15 @@ public:
AK::HashMap<String, GC::Ref<Index>>& index_set() { return m_indexes; }
GC::Ref<Database> database() const { return m_database; }
ReadonlySpan<Record> records() const { return m_records; }
ReadonlySpan<ObjectStoreRecord> records() const { return m_records; }
void remove_records_in_range(GC::Ref<IDBKeyRange> range);
bool has_record_with_key(GC::Ref<Key> key);
void store_a_record(Record const& record);
void store_a_record(ObjectStoreRecord const& record);
u64 count_records_in_range(GC::Ref<IDBKeyRange> range);
Optional<Record&> first_in_range(GC::Ref<IDBKeyRange> range);
Optional<ObjectStoreRecord&> first_in_range(GC::Ref<IDBKeyRange> range);
void clear_records();
GC::ConservativeVector<Record> first_n_in_range(GC::Ref<IDBKeyRange> range, Optional<WebIDL::UnsignedLong> count);
GC::ConservativeVector<ObjectStoreRecord> first_n_in_range(GC::Ref<IDBKeyRange> range, Optional<WebIDL::UnsignedLong> count);
protected:
virtual void visit_edges(Visitor&) override;
@ -80,7 +75,7 @@ private:
Optional<KeyGenerator> m_key_generator;
// An object store has a list of records
Vector<Record> m_records;
Vector<ObjectStoreRecord> m_records;
};
}