ladybird/Userland/Libraries/LibWebView/ProcessHandle.cpp
Andrew Kaster fa8b64d59a LibWebView+WebContent: Notify UI process about WebContent PID explicitly
On Serenity, it's not trivial to extract the peer pid from a socket that
is created by SystemServer and then passed to a forked service process.
This patch adds an API to let the WebContent process notify the UI
directly, which makes the WebContent process show up in the Serenity
port's TaskManagerWidget. It seems that we will need to do something of
this sort in order to properly gather metrics on macOS as well, due to
the way that self mach ports work.
2024-04-02 09:52:34 -06:00

23 lines
534 B
C++

/*
* Copyright (c) 2024, Andrew Kaster <akaster@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibIPC/Decoder.h>
#include <LibIPC/Encoder.h>
#include <LibWebView/ProcessHandle.h>
template<>
ErrorOr<void> IPC::encode(IPC::Encoder& encoder, WebView::ProcessHandle const& handle)
{
TRY(encoder.encode(handle.pid));
return {};
}
template<>
ErrorOr<WebView::ProcessHandle> IPC::decode(IPC::Decoder& decoder)
{
auto pid = TRY(decoder.decode<pid_t>());
return WebView::ProcessHandle { pid };
}