Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1240)

Unified Diff: Source/core/html/parser/HTMLScriptRunner.cpp

Issue 368283002: Stream scripts to V8 as they load - Blink side. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: removed untrue assert Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/html/parser/HTMLScriptRunner.h ('k') | Source/core/xml/parser/XMLDocumentParser.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/html/parser/HTMLScriptRunner.cpp
diff --git a/Source/core/html/parser/HTMLScriptRunner.cpp b/Source/core/html/parser/HTMLScriptRunner.cpp
index 9d0355475049aec0b75f859d257eac49dac10cbf..74a30628225a53db17f2474a829d19f72a3ab229 100644
--- a/Source/core/html/parser/HTMLScriptRunner.cpp
+++ b/Source/core/html/parser/HTMLScriptRunner.cpp
@@ -109,6 +109,8 @@ bool HTMLScriptRunner::isPendingScriptReady(const PendingScript& script)
return false;
if (script.resource() && !script.resource()->isLoaded())
return false;
+ if (script.isStreaming())
+ return false;
return true;
}
@@ -167,6 +169,10 @@ void HTMLScriptRunner::executePendingScriptAndDispatchEvent(PendingScript& pendi
void HTMLScriptRunner::notifyFinished(Resource* cachedResource)
{
+ // For a parser-blocking script, this function should be called only when
+ // the streaming is complete.
+ ASSERT(!(m_parserBlockingScript.resource() == cachedResource
+ && m_parserBlockingScript.isStreaming()));
m_host->notifyScriptLoaded(cachedResource);
}
@@ -260,8 +266,13 @@ void HTMLScriptRunner::requestParsingBlockingScript(Element* element)
// We only care about a load callback if resource is not already
// in the cache. Callers will attempt to run the m_parserBlockingScript
// if possible before returning control to the parser.
- if (!m_parserBlockingScript.resource()->isLoaded())
+ if (!m_parserBlockingScript.resource()->isLoaded()) {
+ bool startedStreaming = false;
+ if (m_document->frame())
+ startedStreaming = ScriptStreamer::startStreaming(m_parserBlockingScript, m_document->frame()->settings(), ScriptState::forMainWorld(m_document->frame()));
+ blink::Platform::current()->histogramEnumeration("WebCore.Scripts.ParsingBlocking.StartedStreaming", startedStreaming ? 1 : 0, 2);
m_parserBlockingScript.watchForLoad(this);
+ }
}
void HTMLScriptRunner::requestDeferredScript(Element* element)
@@ -319,6 +330,8 @@ void HTMLScriptRunner::runScript(Element* script, const TextPosition& scriptStar
return;
if (scriptLoader->willExecuteWhenDocumentFinishedParsing()) {
+ // FIXME: in addition to parser blocking scripts, stream also
+ // scripts which are not parser blocking.
requestDeferredScript(script);
} else if (scriptLoader->readyToBeParserExecuted()) {
if (m_scriptNestingLevel == 1) {
« no previous file with comments | « Source/core/html/parser/HTMLScriptRunner.h ('k') | Source/core/xml/parser/XMLDocumentParser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698