|
[extension SW] Support lazy events from extension service workers.
This CL adds support to register and dispatch lazy events from/to
extension SW
(a) To register, we use SW's (unique) scope url to identify a SW
within an extension. Pass the information about scope url through
ServiceWorkerContextClient. Initially EventListener::worker_thread_id_
was used to identify whether an event is for SW context or not.
However, that is not enough for lazy service worker events, because
we need to persist lazy events in the browser process and
worker_thread_id_ is temporary for a running SW.
Change SW EventListener by adding EventListener::is_for_service_worker()
to support this.
(b) To dispatch, we need to start a worker before dispatching the
event. The content/ API:
ServiceWorkerContext::GetWorkerInfoAfterStartWorker()
was added to do that. Add ServiceWorkerTaskQueue (similar to
LazyBackgroundTaskQueue for lazy background pages) to dispatch
the event (a task) in extensions/ layer.
IPC changes:
In order to identify a (possibly stopped) SW, IPCs for lazy
service worker events were changed to accept service worker scope
urls. In order to not convolute existing lazy background page IPCs
(ExtensionHostMsg_Add/RemoveLazyListener), new ones have been
introduced: ExtensionHostMsg_Add/RemoveLazyServiceWorkerListener.
Other notable changes:
- LazyContextTaskQueue is introduced to express a lazy runnable
context. Make the new ServiceWorkerTaskQueue and existing
LazyBackgroundTaskQueue derived from that. One can post [1]
PendingTasks to these contexts. Unfortunately becuase of many
existing usages of LazyBackgroundTaskQueue::AddPendingTask,
[1] was named AddPendingTaskToDispatchEvent to avoid collision.
- LazyContextTaskQueue provides a contexual information expressed
as LazyContextTaskQueue::ContextInfo. This was introduced to
avoid ExtensionHost from LazyContextTaskQueue (See
LazyBackgroundTaskQueue::AddPendingTask)
BUG= 721147
Test=After an extension service worker stops, it should still be
possible to dispatch extension events to it. That will wake up
the service worker.
Review-Url: https://codereview.chromium.org/2943583002
Cr-Commit-Position: refs/heads/master@{#483820}
Committed: https://chromium.googlesource.com/chromium/src/+/63b994a1d1026a4b992c74e10e1e7c826bb5f9ae
Total comments: 22
Total comments: 14
Total comments: 10
Total comments: 6
|
Unified diffs |
Side-by-side diffs |
Delta from patch set |
Stats (+1008 lines, -160 lines) |
Patch |
|
M |
chrome/browser/extensions/service_worker_apitest.cc
|
View
|
1
2
3
4
5
6
7
|
3 chunks |
+36 lines, -0 lines |
0 comments
|
Download
|
|
M |
chrome/renderer/chrome_content_renderer_client.h
|
View
|
1
2
3
4
5
6
7
|
1 chunk |
+4 lines, -2 lines |
0 comments
|
Download
|
|
M |
chrome/renderer/chrome_content_renderer_client.cc
|
View
|
1
2
3
4
5
6
7
|
1 chunk |
+6 lines, -4 lines |
0 comments
|
Download
|
|
A |
chrome/test/data/extensions/api_test/service_worker/events_to_stopped_worker/manifest.json
|
View
|
|
1 chunk |
+6 lines, -0 lines |
0 comments
|
Download
|
|
A |
chrome/test/data/extensions/api_test/service_worker/events_to_stopped_worker/on_updated.html
|
View
|
|
1 chunk |
+6 lines, -0 lines |
0 comments
|
Download
|
|
A |
chrome/test/data/extensions/api_test/service_worker/events_to_stopped_worker/on_updated.js
|
View
|
|
1 chunk |
+13 lines, -0 lines |
0 comments
|
Download
|
|
A |
chrome/test/data/extensions/api_test/service_worker/events_to_stopped_worker/page.html
|
View
|
|
1 chunk |
+1 line, -0 lines |
0 comments
|
Download
|
|
A |
chrome/test/data/extensions/api_test/service_worker/events_to_stopped_worker/page.js
|
View
|
1
2
3
|
1 chunk |
+30 lines, -0 lines |
0 comments
|
Download
|
|
A |
chrome/test/data/extensions/api_test/service_worker/events_to_stopped_worker/sw.js
|
View
|
|
1 chunk |
+55 lines, -0 lines |
0 comments
|
Download
|
|
M |
content/browser/service_worker/service_worker_context_wrapper.h
|
View
|
1
2
3
4
5
6
|
1 chunk |
+3 lines, -0 lines |
0 comments
|
Download
|
|
M |
content/browser/service_worker/service_worker_context_wrapper.cc
|
View
|
1
2
3
4
5
6
|
2 chunks |
+46 lines, -0 lines |
0 comments
|
Download
|
|
M |
content/public/browser/service_worker_context.h
|
View
|
1
2
3
4
|
2 chunks |
+12 lines, -0 lines |
0 comments
|
Download
|
|
M |
content/public/renderer/content_renderer_client.h
|
View
|
1
2
3
4
5
6
7
|
1 chunk |
+4 lines, -2 lines |
0 comments
|
Download
|
|
A |
content/public/test/service_worker_test_helpers.h
|
View
|
1
2
3
4
5
|
1 chunk |
+25 lines, -0 lines |
0 comments
|
Download
|
|
A |
content/public/test/service_worker_test_helpers.cc
|
View
|
1
2
3
4
|
1 chunk |
+106 lines, -0 lines |
0 comments
|
Download
|
|
M |
content/renderer/service_worker/service_worker_context_client.cc
|
View
|
1
2
3
4
5
6
7
|
2 chunks |
+3 lines, -2 lines |
0 comments
|
Download
|
|
M |
content/test/BUILD.gn
|
View
|
1
2
3
4
5
6
7
|
1 chunk |
+2 lines, -0 lines |
0 comments
|
Download
|
|
M |
extensions/browser/BUILD.gn
|
View
|
1
2
3
4
5
6
|
2 chunks |
+5 lines, -0 lines |
0 comments
|
Download
|
|
M |
extensions/browser/event_listener_map.h
|
View
|
1
|
4 chunks |
+13 lines, -3 lines |
0 comments
|
Download
|
|
M |
extensions/browser/event_listener_map.cc
|
View
|
1
|
5 chunks |
+12 lines, -12 lines |
0 comments
|
Download
|
|
M |
extensions/browser/event_router.h
|
View
|
1
|
7 chunks |
+12 lines, -11 lines |
0 comments
|
Download
|
|
M |
extensions/browser/event_router.cc
|
View
|
1
2
3
|
8 chunks |
+61 lines, -50 lines |
0 comments
|
Download
|
|
M |
extensions/browser/events/lazy_event_dispatcher.h
|
View
|
1
|
5 chunks |
+16 lines, -5 lines |
0 comments
|
Download
|
|
M |
extensions/browser/events/lazy_event_dispatcher.cc
|
View
|
|
5 chunks |
+34 lines, -6 lines |
0 comments
|
Download
|
|
M |
extensions/browser/extension_message_filter.h
|
View
|
|
1 chunk |
+10 lines, -4 lines |
0 comments
|
Download
|
|
M |
extensions/browser/extension_message_filter.cc
|
View
|
|
7 chunks |
+50 lines, -24 lines |
0 comments
|
Download
|
|
M |
extensions/browser/lazy_background_task_queue.h
|
View
|
|
4 chunks |
+10 lines, -1 line |
0 comments
|
Download
|
|
M |
extensions/browser/lazy_background_task_queue.cc
|
View
|
|
3 chunks |
+25 lines, -0 lines |
0 comments
|
Download
|
|
M |
extensions/browser/lazy_context_id.h
|
View
|
|
2 chunks |
+15 lines, -4 lines |
0 comments
|
Download
|
|
M |
extensions/browser/lazy_context_id.cc
|
View
|
|
2 chunks |
+14 lines, -3 lines |
0 comments
|
Download
|
|
A |
extensions/browser/lazy_context_task_queue.h
|
View
|
1
2
3
|
1 chunk |
+71 lines, -0 lines |
0 comments
|
Download
|
|
A |
extensions/browser/service_worker_task_queue.h
|
View
|
|
1 chunk |
+46 lines, -0 lines |
0 comments
|
Download
|
|
A |
extensions/browser/service_worker_task_queue.cc
|
View
|
1
2
3
4
|
1 chunk |
+98 lines, -0 lines |
0 comments
|
Download
|
|
A |
extensions/browser/service_worker_task_queue_factory.h
|
View
|
|
1 chunk |
+39 lines, -0 lines |
0 comments
|
Download
|
|
A |
extensions/browser/service_worker_task_queue_factory.cc
|
View
|
|
1 chunk |
+44 lines, -0 lines |
0 comments
|
Download
|
|
M |
extensions/common/extension_messages.h
|
View
|
1
2
3
4
5
6
7
|
2 chunks |
+19 lines, -7 lines |
0 comments
|
Download
|
|
M |
extensions/renderer/dispatcher.h
|
View
|
1
2
3
4
5
6
7
|
2 chunks |
+4 lines, -2 lines |
0 comments
|
Download
|
|
M |
extensions/renderer/dispatcher.cc
|
View
|
1
2
3
4
5
6
7
|
5 chunks |
+15 lines, -12 lines |
0 comments
|
Download
|
|
M |
extensions/renderer/event_bindings.cc
|
View
|
|
4 chunks |
+25 lines, -6 lines |
0 comments
|
Download
|
|
M |
extensions/renderer/script_context.h
|
View
|
1
2
3
4
5
6
|
2 chunks |
+7 lines, -0 lines |
0 comments
|
Download
|
|
M |
extensions/renderer/script_context.cc
|
View
|
1
2
3
4
5
6
|
1 chunk |
+5 lines, -0 lines |
0 comments
|
Download
|
Total messages: 48 (32 generated)
|