2024-03-26 00:29:14 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2024, Andrew Kaster <akaster@serenityos.org>
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
*/
|
|
|
|
|
2024-04-04 20:10:08 +00:00
|
|
|
#pragma once
|
|
|
|
|
2024-03-26 00:29:14 +00:00
|
|
|
#include <AK/Types.h>
|
|
|
|
#include <AK/Vector.h>
|
|
|
|
#include <LibCore/EventReceiver.h>
|
2024-04-21 03:35:17 +00:00
|
|
|
#include <LibCore/Platform/ProcessStatistics.h>
|
2024-04-04 20:10:08 +00:00
|
|
|
#include <LibThreading/Mutex.h>
|
2024-03-26 00:29:14 +00:00
|
|
|
#include <LibWebView/Forward.h>
|
2024-06-30 04:24:01 +00:00
|
|
|
#include <LibWebView/Process.h>
|
|
|
|
#include <LibWebView/ProcessType.h>
|
2024-03-26 00:29:14 +00:00
|
|
|
|
|
|
|
namespace WebView {
|
|
|
|
|
|
|
|
ProcessType process_type_from_name(StringView);
|
|
|
|
StringView process_name_from_type(ProcessType type);
|
|
|
|
|
|
|
|
class ProcessManager {
|
2024-06-30 04:24:01 +00:00
|
|
|
AK_MAKE_NONCOPYABLE(ProcessManager);
|
|
|
|
|
2024-03-26 00:29:14 +00:00
|
|
|
public:
|
2024-06-30 04:24:01 +00:00
|
|
|
ProcessManager();
|
|
|
|
~ProcessManager();
|
2024-03-26 00:29:14 +00:00
|
|
|
|
2024-06-30 04:24:01 +00:00
|
|
|
void add_process(Process&&);
|
|
|
|
Optional<Process> remove_process(pid_t);
|
|
|
|
Optional<Process&> find_process(pid_t);
|
2024-03-26 00:29:14 +00:00
|
|
|
|
2024-04-04 20:10:08 +00:00
|
|
|
#if defined(AK_OS_MACH)
|
2024-06-30 04:24:01 +00:00
|
|
|
void set_process_mach_port(pid_t, Core::MachPort&&);
|
2024-04-04 20:10:08 +00:00
|
|
|
#endif
|
|
|
|
|
2024-06-30 04:24:01 +00:00
|
|
|
void update_all_process_statistics();
|
2024-03-26 17:38:12 +00:00
|
|
|
String generate_html();
|
|
|
|
|
2024-06-30 04:24:01 +00:00
|
|
|
Function<void(Process&&)> on_process_exited;
|
2024-03-26 00:29:14 +00:00
|
|
|
|
2024-06-30 04:24:01 +00:00
|
|
|
private:
|
2024-04-21 03:35:17 +00:00
|
|
|
Core::Platform::ProcessStatistics m_statistics;
|
2024-06-30 04:24:01 +00:00
|
|
|
HashMap<pid_t, Process> m_processes;
|
|
|
|
int m_signal_handle { -1 };
|
2024-04-04 20:10:08 +00:00
|
|
|
Threading::Mutex m_lock;
|
2024-03-26 00:29:14 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|