Application.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /*
  2. * Copyright (c) 2024, Andrew Kaster <akaster@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <LibCore/EventLoop.h>
  8. #include <LibWebView/Process.h>
  9. #include <LibWebView/ProcessManager.h>
  10. #ifdef __swift__
  11. # include <swift/bridging>
  12. #else
  13. # define SWIFT_IMMORTAL_REFERENCE
  14. #endif
  15. namespace WebView {
  16. class Application {
  17. AK_MAKE_NONCOPYABLE(Application);
  18. public:
  19. Application(int argc, char** argv);
  20. virtual ~Application();
  21. int exec();
  22. static Application& the() { return *s_the; }
  23. Core::EventLoop& event_loop() { return m_event_loop; }
  24. void add_child_process(Process&&);
  25. // FIXME: Should these methods be part of Application, instead of deferring to ProcessManager?
  26. #if defined(AK_OS_MACH)
  27. void set_process_mach_port(pid_t, Core::MachPort&&);
  28. #endif
  29. Optional<Process&> find_process(pid_t);
  30. // FIXME: Should we just expose the ProcessManager via a getter?
  31. void update_process_statistics();
  32. String generate_process_statistics_html();
  33. protected:
  34. virtual void process_did_exit(Process&&);
  35. private:
  36. static Application* s_the;
  37. Core::EventLoop m_event_loop;
  38. ProcessManager m_process_manager;
  39. bool m_in_shutdown { false };
  40. } SWIFT_IMMORTAL_REFERENCE;
  41. }