mirror of
https://github.com/zebrajr/ladybird.git
synced 2025-12-06 12:20:00 +01:00
This object will be needed in a future commit to store requests awaiting other requests to finish. Doing this in a separate commit just to make that commit less noisy.
46 lines
1.1 KiB
C++
46 lines
1.1 KiB
C++
/*
|
|
* Copyright (c) 2025, Tim Flynn <trflynn89@ladybird.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <AK/Error.h>
|
|
#include <AK/LexicalPath.h>
|
|
#include <AK/Optional.h>
|
|
#include <AK/StringView.h>
|
|
#include <AK/Time.h>
|
|
#include <AK/Types.h>
|
|
#include <LibDatabase/Database.h>
|
|
#include <LibURL/Forward.h>
|
|
#include <RequestServer/Cache/CacheEntry.h>
|
|
#include <RequestServer/Cache/CacheIndex.h>
|
|
|
|
namespace RequestServer {
|
|
|
|
class DiskCache {
|
|
public:
|
|
static ErrorOr<DiskCache> create();
|
|
|
|
Optional<CacheEntryWriter&> create_entry(Request&);
|
|
Optional<CacheEntryReader&> open_entry(Request&);
|
|
void clear_cache();
|
|
|
|
LexicalPath const& cache_directory() { return m_cache_directory; }
|
|
|
|
void cache_entry_closed(Badge<CacheEntry>, CacheEntry const&);
|
|
|
|
private:
|
|
DiskCache(NonnullRefPtr<Database::Database>, LexicalPath cache_directory, CacheIndex);
|
|
|
|
NonnullRefPtr<Database::Database> m_database;
|
|
|
|
HashMap<FlatPtr, NonnullOwnPtr<CacheEntry>> m_open_cache_entries;
|
|
|
|
LexicalPath m_cache_directory;
|
|
CacheIndex m_index;
|
|
};
|
|
|
|
}
|