[ServiceWorker] Event queuing model for SW (#649)

@annevk has long been pointing out about the need for an external event queue to support SW lifecycle: https://github.com/slightlyoff/ServiceWorker/issues/290#issuecomment-44257645.

As the way I've spec'ed it is a bit different though, I'd like to have your feedback.

Here's the behavior:

1. Every lifecycle event or functional event triggers **Run Service Worker** algorithm
1. _Run Service Worker_ 
  1. If the service worker is already running, do nothing and abort the steps.
  1. Create separate execution context, environment settings object, global object, etc.
  1. Run the event loop specified by the environment settings object.
1. Queue a task to dispatch the event at the service worker

- So, it's not missing any event during a boot-up.
- The events are being queued up and handled while SW's running.
- All the events are extendable event (yeah FetchEvent will also be), so we can signal UAs to keep it up for those given promises' settlements. And have all the events queued up while it's alive.
- But we don't re-queue those events discarded when UA terminates a service worker.

WDYT?

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

Received on Wednesday, 11 March 2015 09:17:12 UTC