ProcessManager.h 979 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 <LibThreading/Mutex.h>
  11. #include <LibWebView/Forward.h>
  12. #include <LibWebView/Platform/ProcessStatistics.h>
  13. namespace WebView {
  14. ProcessType process_type_from_name(StringView);
  15. StringView process_name_from_type(ProcessType type);
  16. class ProcessManager {
  17. public:
  18. static ProcessManager& the();
  19. static void initialize();
  20. void add_process(WebView::ProcessType, pid_t);
  21. void remove_process(pid_t);
  22. #if defined(AK_OS_MACH)
  23. void add_process(pid_t, Core::MachPort&&);
  24. #endif
  25. void update_all_processes();
  26. Vector<ProcessInfo> const& processes() const { return m_statistics.processes; }
  27. String generate_html();
  28. private:
  29. ProcessManager();
  30. ~ProcessManager();
  31. ProcessStatistics m_statistics;
  32. Threading::Mutex m_lock;
  33. };
  34. }