ServiceWorkerBackend Class
The storage of the service worker registrations (https://w3c.github.io/ServiceWorker/#dfn-scope-to-registration-map) of the browsing contexts, e.g. a SQLite database or InMemoryServiceWorkerBackend (see BrowsingContextOptions.ServiceWorkers). The backend stores the registrations of each origin, with their installed (waiting) and activated (active) service workers and the scripts of these workers: the library implements the registrations and runs the service workers, and only reads and writes the registrations.
public abstract class ServiceWorkerBackendRemarks
The methods are called on the threads of the event loops of the windows and the workers that use the registrations: an implementation must be thread-safe. A registration is saved as a whole (ServiceWorkerBackend.SaveRegistration) each time it changes: its waiting or active worker is installed or activated, its last update check time or its navigation preload state changes. A browsing context group calls ServiceWorkerBackend.SaveRegistration and ServiceWorkerBackend.DeleteRegistration one at a time, in the order of the changes of its registrations: the last call for a registration gives its current state.
The browsing contexts that share a backend share the registrations, but each browsing context group runs its own instances of the service workers (as several browser sessions of the same profile): a registration changed by a group is read by the other groups when they look it up for the first time.
Constructors
| Name | Description |
|---|---|
| ServiceWorkerBackend() |
ServiceWorkerBackend()
protected ServiceWorkerBackend()No documentation is available.
Methods
| Name | Description |
|---|---|
| DeleteRegistration(string, string) | Deletes the registration of a scope, and returns true, or returns false when there is no such registration. |
| GetRegistrations(string) | Returns the registrations of an origin. |
| SaveRegistration(string, StoredServiceWorkerRegistration) | Saves a registration: replaces the registration with the same StoredServiceWorkerRegistration.ScopeUrl, or adds it. |
DeleteRegistration(string, string)
Deletes the registration of a scope, and returns true, or returns false when there is no such registration.
GetRegistrations(string)
Returns the registrations of an origin.
public abstract IReadOnlyList<StoredServiceWorkerRegistration> GetRegistrations(string origin)SaveRegistration(string, StoredServiceWorkerRegistration)
Saves a registration: replaces the registration with the same StoredServiceWorkerRegistration.ScopeUrl, or adds it.
public abstract void SaveRegistration(string origin, StoredServiceWorkerRegistration registration)Parameters
originstring- The serialization of the origin.
registrationStoredServiceWorkerRegistration- The registration.