ProcessManager.h 981 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /*
  2. * Copyright (c) 2024, Andrew Kaster <akaster@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <AK/Types.h>
  8. #include <AK/Vector.h>
  9. #include <LibCore/EventReceiver.h>
  10. #include <LibCore/Platform/ProcessStatistics.h>
  11. #include <LibThreading/Mutex.h>
  12. #include <LibWebView/Forward.h>
  13. #include <LibWebView/ProcessInfo.h>
  14. namespace WebView {
  15. ProcessType process_type_from_name(StringView);
  16. StringView process_name_from_type(ProcessType type);
  17. class ProcessManager {
  18. public:
  19. static ProcessManager& the();
  20. static void initialize();
  21. void add_process(WebView::ProcessType, pid_t);
  22. void remove_process(pid_t);
  23. ProcessInfo* find_process(pid_t);
  24. #if defined(AK_OS_MACH)
  25. void add_process(pid_t, Core::MachPort&&);
  26. #endif
  27. void update_all_processes();
  28. String generate_html();
  29. private:
  30. ProcessManager();
  31. ~ProcessManager();
  32. Core::Platform::ProcessStatistics m_statistics;
  33. Threading::Mutex m_lock;
  34. };
  35. }