commit | ee72f4957506d942970bbdc7be2fcd65ecf7fae2 | [log] [tgz] |
---|---|---|
author | Istiaque Ahmed <lazyboy@chromium.org> | Wed Mar 06 21:18:36 2019 |
committer | Commit Bot <commit-bot@chromium.org> | Wed Mar 06 21:18:36 2019 |
tree | 64ea373986773f69704c2a18a0490d2d82014a29 | |
parent | 05d66a56b339e56c1be8dbeba5988afb1ddab6db [diff] |
Implement tab (content script) to Service Worker extension messaging. This is the first step towards implementation of Extension messaging in Extension Service Workers. The CL implements chrome.test.sendMessage from a tab (content script) to a Service Worker running as extension background. Replying to the message through callback isn't implemented in this CL. The basic changes in this CL are: - Make the messaging bindings available in the service workers' script context: runtime.sendMessage and runtime.onMessage. - Handle IPCs to open/close a port for workers as well. - Handle these IPCs in the browser process in the existing MessagingService class, expand ExtensionMessagePort to support workers along with RenderFrames/tabs. - Both JS and native bindings work. - Future CLs can expand on this base CL to support other messaging source and destinations as the implementation is meant to move the code towards generic support of messaging endpoints (worker or RenderFrame). Some more detailed implementation notes: - ExtensionMessagePort can track and target workers along with existing RenderFrames/tabs support. Handle the IPCs sent by it on worker thread (WorkerThreadDispatcher), these IPCs are: * ExtensionMsg_ValidateMessagePort * ExtnesionMsg_DispatchOnConnect * ExtensionMsg_DippatchOnDisconnect * ExtensionMsg_DeliverMessage - MessageService can now work with Service Workers, similar to how they used to work with event pages. - Introduce a generic ScriptContextSetIterator class in the renderer to apply IPCs to a set of ScriptContexts. Expand that to cover WorkerScriptContextSets as well as non-worker ScriptContextSets. Messaging IPCs targeted to workers now get dispatched to WorkerScriptContextSets. An unfortunate consequence of generalizing this to worker is Dispatcher provides a non-const ptr getter to ScriptContextSets (script_context_set_iterator) as worker script context sets require tls lookup. Add an end-to-end test for the feature. Bug: 925927 Change-Id: I8f77e6d63318925b85dc5707f9367e904bde634c Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1441274 Commit-Queue: Istiaque Ahmed <lazyboy@chromium.org> Reviewed-by: Devlin <rdevlin.cronin@chromium.org> Cr-Commit-Position: refs/heads/master@{#638277}
Chromium is an open-source browser project that aims to build a safer, faster, and more stable way for all users to experience the web.
The project's web site is https://www.chromium.org.
Documentation in the source is rooted in docs/README.md.
Learn how to Get Around the Chromium Source Code Directory Structure .