LibWeb: Rename ConnectionQueue to RequestList

This commit is contained in:
stelar7 2025-01-08 23:55:08 +01:00 committed by Jelle Raaijmakers
parent 439245b14a
commit b43bb2429a
Notes: github-actions[bot] 2025-01-14 22:47:13 +00:00
6 changed files with 67 additions and 28 deletions

View file

@ -524,19 +524,20 @@ set(SOURCES
Infra/ByteSequences.cpp
Infra/JSON.cpp
Infra/Strings.cpp
IndexedDB/Internal/Algorithms.cpp
IndexedDB/Internal/Database.cpp
IndexedDB/Internal/Key.cpp
IndexedDB/IDBDatabase.cpp
IndexedDB/IDBCursor.cpp
IndexedDB/IDBDatabase.cpp
IndexedDB/IDBFactory.cpp
IndexedDB/IDBOpenDBRequest.cpp
IndexedDB/IDBIndex.cpp
IndexedDB/IDBKeyRange.cpp
IndexedDB/IDBObjectStore.cpp
IndexedDB/IDBOpenDBRequest.cpp
IndexedDB/IDBRequest.cpp
IndexedDB/IDBTransaction.cpp
IndexedDB/IDBVersionChangeEvent.cpp
IndexedDB/Internal/Algorithms.cpp
IndexedDB/Internal/Database.cpp
IndexedDB/Internal/Key.cpp
IndexedDB/Internal/RequestList.cpp
Internals/Inspector.cpp
Internals/InternalAnimationTimeline.cpp
Internals/Internals.cpp

View file

@ -586,6 +586,7 @@ class IDBOpenDBRequest;
class IDBRequest;
class IDBTransaction;
class IDBVersionChangeEvent;
class RequestList;
}
namespace Web::Internals {

View file

@ -7,34 +7,17 @@
#pragma once
#include <AK/HashMap.h>
#include <LibGC/Root.h>
#include <LibWeb/DOM/EventTarget.h>
#include <LibWeb/IndexedDB/IDBRequest.h>
#include <LibWeb/IndexedDB/Internal/RequestList.h>
#include <LibWeb/StorageAPI/StorageKey.h>
namespace Web::IndexedDB {
class ConnectionQueue : public AK::Vector<GC::Root<IDBRequest>> {
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>>;
using ConnectionMap = HashMap<StorageAPI::StorageKey, HashMap<String, RequestList>>;
// https://w3c.github.io/IndexedDB/#connection-queues
class ConnectionQueueHandler {
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 s_instance;

View file

@ -28,13 +28,13 @@ void Database::visit_edges(Visitor& visitor)
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 HashMap<String, ConnectionQueue>();
return HashMap<String, RequestList>();
})
.ensure(name, [] {
return ConnectionQueue();
return RequestList();
});
}

View 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;
}
}

View 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;
};
}