mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-31 21:29:06 +00:00
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:
parent
5810c8073e
commit
aca4385daf
Notes:
github-actions[bot]
2025-03-11 11:11:42 +00:00
Author: https://github.com/trflynn89
Commit: aca4385daf
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3882
Reviewed-by: https://github.com/gmta ✅
8 changed files with 98 additions and 9 deletions
|
@ -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();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue