Skip to content

Commit c46bea4

Browse files
kalenikaliaksandrawesomekling
authored andcommitted
Everywhere: Hand pid of new process to client in launch_server_process()
Allows WebContentClient to get pid of WebContent process right after creation, so there is no window between forking and notify_process_information() IPC response, when client doesn't know the pid.
1 parent 3110411 commit c46bea4

File tree

5 files changed

+5
-11
lines changed

5 files changed

+5
-11
lines changed

Ladybird/HelperProcess.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ static ErrorOr<NonnullRefPtr<ClientType>> launch_server_process(
4848
if (!result.is_error()) {
4949
auto process = result.release_value();
5050

51+
if constexpr (requires { process.client->set_pid(pid_t {}); })
52+
process.client->set_pid(process.process.pid());
53+
5154
if (register_with_process_manager == RegisterWithProcessManager::Yes)
5255
WebView::ProcessManager::the().add_process(WebView::process_type_from_name(server_name), process.process.pid());
5356

Userland/Libraries/LibWebView/WebContentClient.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,6 @@ void WebContentClient::unregister_view(u64 page_id)
3434
m_views.remove(page_id);
3535
}
3636

37-
void WebContentClient::notify_process_information(WebView::ProcessHandle const& handle)
38-
{
39-
dbgln_if(SPAM_DEBUG, "handle: WebContentClient::NotifyProcessInformation! pid={}", handle.pid);
40-
ProcessManager::the().add_process(ProcessType::WebContent, handle.pid);
41-
m_process_handle = handle;
42-
}
43-
4437
void WebContentClient::did_paint(u64 page_id, Gfx::IntRect const& rect, i32 bitmap_id)
4538
{
4639
if (auto view = view_for_page_id(page_id); view.has_value())

Userland/Libraries/LibWebView/WebContentClient.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,11 @@ class WebContentClient final
3333

3434
Function<void()> on_web_content_process_crash;
3535

36+
void set_pid(pid_t pid) { m_process_handle.pid = pid; }
37+
3638
private:
3739
virtual void die() override;
3840

39-
virtual void notify_process_information(WebView::ProcessHandle const&) override;
4041
virtual void did_paint(u64 page_id, Gfx::IntRect const&, i32) override;
4142
virtual void did_finish_loading(u64 page_id, URL::URL const&) override;
4243
virtual void did_request_navigate_back(u64 page_id) override;

Userland/Services/WebContent/ConnectionFromClient.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ ConnectionFromClient::ConnectionFromClient(NonnullOwnPtr<Core::LocalSocket> sock
5555
, m_page_host(PageHost::create(*this))
5656
{
5757
m_input_event_queue_timer = Web::Platform::Timer::create_single_shot(0, [this] { process_next_input_event(); });
58-
async_notify_process_information({ ::getpid() });
5958
}
6059

6160
ConnectionFromClient::~ConnectionFromClient() = default;

Userland/Services/WebContent/WebContentClient.ipc

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717

1818
endpoint WebContentClient
1919
{
20-
notify_process_information(WebView::ProcessHandle handle) =|
21-
2220
did_start_loading(u64 page_id, URL::URL url, bool is_redirect) =|
2321
did_finish_loading(u64 page_id, URL::URL url) =|
2422
did_request_navigate_back(u64 page_id) =|

0 commit comments

Comments
 (0)