[ServiceWorker] Workers & SharedWorkers within ServiceWorkers (#678)

ServiceWorkers should be able to create dedicated workers to do processing work that would otherwise hold up the thread. With canvas-in-workers proposals starting to mature, this could include image pixel manipulation, but may also include complex diffing etc. 

Multi-tab apps sometimes use a SharedWorker to ensure only one connection is held to the server, and that worker distributes the data to the appropriate clients. A ServiceWorker should be able to connect to an existing ServiceWorker instance or create a new one, to make use of this single connection. [Mozilla have a use-case](https://github.com/slightlyoff/BackgroundSync/issues/70#issuecomment-92445609) for their email app.

Workers and SharedWorkers are [currently tied to documents](https://html.spec.whatwg.org/multipage/workers.html#dom-sharedworker), changing this to also allow ServiceWorkers shouldn't be too much of a problem spec-wise.

Since creating a Worker/SharedWorker forms a new client & will select its own registration, workers created within a SW may trigger `onfetch` within the same ServiceWorker.

---
Reply to this email directly or view it on GitHub:
https://github.com/slightlyoff/ServiceWorker/issues/678

Received on Tuesday, 14 April 2015 10:19:25 UTC