[Extensions Bindings] Restructure event dispatching during JS suspension
JS can be suspended when the renderer receives the IPC to dispatch an event. In this case, the JS shouldn't immediately run, but rather respect the JS state. Currently, the EventEmitter does this by using JSRunner::RunJSFunction() (which does respect JS suspension) with each of the listeners for the event. This mostly works, but has a couple of problems. For one, it makes it difficult to catch exceptions thrown from a JS listener (since the listener isn't notified when we queue it up through the JSRunner). It also doesn't account for the possibility of listeners being removed between a event comes in, and when it is actually disptached. Finally, it makes creating a single result for the dispatch difficult, which is problematic for messaging bindings. Rework the way event dispatching works to instead use a v8::Function wrapper around the EventEmitter to trigger the event being dispatched to listeners. Once that function is triggered, it's safe to use synchronous JS execution, since JS is already running at that point. This addresses the concerns with the current approach. Also add a Suspension utility to the TestJSRunner to simulate JS being suspended in testing, and add unit tests for dispatching events while JS is suspended. Bug: 653596 Change-Id: I7899e1946e8fe750fa2a1f53d62a04e5bd075664 Reviewed-on: https://chromium-review.googlesource.com/792033 Commit-Queue: Devlin <rdevlin.cronin@chromium.org> Reviewed-by:Istiaque Ahmed <lazyboy@chromium.org> Reviewed-by:
Jeremy Roman <jbroman@chromium.org> Cr-Commit-Position: refs/heads/master@{#521592}
Showing
This diff is collapsed.
Please register or sign in to comment