/* * Copyright (c) 2022, Andreas Kling * Copyright (c) 2024, Jamie Mansfield * * SPDX-License-Identifier: BSD-2-Clause */ #include #include #include #include #include namespace Web::HTML { JS_DEFINE_ALLOCATOR(WorkerNavigator); JS::NonnullGCPtr WorkerNavigator::create(WorkerGlobalScope& global_scope) { return global_scope.heap().allocate(global_scope.realm(), global_scope); } WorkerNavigator::WorkerNavigator(WorkerGlobalScope& global_scope) : PlatformObject(global_scope.realm()) { } WorkerNavigator::~WorkerNavigator() = default; void WorkerNavigator::initialize(JS::Realm& realm) { Base::initialize(realm); WEB_SET_PROTOTYPE_FOR_INTERFACE(WorkerNavigator); } void WorkerNavigator::visit_edges(Cell::Visitor& visitor) { Base::visit_edges(visitor); visitor.visit(m_media_capabilities); visitor.visit(m_service_worker_container); } JS::NonnullGCPtr WorkerNavigator::media_capabilities() { if (!m_media_capabilities) m_media_capabilities = heap().allocate(realm(), realm()); return *m_media_capabilities; } JS::NonnullGCPtr WorkerNavigator::service_worker() { if (!m_service_worker_container) m_service_worker_container = heap().allocate(realm(), realm()); return *m_service_worker_container; } }