WebContent: Turn it into a MultiInstance service :^)

Port the WebContent service to the new MultiInstance mechanism that
Sergey added. This means that every new WebContentView gets its very
own segregated WebContent process.
This commit is contained in:
Andreas Kling 2020-06-21 21:22:10 +02:00
parent ed351c7493
commit 59537cf257
Notes: sideshowbarker 2024-07-19 05:28:02 +09:00
5 changed files with 10 additions and 17 deletions

View file

@ -13,6 +13,8 @@ SocketPermissions=660
Lazy=1
User=webcontent
BootModes=graphical
MultiInstance=1
AcceptSocketConnections=1
[LookupServer]
Socket=/tmp/portal/lookup

View file

@ -37,8 +37,9 @@ WebContentClient::WebContentClient(WebContentView& view)
void WebContentClient::handshake()
{
auto response = send_sync<Messages::WebContentServer::Greet>();
auto response = send_sync<Messages::WebContentServer::Greet>(getpid());
set_my_client_id(response->client_id());
set_server_pid(response->server_pid());
}
void WebContentClient::handle(const Messages::WebContentClient::DidPaint& message)

View file

@ -62,9 +62,10 @@ const Web::Page& ClientConnection::page() const
return m_page_host->page();
}
OwnPtr<Messages::WebContentServer::GreetResponse> ClientConnection::handle(const Messages::WebContentServer::Greet&)
OwnPtr<Messages::WebContentServer::GreetResponse> ClientConnection::handle(const Messages::WebContentServer::Greet& message)
{
return make<Messages::WebContentServer::GreetResponse>(client_id());
set_client_pid(message.client_pid());
return make<Messages::WebContentServer::GreetResponse>(client_id(), getpid());
}
void ClientConnection::handle(const Messages::WebContentServer::UpdateSystemTheme& message)

View file

@ -1,6 +1,6 @@
endpoint WebContentServer = 89
{
Greet() => (i32 client_id)
Greet(i32 client_pid) => (i32 client_id, i32 server_pid)
UpdateSystemTheme(i32 shbuf_id) =|

View file

@ -49,18 +49,7 @@ int main(int, char**)
return 1;
}
auto server = Core::LocalServer::construct();
bool ok = server->take_over_from_system_server();
ASSERT(ok);
server->on_ready_to_accept = [&] {
auto client_socket = server->accept();
if (!client_socket) {
dbg() << "WebContent: accept failed.";
return;
}
static int s_next_client_id = 0;
int client_id = ++s_next_client_id;
IPC::new_client_connection<WebContent::ClientConnection>(*client_socket, client_id);
};
auto socket = Core::LocalSocket::take_over_accepted_socket_from_system_server();
IPC::new_client_connection<WebContent::ClientConnection>(*socket, 1);
return event_loop.exec();
}