ladybird/Libraries/LibWeb/IndexedDB/Internal/ConnectionQueueHandler.h
Shannon Booth f87041bf3a LibGC+Everywhere: Factor out a LibGC from LibJS
Resulting in a massive rename across almost everywhere! Alongside the
namespace change, we now have the following names:

 * JS::NonnullGCPtr -> GC::Ref
 * JS::GCPtr -> GC::Ptr
 * JS::HeapFunction -> GC::Function
 * JS::CellImpl -> GC::Cell
 * JS::Handle -> GC::Root
2024-11-15 14:49:20 +01:00

48 lines
1.1 KiB
C++

/*
* Copyright (c) 2024, stelar7 <dudedbz@gmail.com>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/HashMap.h>
#include <LibGC/Root.h>
#include <LibWeb/DOM/EventTarget.h>
#include <LibWeb/IndexedDB/IDBRequest.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>>;
// https://w3c.github.io/IndexedDB/#connection-queues
class ConnectionQueueHandler {
public:
static ConnectionQueue& for_key_and_name(StorageAPI::StorageKey& key, String& name);
static ConnectionQueueHandler& the()
{
static ConnectionQueueHandler s_instance;
return s_instance;
}
private:
ConnectionMap m_open_requests;
};
}