Skip to content

Commit adcf546

Browse files
trflynn89awesomekling
authored andcommitted
LibWeb+WebContent: Rename the http-cache flag to http-memory-cache
Rather than having http-cache and http-disk-cache, let's rename the former to http-memory-cache to be extra clear what we are talking about.
1 parent b376ab4 commit adcf546

File tree

10 files changed

+31
-33
lines changed

10 files changed

+31
-33
lines changed

AK/Debug.h.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,8 @@
106106
# cmakedefine01 HTML_SCRIPT_DEBUG
107107
#endif
108108

109-
#ifndef HTTP_CACHE_DEBUG
110-
# cmakedefine01 HTTP_CACHE_DEBUG
109+
#ifndef HTTP_MEMORY_CACHE_DEBUG
110+
# cmakedefine01 HTTP_MEMORY_CACHE_DEBUG
111111
#endif
112112

113113
#ifndef HTTPJOB_DEBUG

Libraries/LibWeb/Fetch/Fetching/Fetching.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@
7070

7171
namespace Web::Fetch::Fetching {
7272

73-
bool g_http_cache_enabled = false;
73+
bool g_http_memory_cache_enabled = false;
7474

7575
#define TRY_OR_IGNORE(expression) \
7676
({ \
@@ -1424,14 +1424,14 @@ class CachePartition : public RefCounted<CachePartition> {
14241424
// - the presented target URI (Section 7.1 of [HTTP]) and that of the stored response match, and
14251425
auto it = m_cache.find(url);
14261426
if (it == m_cache.end()) {
1427-
dbgln_if(HTTP_CACHE_DEBUG, "\033[31;1mHTTP CACHE MISS!\033[0m {}", url);
1427+
dbgln_if(HTTP_MEMORY_CACHE_DEBUG, "\033[31;1mHTTP CACHE MISS!\033[0m {}", url);
14281428
return {};
14291429
}
14301430
auto const& cached_response = it->value;
14311431

14321432
// - the request method associated with the stored response allows it to be used for the presented request, and
14331433
if (method != cached_response->method()) {
1434-
dbgln_if(HTTP_CACHE_DEBUG, "\033[31;1mHTTP CACHE MISS!\033[0m (Bad method) {}", url);
1434+
dbgln_if(HTTP_MEMORY_CACHE_DEBUG, "\033[31;1mHTTP CACHE MISS!\033[0m (Bad method) {}", url);
14351435
return {};
14361436
}
14371437

@@ -1445,7 +1445,7 @@ class CachePartition : public RefCounted<CachePartition> {
14451445
// + allowed to be served stale (see Section 4.2.4), or
14461446
// + successfully validated (see Section 4.3).
14471447

1448-
dbgln_if(HTTP_CACHE_DEBUG, "\033[32;1mHTTP CACHE HIT!\033[0m {}", url);
1448+
dbgln_if(HTTP_MEMORY_CACHE_DEBUG, "\033[32;1mHTTP CACHE HIT!\033[0m {}", url);
14491449
return cached_response->clone(realm);
14501450
}
14511451

@@ -1498,7 +1498,7 @@ class HTTPCache {
14981498
// https://fetch.spec.whatwg.org/#determine-the-http-cache-partition
14991499
static RefPtr<CachePartition> determine_the_http_cache_partition(Infrastructure::Request const& request)
15001500
{
1501-
if (!g_http_cache_enabled)
1501+
if (!g_http_memory_cache_enabled)
15021502
return nullptr;
15031503

15041504
// 1. Let key be the result of determining the network partition key given request.
@@ -1905,7 +1905,7 @@ GC::Ref<PendingResponse> http_network_or_cache_fetch(JS::Realm& realm, Infrastru
19051905

19061906
// 4. If the revalidatingFlag is set and forwardResponse’s status is 304, then:
19071907
if (revalidating_flag->value() && forward_response->status() == 304) {
1908-
dbgln_if(HTTP_CACHE_DEBUG, "\033[34;1mHTTP CACHE REVALIDATE (304)\033[0m {}", http_request->current_url());
1908+
dbgln_if(HTTP_MEMORY_CACHE_DEBUG, "\033[34;1mHTTP CACHE REVALIDATE (304)\033[0m {}", http_request->current_url());
19091909

19101910
// 1. Update storedResponse’s header list using forwardResponse’s header list, as per the "Freshening
19111911
// Stored Responses upon Validation" chapter of HTTP Caching.
@@ -2524,17 +2524,17 @@ void append_fetch_metadata_headers_for_request(Infrastructure::Request& request)
25242524
set_sec_fetch_user_header(request);
25252525
}
25262526

2527-
void set_http_cache_enabled(bool const enabled)
2527+
void set_http_memory_cache_enabled(bool const enabled)
25282528
{
2529-
g_http_cache_enabled = enabled;
2529+
g_http_memory_cache_enabled = enabled;
25302530
}
25312531

2532-
bool http_cache_enabled()
2532+
bool http_memory_cache_enabled()
25332533
{
2534-
return g_http_cache_enabled;
2534+
return g_http_memory_cache_enabled;
25352535
}
25362536

2537-
void clear_http_cache()
2537+
void clear_http_memory_cache()
25382538
{
25392539
HTTPCache::the().clear_cache();
25402540
}

Libraries/LibWeb/Fetch/Fetching/Fetching.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ void set_sec_fetch_site_header(Infrastructure::Request&);
5555
void set_sec_fetch_user_header(Infrastructure::Request&);
5656
void append_fetch_metadata_headers_for_request(Infrastructure::Request&);
5757

58-
WEB_API void set_http_cache_enabled(bool enabled);
59-
WEB_API bool http_cache_enabled();
60-
WEB_API void clear_http_cache();
58+
WEB_API void set_http_memory_cache_enabled(bool enabled);
59+
WEB_API bool http_memory_cache_enabled();
60+
WEB_API void clear_http_memory_cache();
6161

6262
}

Libraries/LibWeb/Internals/Internals.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -301,8 +301,8 @@ void Internals::expire_cookies_with_time_offset(WebIDL::LongLong seconds)
301301

302302
bool Internals::set_http_memory_cache_enabled(bool enabled)
303303
{
304-
auto was_enabled = Web::Fetch::Fetching::http_cache_enabled();
305-
Web::Fetch::Fetching::set_http_cache_enabled(enabled);
304+
auto was_enabled = Web::Fetch::Fetching::http_memory_cache_enabled();
305+
Web::Fetch::Fetching::set_http_memory_cache_enabled(enabled);
306306
return was_enabled;
307307
}
308308

Libraries/LibWebView/Application.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ ErrorOr<void> Application::initialize(Main::Arguments const& arguments)
117117
bool log_all_js_exceptions = false;
118118
bool disable_site_isolation = false;
119119
bool enable_idl_tracing = false;
120-
bool disable_http_cache = false;
120+
bool disable_http_memory_cache = false;
121121
bool enable_http_disk_cache = false;
122122
bool disable_content_filter = false;
123123
bool enable_autoplay = false;
@@ -168,7 +168,7 @@ ErrorOr<void> Application::initialize(Main::Arguments const& arguments)
168168
args_parser.add_option(log_all_js_exceptions, "Log all JavaScript exceptions", "log-all-js-exceptions");
169169
args_parser.add_option(disable_site_isolation, "Disable site isolation", "disable-site-isolation");
170170
args_parser.add_option(enable_idl_tracing, "Enable IDL tracing", "enable-idl-tracing");
171-
args_parser.add_option(disable_http_cache, "Disable HTTP cache", "disable-http-cache");
171+
args_parser.add_option(disable_http_memory_cache, "Disable HTTP memory cache", "disable-http-memory-cache");
172172
args_parser.add_option(enable_http_disk_cache, "Enable HTTP disk cache", "enable-http-disk-cache");
173173
args_parser.add_option(disable_content_filter, "Disable content filter", "disable-content-filter");
174174
args_parser.add_option(enable_autoplay, "Enable multimedia autoplay", "enable-autoplay");
@@ -273,7 +273,7 @@ ErrorOr<void> Application::initialize(Main::Arguments const& arguments)
273273
.log_all_js_exceptions = log_all_js_exceptions ? LogAllJSExceptions::Yes : LogAllJSExceptions::No,
274274
.disable_site_isolation = disable_site_isolation ? DisableSiteIsolation::Yes : DisableSiteIsolation::No,
275275
.enable_idl_tracing = enable_idl_tracing ? EnableIDLTracing::Yes : EnableIDLTracing::No,
276-
.enable_http_cache = disable_http_cache ? EnableHTTPCache::No : EnableHTTPCache::Yes,
276+
.enable_http_memory_cache = disable_http_memory_cache ? EnableMemoryHTTPCache::No : EnableMemoryHTTPCache::Yes,
277277
.expose_internals_object = expose_internals_object ? ExposeInternalsObject::Yes : ExposeInternalsObject::No,
278278
.force_cpu_painting = force_cpu_painting ? ForceCPUPainting::Yes : ForceCPUPainting::No,
279279
.force_fontconfig = force_fontconfig ? ForceFontconfig::Yes : ForceFontconfig::No,

Libraries/LibWebView/HelperProcess.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,8 @@ static ErrorOr<NonnullRefPtr<WebView::WebContentClient>> launch_web_content_proc
110110
arguments.append("--disable-site-isolation"sv);
111111
if (web_content_options.enable_idl_tracing == WebView::EnableIDLTracing::Yes)
112112
arguments.append("--enable-idl-tracing"sv);
113-
if (web_content_options.enable_http_cache == WebView::EnableHTTPCache::Yes)
114-
arguments.append("--enable-http-cache"sv);
113+
if (web_content_options.enable_http_memory_cache == WebView::EnableMemoryHTTPCache::Yes)
114+
arguments.append("--enable-http-memory-cache"sv);
115115
if (web_content_options.expose_internals_object == WebView::ExposeInternalsObject::Yes)
116116
arguments.append("--expose-internals-object"sv);
117117
if (web_content_options.force_cpu_painting == WebView::ForceCPUPainting::Yes)

Libraries/LibWebView/Options.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ enum class EnableIDLTracing {
119119
Yes,
120120
};
121121

122-
enum class EnableHTTPCache {
122+
enum class EnableMemoryHTTPCache {
123123
No,
124124
Yes,
125125
};
@@ -163,7 +163,7 @@ struct WebContentOptions {
163163
LogAllJSExceptions log_all_js_exceptions { LogAllJSExceptions::No };
164164
DisableSiteIsolation disable_site_isolation { DisableSiteIsolation::No };
165165
EnableIDLTracing enable_idl_tracing { EnableIDLTracing::No };
166-
EnableHTTPCache enable_http_cache { EnableHTTPCache::No };
166+
EnableMemoryHTTPCache enable_http_memory_cache { EnableMemoryHTTPCache::No };
167167
ExposeInternalsObject expose_internals_object { ExposeInternalsObject::No };
168168
ForceCPUPainting force_cpu_painting { ForceCPUPainting::No };
169169
ForceFontconfig force_fontconfig { ForceFontconfig::No };

Meta/CMake/all_the_debug_macros.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ set(GIF_DEBUG ON)
2222
set(HEAP_DEBUG ON)
2323
set(HIGHLIGHT_FOCUSED_FRAME_DEBUG ON)
2424
set(HTML_SCRIPT_DEBUG ON)
25-
set(HTTP_CACHE_DEBUG ON)
25+
set(HTTP_MEMORY_CACHE_DEBUG ON)
2626
set(HTTPJOB_DEBUG ON)
2727
set(HUNKS_DEBUG ON)
2828
set(ICO_DEBUG ON)

Services/WebContent/ConnectionFromClient.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ void ConnectionFromClient::debug_request(u64 page_id, ByteString request, ByteSt
387387
}
388388

389389
if (request == "clear-cache") {
390-
Web::Fetch::Fetching::clear_http_cache();
390+
Web::Fetch::Fetching::clear_http_memory_cache();
391391
return;
392392
}
393393

Services/WebContent/main.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ ErrorOr<int> ladybird_main(Main::Arguments arguments)
8080
bool log_all_js_exceptions = false;
8181
bool disable_site_isolation = false;
8282
bool enable_idl_tracing = false;
83-
bool enable_http_cache = false;
83+
bool enable_http_memory_cache = false;
8484
bool force_cpu_painting = false;
8585
bool force_fontconfig = false;
8686
bool collect_garbage_on_every_allocation = false;
@@ -103,7 +103,7 @@ ErrorOr<int> ladybird_main(Main::Arguments arguments)
103103
args_parser.add_option(log_all_js_exceptions, "Log all JavaScript exceptions", "log-all-js-exceptions");
104104
args_parser.add_option(disable_site_isolation, "Disable site isolation", "disable-site-isolation");
105105
args_parser.add_option(enable_idl_tracing, "Enable IDL tracing", "enable-idl-tracing");
106-
args_parser.add_option(enable_http_cache, "Enable HTTP cache", "enable-http-cache");
106+
args_parser.add_option(enable_http_memory_cache, "Enable HTTP cache", "enable-http-memory-cache");
107107
args_parser.add_option(force_cpu_painting, "Force CPU painting", "force-cpu-painting");
108108
args_parser.add_option(force_fontconfig, "Force using fontconfig for font loading", "force-fontconfig");
109109
args_parser.add_option(collect_garbage_on_every_allocation, "Collect garbage after every JS heap allocation", "collect-garbage-on-every-allocation");
@@ -146,10 +146,8 @@ ErrorOr<int> ladybird_main(Main::Arguments arguments)
146146
if (disable_site_isolation)
147147
WebView::disable_site_isolation();
148148

149-
if (enable_http_cache) {
150-
151-
Web::Fetch::Fetching::set_http_cache_enabled(true);
152-
}
149+
if (enable_http_memory_cache)
150+
Web::Fetch::Fetching::set_http_memory_cache_enabled(true);
153151

154152
Web::Painting::set_paint_viewport_scrollbars(!disable_scrollbar_painting);
155153

0 commit comments

Comments
 (0)