mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-02 22:30:31 +00:00
LibWeb: Rename ConnectionQueue to RequestList
This commit is contained in:
parent
439245b14a
commit
b43bb2429a
Notes:
github-actions[bot]
2025-01-14 22:47:13 +00:00
Author: https://github.com/stelar7
Commit: b43bb2429a
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3190
Reviewed-by: https://github.com/Lubrsi
Reviewed-by: https://github.com/gmta ✅
6 changed files with 67 additions and 28 deletions
|
@ -524,19 +524,20 @@ set(SOURCES
|
||||||
Infra/ByteSequences.cpp
|
Infra/ByteSequences.cpp
|
||||||
Infra/JSON.cpp
|
Infra/JSON.cpp
|
||||||
Infra/Strings.cpp
|
Infra/Strings.cpp
|
||||||
IndexedDB/Internal/Algorithms.cpp
|
|
||||||
IndexedDB/Internal/Database.cpp
|
|
||||||
IndexedDB/Internal/Key.cpp
|
|
||||||
IndexedDB/IDBDatabase.cpp
|
|
||||||
IndexedDB/IDBCursor.cpp
|
IndexedDB/IDBCursor.cpp
|
||||||
|
IndexedDB/IDBDatabase.cpp
|
||||||
IndexedDB/IDBFactory.cpp
|
IndexedDB/IDBFactory.cpp
|
||||||
IndexedDB/IDBOpenDBRequest.cpp
|
|
||||||
IndexedDB/IDBIndex.cpp
|
IndexedDB/IDBIndex.cpp
|
||||||
IndexedDB/IDBKeyRange.cpp
|
IndexedDB/IDBKeyRange.cpp
|
||||||
IndexedDB/IDBObjectStore.cpp
|
IndexedDB/IDBObjectStore.cpp
|
||||||
|
IndexedDB/IDBOpenDBRequest.cpp
|
||||||
IndexedDB/IDBRequest.cpp
|
IndexedDB/IDBRequest.cpp
|
||||||
IndexedDB/IDBTransaction.cpp
|
IndexedDB/IDBTransaction.cpp
|
||||||
IndexedDB/IDBVersionChangeEvent.cpp
|
IndexedDB/IDBVersionChangeEvent.cpp
|
||||||
|
IndexedDB/Internal/Algorithms.cpp
|
||||||
|
IndexedDB/Internal/Database.cpp
|
||||||
|
IndexedDB/Internal/Key.cpp
|
||||||
|
IndexedDB/Internal/RequestList.cpp
|
||||||
Internals/Inspector.cpp
|
Internals/Inspector.cpp
|
||||||
Internals/InternalAnimationTimeline.cpp
|
Internals/InternalAnimationTimeline.cpp
|
||||||
Internals/Internals.cpp
|
Internals/Internals.cpp
|
||||||
|
|
|
@ -586,6 +586,7 @@ class IDBOpenDBRequest;
|
||||||
class IDBRequest;
|
class IDBRequest;
|
||||||
class IDBTransaction;
|
class IDBTransaction;
|
||||||
class IDBVersionChangeEvent;
|
class IDBVersionChangeEvent;
|
||||||
|
class RequestList;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace Web::Internals {
|
namespace Web::Internals {
|
||||||
|
|
|
@ -7,34 +7,17 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <AK/HashMap.h>
|
#include <AK/HashMap.h>
|
||||||
#include <LibGC/Root.h>
|
#include <LibWeb/IndexedDB/Internal/RequestList.h>
|
||||||
#include <LibWeb/DOM/EventTarget.h>
|
|
||||||
#include <LibWeb/IndexedDB/IDBRequest.h>
|
|
||||||
#include <LibWeb/StorageAPI/StorageKey.h>
|
#include <LibWeb/StorageAPI/StorageKey.h>
|
||||||
|
|
||||||
namespace Web::IndexedDB {
|
namespace Web::IndexedDB {
|
||||||
|
|
||||||
class ConnectionQueue : public AK::Vector<GC::Root<IDBRequest>> {
|
using ConnectionMap = HashMap<StorageAPI::StorageKey, HashMap<String, RequestList>>;
|
||||||
public:
|
|
||||||
bool all_previous_requests_processed(GC::Ref<IDBRequest> const& request) const
|
|
||||||
{
|
|
||||||
for (auto const& entry : *this) {
|
|
||||||
if (entry == request)
|
|
||||||
return true;
|
|
||||||
if (!entry->processed())
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
using ConnectionMap = HashMap<StorageAPI::StorageKey, HashMap<String, ConnectionQueue>>;
|
|
||||||
|
|
||||||
// https://w3c.github.io/IndexedDB/#connection-queues
|
// https://w3c.github.io/IndexedDB/#connection-queues
|
||||||
class ConnectionQueueHandler {
|
class ConnectionQueueHandler {
|
||||||
public:
|
public:
|
||||||
static ConnectionQueue& for_key_and_name(StorageAPI::StorageKey& key, String& name);
|
static RequestList& for_key_and_name(StorageAPI::StorageKey& key, String& name);
|
||||||
static ConnectionQueueHandler& the()
|
static ConnectionQueueHandler& the()
|
||||||
{
|
{
|
||||||
static ConnectionQueueHandler s_instance;
|
static ConnectionQueueHandler s_instance;
|
||||||
|
|
|
@ -28,13 +28,13 @@ void Database::visit_edges(Visitor& visitor)
|
||||||
visitor.visit(m_upgrade_transaction);
|
visitor.visit(m_upgrade_transaction);
|
||||||
}
|
}
|
||||||
|
|
||||||
ConnectionQueue& ConnectionQueueHandler::for_key_and_name(StorageAPI::StorageKey& key, String& name)
|
RequestList& ConnectionQueueHandler::for_key_and_name(StorageAPI::StorageKey& key, String& name)
|
||||||
{
|
{
|
||||||
return ConnectionQueueHandler::the().m_open_requests.ensure(key, [] {
|
return ConnectionQueueHandler::the().m_open_requests.ensure(key, [] {
|
||||||
return HashMap<String, ConnectionQueue>();
|
return HashMap<String, RequestList>();
|
||||||
})
|
})
|
||||||
.ensure(name, [] {
|
.ensure(name, [] {
|
||||||
return ConnectionQueue();
|
return RequestList();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
33
Libraries/LibWeb/IndexedDB/Internal/RequestList.cpp
Normal file
33
Libraries/LibWeb/IndexedDB/Internal/RequestList.cpp
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2024, stelar7 <dudedbz@gmail.com>
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <LibWeb/IndexedDB/Internal/RequestList.h>
|
||||||
|
|
||||||
|
namespace Web::IndexedDB {
|
||||||
|
|
||||||
|
bool RequestList::all_requests_processed() const
|
||||||
|
{
|
||||||
|
for (auto const& entry : *this) {
|
||||||
|
if (!entry->processed())
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool RequestList::all_previous_requests_processed(GC::Ref<IDBRequest> const& request) const
|
||||||
|
{
|
||||||
|
for (auto const& entry : *this) {
|
||||||
|
if (entry == request)
|
||||||
|
return true;
|
||||||
|
if (!entry->processed())
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
21
Libraries/LibWeb/IndexedDB/Internal/RequestList.h
Normal file
21
Libraries/LibWeb/IndexedDB/Internal/RequestList.h
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2024, stelar7 <dudedbz@gmail.com>
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <AK/Vector.h>
|
||||||
|
#include <LibGC/Root.h>
|
||||||
|
#include <LibWeb/IndexedDB/IDBRequest.h>
|
||||||
|
|
||||||
|
namespace Web::IndexedDB {
|
||||||
|
|
||||||
|
class RequestList : public AK::Vector<GC::Root<IDBRequest>> {
|
||||||
|
public:
|
||||||
|
bool all_requests_processed() const;
|
||||||
|
bool all_previous_requests_processed(GC::Ref<IDBRequest> const& request) const;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue