ladybird/Userland/Libraries/LibWebView/ProcessManager.h
Timothy Flynn 5dd3b91f0e LibCore+LibWebView: Move process statistics to LibCore
This will be needed to collect statistics from processes that do not
have anything to do with LibWebView. The ProcessInfo structure must be
virtual to allow callers to add application-specific information.
2024-04-22 14:46:10 -06:00

47 lines
981 B
C++

/*
* Copyright (c) 2024, Andrew Kaster <akaster@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/Types.h>
#include <AK/Vector.h>
#include <LibCore/EventReceiver.h>
#include <LibCore/Platform/ProcessStatistics.h>
#include <LibThreading/Mutex.h>
#include <LibWebView/Forward.h>
#include <LibWebView/ProcessInfo.h>
namespace WebView {
ProcessType process_type_from_name(StringView);
StringView process_name_from_type(ProcessType type);
class ProcessManager {
public:
static ProcessManager& the();
static void initialize();
void add_process(WebView::ProcessType, pid_t);
void remove_process(pid_t);
ProcessInfo* find_process(pid_t);
#if defined(AK_OS_MACH)
void add_process(pid_t, Core::MachPort&&);
#endif
void update_all_processes();
String generate_html();
private:
ProcessManager();
~ProcessManager();
Core::Platform::ProcessStatistics m_statistics;
Threading::Mutex m_lock;
};
}