diff options
author | Ali Mohammad Pur <ali.mpfard@gmail.com> | 2021-09-28 00:08:29 +0330 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-09-28 22:32:31 +0200 |
commit | f0e2c517fc6c5f9eae904cbd2aadede28a432850 (patch) | |
tree | 98d675caa0f43873e2892c5ac1847bbd3a38812f /Userland/Libraries/LibWeb/Loader | |
parent | e9b9f89e707cf8e64377bc221ed5297ae5dc1f36 (diff) | |
download | serenity-f0e2c517fc6c5f9eae904cbd2aadede28a432850.zip |
LibWeb: Implement the dns-prefetch and preconnect link relationships
Diffstat (limited to 'Userland/Libraries/LibWeb/Loader')
-rw-r--r-- | Userland/Libraries/LibWeb/Loader/ResourceLoader.cpp | 10 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/Loader/ResourceLoader.h | 3 |
2 files changed, 13 insertions, 0 deletions
diff --git a/Userland/Libraries/LibWeb/Loader/ResourceLoader.cpp b/Userland/Libraries/LibWeb/Loader/ResourceLoader.cpp index 9d9f4c8efd..02ba6d19b0 100644 --- a/Userland/Libraries/LibWeb/Loader/ResourceLoader.cpp +++ b/Userland/Libraries/LibWeb/Loader/ResourceLoader.cpp @@ -52,6 +52,16 @@ void ResourceLoader::load_sync(LoadRequest& request, Function<void(ReadonlyBytes loop.exec(); } +void ResourceLoader::prefetch_dns(AK::URL const& url) +{ + m_protocol_client->ensure_connection(url, RequestServer::CacheLevel::ResolveOnly); +} + +void ResourceLoader::preconnect(AK::URL const& url) +{ + m_protocol_client->ensure_connection(url, RequestServer::CacheLevel::CreateConnection); +} + static HashMap<LoadRequest, NonnullRefPtr<Resource>> s_resource_cache; RefPtr<Resource> ResourceLoader::load_resource(Resource::Type type, LoadRequest& request) diff --git a/Userland/Libraries/LibWeb/Loader/ResourceLoader.h b/Userland/Libraries/LibWeb/Loader/ResourceLoader.h index 0e2ffeec72..e311baddea 100644 --- a/Userland/Libraries/LibWeb/Loader/ResourceLoader.h +++ b/Userland/Libraries/LibWeb/Loader/ResourceLoader.h @@ -37,6 +37,9 @@ public: void load(const AK::URL&, Function<void(ReadonlyBytes, const HashMap<String, String, CaseInsensitiveStringTraits>& response_headers, Optional<u32> status_code)> success_callback, Function<void(const String&, Optional<u32> status_code)> error_callback = nullptr); void load_sync(LoadRequest&, Function<void(ReadonlyBytes, const HashMap<String, String, CaseInsensitiveStringTraits>& response_headers, Optional<u32> status_code)> success_callback, Function<void(const String&, Optional<u32> status_code)> error_callback = nullptr); + void prefetch_dns(AK::URL const&); + void preconnect(AK::URL const&); + Function<void()> on_load_counter_change; int pending_loads() const { return m_pending_loads; } |