mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-31 21:29:06 +00:00
LibWeb/IDB: Keep track of the connection used to start a transaction
This commit is contained in:
parent
d1dabb9039
commit
fc93ec135e
Notes:
github-actions[bot]
2025-04-11 01:14:28 +00:00
Author: https://github.com/stelar7
Commit: fc93ec135e
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4306
Reviewed-by: https://github.com/ADKaster ✅
3 changed files with 8 additions and 0 deletions
|
@ -44,6 +44,7 @@ void IDBDatabase::visit_edges(Visitor& visitor)
|
|||
Base::visit_edges(visitor);
|
||||
visitor.visit(m_object_store_set);
|
||||
visitor.visit(m_associated_database);
|
||||
visitor.visit(m_transactions);
|
||||
}
|
||||
|
||||
void IDBDatabase::set_onabort(WebIDL::CallbackType* event_handler)
|
||||
|
|
|
@ -59,6 +59,9 @@ public:
|
|||
m_object_store_set.remove_first_matching([&](auto& entry) { return entry == object_store; });
|
||||
}
|
||||
|
||||
[[nodiscard]] ReadonlySpan<GC::Ref<IDBTransaction>> transactions() { return m_transactions; }
|
||||
void add_transaction(GC::Ref<IDBTransaction> transaction) { m_transactions.append(transaction); }
|
||||
|
||||
[[nodiscard]] GC::Ref<HTML::DOMStringList> object_store_names();
|
||||
WebIDL::ExceptionOr<GC::Ref<IDBObjectStore>> create_object_store(String const&, IDBObjectStoreParameters const&);
|
||||
WebIDL::ExceptionOr<void> delete_object_store(String const&);
|
||||
|
@ -98,6 +101,9 @@ private:
|
|||
// So we stash the one we have when opening a connection.
|
||||
GC::Ref<Database> m_associated_database;
|
||||
|
||||
// NOTE: We need to keep track of what transactions were created by this connection
|
||||
Vector<GC::Ref<IDBTransaction>> m_transactions;
|
||||
|
||||
// NOTE: Used for debug purposes
|
||||
String m_uuid;
|
||||
};
|
||||
|
|
|
@ -24,6 +24,7 @@ IDBTransaction::IDBTransaction(JS::Realm& realm, GC::Ref<IDBDatabase> connection
|
|||
, m_scope(move(scopes))
|
||||
{
|
||||
m_uuid = MUST(Crypto::generate_random_uuid());
|
||||
connection->add_transaction(*this);
|
||||
}
|
||||
|
||||
GC::Ref<IDBTransaction> IDBTransaction::create(JS::Realm& realm, GC::Ref<IDBDatabase> connection, Bindings::IDBTransactionMode mode, Bindings::IDBTransactionDurability durability = Bindings::IDBTransactionDurability::Default, Vector<GC::Ref<ObjectStore>> scopes = {})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue