mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-17 07:50:04 +00:00
LibWebView+LibCore: Manage process lifecycle using a SIGCHLD handler
This large commit also refactors LibWebView's process handling to use a top-level Application class that uses a new WebView::Process class to encapsulate the IPC-centric nature of each helper process.
This commit is contained in:
parent
3dea602d92
commit
4cc3d598f9
Notes:
sideshowbarker
2024-07-17 06:51:10 +09:00
Author: https://github.com/ADKaster
Commit: 4cc3d598f9
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/319
24 changed files with 382 additions and 196 deletions
46
Userland/Libraries/LibWebView/Process.h
Normal file
46
Userland/Libraries/LibWebView/Process.h
Normal file
|
@ -0,0 +1,46 @@
|
|||
/*
|
||||
* Copyright (c) 2024, Andrew Kaster <akaster@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AK/String.h>
|
||||
#include <AK/WeakPtr.h>
|
||||
#include <LibCore/Process.h>
|
||||
#include <LibIPC/Connection.h>
|
||||
#include <LibWebView/ProcessType.h>
|
||||
|
||||
namespace WebView {
|
||||
|
||||
class Process {
|
||||
AK_MAKE_NONCOPYABLE(Process);
|
||||
AK_MAKE_DEFAULT_MOVABLE(Process);
|
||||
|
||||
public:
|
||||
Process(ProcessType type, RefPtr<IPC::ConnectionBase> connection, Core::Process process);
|
||||
~Process();
|
||||
|
||||
ProcessType type() const { return m_type; }
|
||||
Optional<String> const& title() const { return m_title; }
|
||||
void set_title(Optional<String> title) { m_title = move(title); }
|
||||
|
||||
template<typename ConnectionFromClient>
|
||||
Optional<ConnectionFromClient&> client()
|
||||
{
|
||||
if (auto strong_connection = m_connection.strong_ref())
|
||||
return verify_cast<ConnectionFromClient>(*strong_connection);
|
||||
return {};
|
||||
}
|
||||
|
||||
pid_t pid() const { return m_process.pid(); }
|
||||
|
||||
private:
|
||||
Core::Process m_process;
|
||||
ProcessType m_type;
|
||||
Optional<String> m_title;
|
||||
WeakPtr<IPC::ConnectionBase> m_connection;
|
||||
};
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue