ladybird/Libraries/LibHTTP/Cache/DiskCacheSettings.cpp
Timothy Flynn 7d60d0bfb7 LibHTTP+LibWebView+RequestServer: Allow users to set disk cache limits
This adds a settings box to about:settings to allow users to limit the
disk cache size. This will override the default 5 GiB limit. We do not
automatically delete cache data if the new limit is suddenly less than
the used disk space; this will happen on the next request. This allows
multiple changes to the settings in a row without thrashing the cache.

In the future, we can add more toggles, such as disabling the disk
cache altogether.
2026-02-13 10:20:52 -05:00

29 lines
565 B
C++

/*
* Copyright (c) 2026, Tim Flynn <trflynn89@ladybird.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibHTTP/Cache/DiskCacheSettings.h>
#include <LibIPC/Decoder.h>
#include <LibIPC/Encoder.h>
namespace IPC {
template<>
ErrorOr<void> encode(Encoder& encoder, HTTP::DiskCacheSettings const& sizes)
{
TRY(encoder.encode(sizes.maximum_size));
return {};
}
template<>
ErrorOr<HTTP::DiskCacheSettings> decode(Decoder& decoder)
{
auto maximum_size = TRY(decoder.decode<u64>());
return HTTP::DiskCacheSettings { maximum_size };
}
}