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

Unified Diff: Source/core/dom/PendingScript.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/dom/PendingScript.h ('k') | Source/core/dom/ScriptLoader.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/dom/PendingScript.cpp
diff --git a/Source/core/dom/PendingScript.cpp b/Source/core/dom/PendingScript.cpp
index 58b27c2ce913bfdbdfbb7deaea6564e817a692be..8d47019cae642400e8b1c656a7909791d6a9b7f5 100644
--- a/Source/core/dom/PendingScript.cpp
+++ b/Source/core/dom/PendingScript.cpp
@@ -26,6 +26,7 @@
#include "config.h"
#include "core/dom/PendingScript.h"
+#include "bindings/core/v8/ScriptStreamer.h"
#include "core/dom/Element.h"
#include "core/fetch/ScriptResource.h"
@@ -35,23 +36,34 @@ PendingScript::~PendingScript()
{
}
-void PendingScript::watchForLoad(ResourceClient* client)
+void PendingScript::watchForLoad(ScriptResourceClient* client)
{
ASSERT(!m_watchingForLoad);
ASSERT(!resource()->isLoaded());
- // addClient() will call notifyFinished() if the load is complete. Callers
- // do not expect to be re-entered from this call, so they should not become
- // a client of an already-loaded Resource.
- resource()->addClient(client);
+ if (m_streamer) {
+ m_streamer->addClient(client);
+ } else {
+ // addClient() will call notifyFinished() if the load is
+ // complete. Callers do not expect to be re-entered from this call, so
+ // they should not become a client of an already-loaded Resource.
+ resource()->addClient(client);
+ }
m_watchingForLoad = true;
}
-void PendingScript::stopWatchingForLoad(ResourceClient* client)
+void PendingScript::stopWatchingForLoad(ScriptResourceClient* client)
{
- if (resource() && m_watchingForLoad) {
+ if (!m_watchingForLoad)
+ return;
+ ASSERT(resource());
+ if (m_streamer) {
+ m_streamer->cancel();
+ m_streamer->removeClient(client);
+ m_streamer.clear();
+ } else {
resource()->removeClient(client);
- m_watchingForLoad = false;
}
+ m_watchingForLoad = false;
}
PassRefPtrWillBeRawPtr<Element> PendingScript::releaseElementAndClear()
@@ -65,10 +77,23 @@ PassRefPtrWillBeRawPtr<Element> PendingScript::releaseElementAndClear()
void PendingScript::setScriptResource(ScriptResource* resource)
{
setResource(resource);
+ // This function is only called 1) during construction (we're not yet
+ // streaming) 2) after loading has completed (and streaming too, if we were
+ // streaming).
+ ASSERT(!isStreaming());
+ m_streamer.release();
+}
+
+void PendingScript::notifyFinished(Resource* resource)
+{
+ if (m_streamer)
+ m_streamer->notifyFinished(resource);
}
-void PendingScript::notifyFinished(Resource*)
+void PendingScript::notifyAppendData(ScriptResource* resource)
{
+ if (m_streamer)
+ m_streamer->notifyAppendData(resource);
}
void PendingScript::trace(Visitor* visitor)
@@ -81,10 +106,17 @@ ScriptSourceCode PendingScript::getSource(const KURL& documentURL, bool& errorOc
if (resource()) {
errorOccurred = resource()->errorOccurred();
ASSERT(resource()->isLoaded());
+ if (m_streamer && !m_streamer->streamingSuppressed())
+ return ScriptSourceCode(m_streamer, resource());
return ScriptSourceCode(resource());
}
errorOccurred = false;
return ScriptSourceCode(m_element->textContent(), documentURL, startingPosition());
}
+bool PendingScript::isStreaming() const
+{
+ return m_streamer && m_streamer->streamingInProgress();
+}
+
}
« no previous file with comments | « Source/core/dom/PendingScript.h ('k') | Source/core/dom/ScriptLoader.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698