LibWebView: Create a spare WebContent process

Since cross-site navigation is a pretty frequent task, creating a spare
process is commonplace in other browsers to reduce the overhead of
directing the target site to a new process.

We store this process on the WebView application. If it is unavailable,
we queue a task to create it later.
This commit is contained in:
Timothy Flynn 2025-03-09 18:01:25 -04:00 committed by Jelle Raaijmakers
commit aca4385daf
Notes: github-actions[bot] 2025-03-11 11:11:42 +00:00
8 changed files with 98 additions and 9 deletions

View file

@ -31,6 +31,12 @@ WebContentClient::WebContentClient(IPC::Transport transport, ViewImplementation&
m_views.set(0, &view);
}
WebContentClient::WebContentClient(IPC::Transport transport)
: IPC::ConnectionToServer<WebContentClientEndpoint, WebContentServerEndpoint>(*this, move(transport))
{
s_clients.set(this);
}
WebContentClient::~WebContentClient()
{
s_clients.remove(this);
@ -41,6 +47,12 @@ void WebContentClient::die()
// Intentionally empty. Restart is handled at another level.
}
void WebContentClient::assign_view(Badge<Application>, ViewImplementation& view)
{
VERIFY(m_views.is_empty());
m_views.set(0, &view);
}
void WebContentClient::register_view(u64 page_id, ViewImplementation& view)
{
VERIFY(page_id > 0);
@ -768,6 +780,10 @@ void WebContentClient::did_get_style_sheet_source(u64 page_id, Web::CSS::StyleSh
Optional<ViewImplementation&> WebContentClient::view_for_page_id(u64 page_id, SourceLocation location)
{
// Don't bother logging anything for the spare WebContent process. It will only receive a load notification for about:blank.
if (m_views.is_empty())
return {};
if (auto view = m_views.get(page_id); view.has_value())
return *view.value();