mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 07:30:19 +00:00
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.
This commit is contained in:
parent
a6220501ab
commit
fa8b64d59a
Notes:
sideshowbarker
2024-07-17 23:00:03 +09:00
Author: https://github.com/ADKaster Commit: https://github.com/SerenityOS/serenity/commit/fa8b64d59a Pull-request: https://github.com/SerenityOS/serenity/pull/23745 Reviewed-by: https://github.com/alimpfard Reviewed-by: https://github.com/trflynn89
10 changed files with 63 additions and 2 deletions
|
@ -96,8 +96,6 @@ ErrorOr<NonnullRefPtr<WebView::WebContentClient>> launch_web_content_process(
|
|||
dbgln();
|
||||
}
|
||||
|
||||
WebView::ProcessManager::the().add_process(WebView::ProcessType::WebContent, child_pid);
|
||||
|
||||
return new_client;
|
||||
}
|
||||
|
||||
|
|
|
@ -122,6 +122,7 @@ shared_library("LibWebView") {
|
|||
"Database.cpp",
|
||||
"History.cpp",
|
||||
"InspectorClient.cpp",
|
||||
"ProcessHandle.cpp",
|
||||
"ProcessManager.cpp",
|
||||
"RequestServerAdapter.cpp",
|
||||
"SearchEngine.cpp",
|
||||
|
|
|
@ -6,6 +6,7 @@ set(SOURCES
|
|||
Database.cpp
|
||||
History.cpp
|
||||
InspectorClient.cpp
|
||||
ProcessHandle.cpp
|
||||
ProcessManager.cpp
|
||||
RequestServerAdapter.cpp
|
||||
SearchEngine.cpp
|
||||
|
|
|
@ -21,6 +21,7 @@ class WebContentClient;
|
|||
|
||||
struct Attribute;
|
||||
struct CookieStorageKey;
|
||||
struct ProcessHandle;
|
||||
struct SearchEngine;
|
||||
struct SocketPair;
|
||||
|
||||
|
|
23
Userland/Libraries/LibWebView/ProcessHandle.cpp
Normal file
23
Userland/Libraries/LibWebView/ProcessHandle.cpp
Normal file
|
@ -0,0 +1,23 @@
|
|||
/*
|
||||
* 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 };
|
||||
}
|
25
Userland/Libraries/LibWebView/ProcessHandle.h
Normal file
25
Userland/Libraries/LibWebView/ProcessHandle.h
Normal file
|
@ -0,0 +1,25 @@
|
|||
/*
|
||||
* Copyright (c) 2024, Andrew Kaster <akaster@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AK/Types.h>
|
||||
#include <LibIPC/Forward.h>
|
||||
|
||||
namespace WebView {
|
||||
|
||||
struct ProcessHandle {
|
||||
// FIXME: Use mach_port_t on macOS/Hurd and HANDLE on Windows.
|
||||
pid_t pid;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
template<>
|
||||
ErrorOr<void> IPC::encode(IPC::Encoder&, WebView::ProcessHandle const&);
|
||||
|
||||
template<>
|
||||
ErrorOr<WebView::ProcessHandle> IPC::decode(IPC::Decoder&);
|
|
@ -5,6 +5,7 @@
|
|||
*/
|
||||
|
||||
#include "WebContentClient.h"
|
||||
#include "ProcessManager.h"
|
||||
#include "ViewImplementation.h"
|
||||
#include <LibWeb/Cookie/ParsedCookie.h>
|
||||
|
||||
|
@ -33,6 +34,12 @@ void WebContentClient::unregister_view(u64 page_id)
|
|||
m_views.remove(page_id);
|
||||
}
|
||||
|
||||
void WebContentClient::notify_process_information(WebView::ProcessHandle const& handle)
|
||||
{
|
||||
dbgln_if(SPAM_DEBUG, "handle: WebContentClient::NotifyProcessInformation! pid={}", handle.pid);
|
||||
ProcessManager::the().add_process(ProcessType::WebContent, handle.pid);
|
||||
}
|
||||
|
||||
void WebContentClient::did_paint(u64 page_id, Gfx::IntRect const& rect, i32 bitmap_id)
|
||||
{
|
||||
if (auto view = view_for_page_id(page_id); view.has_value())
|
||||
|
|
|
@ -37,6 +37,7 @@ public:
|
|||
private:
|
||||
virtual void die() override;
|
||||
|
||||
virtual void notify_process_information(WebView::ProcessHandle const&) override;
|
||||
virtual void did_paint(u64 page_id, Gfx::IntRect const&, i32) override;
|
||||
virtual void did_finish_loading(u64 page_id, URL::URL const&) override;
|
||||
virtual void did_update_url(u64 page_id, URL::URL const& url, Web::HTML::HistoryHandlingBehavior history_behavior) override;
|
||||
|
|
|
@ -59,6 +59,7 @@ ConnectionFromClient::ConnectionFromClient(NonnullOwnPtr<Core::LocalSocket> sock
|
|||
, m_page_host(PageHost::create(*this))
|
||||
{
|
||||
m_input_event_queue_timer = Web::Platform::Timer::create_single_shot(0, [this] { process_next_input_event(); });
|
||||
async_notify_process_information({ ::getpid() });
|
||||
}
|
||||
|
||||
void ConnectionFromClient::die()
|
||||
|
|
|
@ -15,9 +15,12 @@
|
|||
#include <LibWeb/Page/Page.h>
|
||||
#include <LibWebView/Attribute.h>
|
||||
#include <LibWebView/SocketPair.h>
|
||||
#include <LibWebView/ProcessHandle.h>
|
||||
|
||||
endpoint WebContentClient
|
||||
{
|
||||
notify_process_information(WebView::ProcessHandle handle) =|
|
||||
|
||||
did_start_loading(u64 page_id, URL::URL url, bool is_redirect) =|
|
||||
did_finish_loading(u64 page_id, URL::URL url) =|
|
||||
did_update_url(u64 page_id, URL::URL url, Web::HTML::HistoryHandlingBehavior history_behavior) =|
|
||||
|
|
Loading…
Reference in a new issue