2024-11-30 18:35:45 +13:00
|
|
|
/*
|
2025-04-25 17:41:40 +12:00
|
|
|
* Copyright (c) 2024-2025, Shannon Booth <shannon@serenityos.org>
|
2024-11-30 18:35:45 +13:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <LibWeb/HTML/WorkerGlobalScope.h>
|
|
|
|
|
|
|
|
namespace Web::ServiceWorker {
|
|
|
|
|
|
|
|
// https://w3c.github.io/ServiceWorker/#serviceworkerglobalscope
|
|
|
|
class ServiceWorkerGlobalScope : public HTML::WorkerGlobalScope {
|
|
|
|
WEB_PLATFORM_OBJECT(ServiceWorkerGlobalScope, HTML::WorkerGlobalScope);
|
|
|
|
GC_DECLARE_ALLOCATOR(ServiceWorkerGlobalScope);
|
|
|
|
|
|
|
|
public:
|
|
|
|
virtual ~ServiceWorkerGlobalScope() override;
|
|
|
|
|
2025-04-25 17:41:40 +12:00
|
|
|
void set_oninstall(GC::Ptr<WebIDL::CallbackType>);
|
|
|
|
GC::Ptr<WebIDL::CallbackType> oninstall();
|
|
|
|
|
|
|
|
void set_onactivate(GC::Ptr<WebIDL::CallbackType>);
|
|
|
|
GC::Ptr<WebIDL::CallbackType> onactivate();
|
|
|
|
|
|
|
|
void set_onfetch(GC::Ptr<WebIDL::CallbackType>);
|
|
|
|
GC::Ptr<WebIDL::CallbackType> onfetch();
|
|
|
|
|
|
|
|
void set_onmessage(GC::Ptr<WebIDL::CallbackType>);
|
|
|
|
GC::Ptr<WebIDL::CallbackType> onmessage();
|
|
|
|
|
|
|
|
void set_onmessageerror(GC::Ptr<WebIDL::CallbackType>);
|
|
|
|
GC::Ptr<WebIDL::CallbackType> onmessageerror();
|
|
|
|
|
2025-08-04 22:17:20 +03:00
|
|
|
[[nodiscard]] GC::Ref<CookieStore::CookieStore> cookie_store();
|
|
|
|
|
2024-11-30 18:35:45 +13:00
|
|
|
protected:
|
|
|
|
explicit ServiceWorkerGlobalScope(JS::Realm&, GC::Ref<Web::Page>);
|
2025-08-04 22:17:20 +03:00
|
|
|
|
|
|
|
private:
|
|
|
|
virtual void visit_edges(Cell::Visitor&) override;
|
|
|
|
|
|
|
|
GC::Ptr<CookieStore::CookieStore> m_cookie_store;
|
2024-11-30 18:35:45 +13:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|