mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-07 08:39:22 +00:00
LibWeb: Move ServiceWorker classes to ServiceWorker namespace
These are defined by the ServiceWorker spec, not the HTML one.
This commit is contained in:
parent
2918405360
commit
4417f63ca0
Notes:
github-actions[bot]
2024-11-30 10:20:43 +00:00
Author: https://github.com/shannonbooth
Commit: 4417f63ca0
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2653
19 changed files with 44 additions and 37 deletions
57
Libraries/LibWeb/ServiceWorker/ServiceWorkerContainer.h
Normal file
57
Libraries/LibWeb/ServiceWorker/ServiceWorkerContainer.h
Normal file
|
@ -0,0 +1,57 @@
|
|||
/*
|
||||
* Copyright (c) 2024, Tim Ledbetter <tim.ledbetter@ladybird.org>
|
||||
* Copyright (c) 2024, Jamie Mansfield <jmansfield@cadixdev.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <LibWeb/Bindings/ServiceWorkerRegistrationPrototype.h>
|
||||
#include <LibWeb/Bindings/WorkerPrototype.h>
|
||||
#include <LibWeb/DOM/EventTarget.h>
|
||||
#include <LibWeb/WebIDL/ExceptionOr.h>
|
||||
#include <LibWeb/WebIDL/Promise.h>
|
||||
|
||||
#define ENUMERATE_SERVICE_WORKER_CONTAINER_EVENT_HANDLERS(E) \
|
||||
E(oncontrollerchange, HTML::EventNames::controllerchange) \
|
||||
E(onmessage, HTML::EventNames::message) \
|
||||
E(onmessageerror, HTML::EventNames::messageerror)
|
||||
|
||||
namespace Web::ServiceWorker {
|
||||
|
||||
struct RegistrationOptions {
|
||||
Optional<String> scope;
|
||||
Bindings::WorkerType type = Bindings::WorkerType::Classic;
|
||||
Bindings::ServiceWorkerUpdateViaCache update_via_cache = Bindings::ServiceWorkerUpdateViaCache::Imports;
|
||||
};
|
||||
|
||||
class ServiceWorkerContainer : public DOM::EventTarget {
|
||||
WEB_PLATFORM_OBJECT(ServiceWorkerContainer, DOM::EventTarget);
|
||||
GC_DECLARE_ALLOCATOR(ServiceWorkerContainer);
|
||||
|
||||
public:
|
||||
[[nodiscard]] static GC::Ref<ServiceWorkerContainer> create(JS::Realm& realm);
|
||||
virtual ~ServiceWorkerContainer() override;
|
||||
|
||||
GC::Ref<WebIDL::Promise> register_(String script_url, RegistrationOptions const& options);
|
||||
|
||||
#undef __ENUMERATE
|
||||
#define __ENUMERATE(attribute_name, event_name) \
|
||||
void set_##attribute_name(WebIDL::CallbackType*); \
|
||||
WebIDL::CallbackType* attribute_name();
|
||||
ENUMERATE_SERVICE_WORKER_CONTAINER_EVENT_HANDLERS(__ENUMERATE)
|
||||
#undef __ENUMERATE
|
||||
|
||||
private:
|
||||
explicit ServiceWorkerContainer(JS::Realm&);
|
||||
|
||||
virtual void initialize(JS::Realm&) override;
|
||||
virtual void visit_edges(Cell::Visitor&) override;
|
||||
|
||||
void start_register(Optional<URL::URL> scope_url, URL::URL script_url, GC::Ref<WebIDL::Promise>, HTML::EnvironmentSettingsObject&, URL::URL referrer, Bindings::WorkerType, Bindings::ServiceWorkerUpdateViaCache);
|
||||
|
||||
GC::Ref<HTML::EnvironmentSettingsObject> m_service_worker_client;
|
||||
};
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue