ladybird/Userland/Libraries/LibWebView/Application.h
Andrew Kaster 4cc3d598f9 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.
2024-07-01 18:10:56 +02:00

52 lines
1.1 KiB
C++

/*
* Copyright (c) 2024, Andrew Kaster <akaster@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <LibCore/EventLoop.h>
#include <LibWebView/Process.h>
#include <LibWebView/ProcessManager.h>
namespace WebView {
class Application {
AK_MAKE_NONCOPYABLE(Application);
public:
Application(int argc, char** argv);
virtual ~Application();
int exec();
static Application& the() { return *s_the; }
Core::EventLoop& event_loop() { return m_event_loop; }
void add_child_process(Process&&);
// FIXME: Should these methods be part of Application, instead of deferring to ProcessManager?
#if defined(AK_OS_MACH)
void set_process_mach_port(pid_t, Core::MachPort&&);
#endif
Optional<Process&> find_process(pid_t);
// FIXME: Should we just expose the ProcessManager via a getter?
void update_process_statistics();
String generate_process_statistics_html();
protected:
virtual void process_did_exit(Process&&);
private:
static Application* s_the;
Core::EventLoop m_event_loop;
ProcessManager m_process_manager;
bool m_in_shutdown { false };
};
}