Extension SW: Run all PendingTasks once a lazy context's worker is ready.
For running PendingTasks for a particular ContextId through SWTQ::AddPendingTask(), call StartWorker* exactly once instead of calling it each time for each AddPendingTask call. This has two advantages: - We don't call StartWorker* more than once when we don't need to. - Extension messaging subtly depends on running these tasks once. This is because how LazyBackgroundTaskQueue behaves in terms of multiple pending tasks and we need some sort of parity in SWTQ for future worker messaging implementation. Detailed changes: - ServiceWorkerTaskQueue: Remove the queue for registration (old |pending_tasks_|) and worker start (|waiting_did_start_worker_tasks_|) and merge them to a single queue (|pending_tasks_). Run these tasks once registration, service worker start (DidStartWorkerForScope) and service worker loadstop (DidStartServiceWorkerContext) completes. - IPC: Add thread_id and SW scope to DidStartServiceWorkerContext IPC (loadstop), as PendingTasks that were pending after DidStartWorkerForScope but before the SW context has seen loadstop can use these thread_id and scope to build LazyContextTaskQueue::ContextInfo to run those tasks. Previously we used to remember these two pieces of information in WaitingDidStartWorkerTask. This also simplifies the queue in SWTQ. - IPC: Add thread_id and SW scope to DidStopServiceWorkerContext IPC to clean up the task containers on worker shutdown. This will also be necessary for multiple worker support within extension in future. Bug: 925927 Test: Service worker within extension internal change, no visible effect. Change-Id: I06581f821550154ebca3ee6d9aa803953abf7d86 Reviewed-on: https://chromium-review.googlesource.com/c/1481580Reviewed-by:Dominick Ng <dominickn@chromium.org> Reviewed-by:
Devlin <rdevlin.cronin@chromium.org> Commit-Queue: Istiaque Ahmed <lazyboy@chromium.org> Cr-Commit-Position: refs/heads/master@{#636239}
Showing
This diff is collapsed.
Please register or sign in to comment