From b43bb2429a107d5389829de3c6c7fc5c0b3d9ade Mon Sep 17 00:00:00 2001 From: stelar7 Date: Wed, 8 Jan 2025 23:55:08 +0100 Subject: [PATCH] LibWeb: Rename ConnectionQueue to RequestList --- Libraries/LibWeb/CMakeLists.txt | 11 ++++--- Libraries/LibWeb/Forward.h | 1 + .../Internal/ConnectionQueueHandler.h | 23 ++----------- .../LibWeb/IndexedDB/Internal/Database.cpp | 6 ++-- .../LibWeb/IndexedDB/Internal/RequestList.cpp | 33 +++++++++++++++++++ .../LibWeb/IndexedDB/Internal/RequestList.h | 21 ++++++++++++ 6 files changed, 67 insertions(+), 28 deletions(-) create mode 100644 Libraries/LibWeb/IndexedDB/Internal/RequestList.cpp create mode 100644 Libraries/LibWeb/IndexedDB/Internal/RequestList.h diff --git a/Libraries/LibWeb/CMakeLists.txt b/Libraries/LibWeb/CMakeLists.txt index 5090decc633..96a9cd5e0d5 100644 --- a/Libraries/LibWeb/CMakeLists.txt +++ b/Libraries/LibWeb/CMakeLists.txt @@ -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 diff --git a/Libraries/LibWeb/Forward.h b/Libraries/LibWeb/Forward.h index 07d6692fa9e..950a6d93f83 100644 --- a/Libraries/LibWeb/Forward.h +++ b/Libraries/LibWeb/Forward.h @@ -586,6 +586,7 @@ class IDBOpenDBRequest; class IDBRequest; class IDBTransaction; class IDBVersionChangeEvent; +class RequestList; } namespace Web::Internals { diff --git a/Libraries/LibWeb/IndexedDB/Internal/ConnectionQueueHandler.h b/Libraries/LibWeb/IndexedDB/Internal/ConnectionQueueHandler.h index c9715830576..acb2cd2ab44 100644 --- a/Libraries/LibWeb/IndexedDB/Internal/ConnectionQueueHandler.h +++ b/Libraries/LibWeb/IndexedDB/Internal/ConnectionQueueHandler.h @@ -7,34 +7,17 @@ #pragma once #include -#include -#include -#include +#include #include namespace Web::IndexedDB { -class ConnectionQueue : public AK::Vector> { -public: - bool all_previous_requests_processed(GC::Ref const& request) const - { - for (auto const& entry : *this) { - if (entry == request) - return true; - if (!entry->processed()) - return false; - } - - return true; - } -}; - -using ConnectionMap = HashMap>; +using ConnectionMap = HashMap>; // 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; diff --git a/Libraries/LibWeb/IndexedDB/Internal/Database.cpp b/Libraries/LibWeb/IndexedDB/Internal/Database.cpp index fbc4daa3f71..8fdf3ba3f36 100644 --- a/Libraries/LibWeb/IndexedDB/Internal/Database.cpp +++ b/Libraries/LibWeb/IndexedDB/Internal/Database.cpp @@ -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(); + return HashMap(); }) .ensure(name, [] { - return ConnectionQueue(); + return RequestList(); }); } diff --git a/Libraries/LibWeb/IndexedDB/Internal/RequestList.cpp b/Libraries/LibWeb/IndexedDB/Internal/RequestList.cpp new file mode 100644 index 00000000000..dbbeab9409f --- /dev/null +++ b/Libraries/LibWeb/IndexedDB/Internal/RequestList.cpp @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024, stelar7 + * + * SPDX-License-Identifier: BSD-2-Clause + */ + +#include + +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 const& request) const +{ + for (auto const& entry : *this) { + if (entry == request) + return true; + if (!entry->processed()) + return false; + } + + return true; +} + +} diff --git a/Libraries/LibWeb/IndexedDB/Internal/RequestList.h b/Libraries/LibWeb/IndexedDB/Internal/RequestList.h new file mode 100644 index 00000000000..8e11b7677cb --- /dev/null +++ b/Libraries/LibWeb/IndexedDB/Internal/RequestList.h @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2024, stelar7 + * + * SPDX-License-Identifier: BSD-2-Clause + */ + +#pragma once + +#include +#include +#include + +namespace Web::IndexedDB { + +class RequestList : public AK::Vector> { +public: + bool all_requests_processed() const; + bool all_previous_requests_processed(GC::Ref const& request) const; +}; + +}