WorkerAgent.h 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /*
  2. * Copyright (c) 2023, Andrew Kaster <akaster@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <LibCore/Socket.h>
  8. #include <LibWeb/Forward.h>
  9. #include <LibWeb/HTML/MessageEvent.h>
  10. #include <LibWeb/HTML/MessagePort.h>
  11. #include <LibWeb/HTML/Scripting/WorkerEnvironmentSettingsObject.h>
  12. #include <LibWeb/HTML/Window.h>
  13. #include <LibWeb/Worker/WebWorkerClient.h>
  14. namespace Web::HTML {
  15. struct WorkerOptions {
  16. String type { "classic"_string };
  17. String credentials { "same-origin"_string };
  18. String name { String {} };
  19. };
  20. struct WorkerAgent : JS::Cell {
  21. JS_CELL(Agent, JS::Cell);
  22. JS_DECLARE_ALLOCATOR(WorkerAgent);
  23. WorkerAgent(AK::URL url, WorkerOptions const& options, JS::GCPtr<MessagePort> outside_port);
  24. RefPtr<Web::HTML::WebWorkerClient> m_worker_ipc;
  25. private:
  26. virtual void initialize(JS::Realm&) override;
  27. virtual void visit_edges(Cell::Visitor&) override;
  28. WorkerOptions m_worker_options;
  29. AK::URL m_url;
  30. JS::GCPtr<MessagePort> m_message_port;
  31. JS::GCPtr<MessagePort> m_outside_port;
  32. };
  33. }