Skip to content

Instantly share code, notes, and snippets.

@creativcoder
Last active July 28, 2016 13:27
Show Gist options
  • Save creativcoder/4c8093e3a9fa6edcd77ac6df58792ea5 to your computer and use it in GitHub Desktop.
Save creativcoder/4c8093e3a9fa6edcd77ac6df58792ea5 to your computer and use it in GitHub Desktop.
Provision a trusted worker to the serviceworkerglobalscope, on invoking run_serviceworker_scope from ServiceWorkerManager thread.

Approach:

  • The service worker manager will send a message to constellation with, its sender and a pipeline id, and a scope_url.

  • The constellation on receiving the message will find the pipeline and send a message to its containing script thread passing the SW manager sender.

  • The script_thread on receiving the message will query its TLS ServiceWorkerRegistration (by scope_url) and retrieve the Trusted<ServiceWorker> by calling get_trusted_worker() on ServiceWorkerRegistration object , and send the Trusted<ServiceWorker> to the SW manager using the sender which it gets from the constellation.

So is this approach going in right direction ?

@jdm
Copy link

jdm commented Jul 28, 2016

The idea is plausible, but there are two main problems:

  • the sender the constellation provides is an IpcSender, and Trusted<ServiceWorker> contains a bunch of members that cannot be serialized
  • there will not always be a ServiceWorker object - after registering a service worker, subsequent page loads may not interact with navigator.serviceWorker.controller at all, but the worker will still be active

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment