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

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: cleanup 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
Index: Source/core/html/parser/HTMLScriptRunner.cpp
diff --git a/Source/core/html/parser/HTMLScriptRunner.cpp b/Source/core/html/parser/HTMLScriptRunner.cpp
index 4e1da540a73b334182b6a95a4fcf32e75c74037a..9056d84076e03d2afc51536c2913a2acc764e9da 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())
haraken 2014/09/10 05:57:52 Not related to this CL, is it possible that script
marja 2014/09/11 09:15:38 Hmm, no idea.
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);
}
@@ -255,8 +261,11 @@ 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_parserBlockingScriptAlreadyLoaded)
+ if (!m_parserBlockingScriptAlreadyLoaded) {
+ bool startedStreaming = ScriptStreamer::startStreaming(m_parserBlockingScript);
+ blink::Platform::current()->histogramEnumeration("WebCore.Scripts.ParsingBlocking.StartedStreaming", startedStreaming ? 1 : 0, 2);
haraken 2014/09/10 05:57:52 You can add this in a separate CL.
marja 2014/09/11 09:15:38 Hmm, which part? Calling startStreaming or the UMA
m_parserBlockingScript.watchForLoad(this);
+ }
}
void HTMLScriptRunner::requestDeferredScript(Element* element)
@@ -314,6 +323,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) {

Powered by Google App Engine
This is Rietveld 408576698