DescriptionReland: Refactor Script(Loader|Runner): don't access Resources all over the place...
... but use proper layering instead.
PendingScript holds a Resource, and many places in the code are using both the
PendingScript and the underlying Resource. For example, ScriptRunner holds a
collection of PendingScripts, and ScriptLoaders then listen to the underlying
Resources. This is confusing and error prone.
The Resource - ScriptLoader - PendingScript - Element love quadrangle is messy
in general. Both ScriptLoader and PendingScript refer to the Resource. The way
to get ScriptLoader from PendingScript is via Element which PendingScript also
holds. But there's no way to get PendingScript from ScriptLoader.
This CL makes ScriptRunner access the ScriptLoaders directly and moves the
PendingScript to ScriptLoader. In addition, it makes ScriptRunner not access the
Resource of the ScriptLoader directly.
This CL also cancels the hack from https://bugs.webkit.org/show_bug.cgi?id=92211
(r139942) where it was speculated that a crash can be caused by ScriptLoader
getting the notifyFinished notification twice because it doesn't unsubscribe yet
when it gets the first one. The speculative fix was to made it nullify
ScriptLoader::m_resource and check for the nullity later. This is pretty
surprising, since the obvious solution would've been to just unsubscribe early
enough (which is done by this CL).
Note a behavioral change: It's OK to call Resource::addClient even if the
Resource is finished, and in that case, the client will be notified
immediately. But PendingScript used to ASSERT that the Resource is not
finished. This CL removes that restriction (the underlying Resource already
handles adding clients to finished resources + made ScriptStreamer handle it
too).
First version: https://codereview.chromium.org/656113002/
Committed: https://src.chromium.org/viewvc/blink?view=rev&revision=183984
Patch Set 1 #Patch Set 2 : fixes #Patch Set 3 : another tiny fix: stopWatching no longer cancels, HTMLScriptRunner::detach must #Patch Set 4 : test update #
Messages
Total messages: 17 (8 generated)
|