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

Unified Diff: Source/core/dom/PendingScript.cpp

Issue 551293002: Refactor PendingScript / HTMLScriptRunner. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: 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/html/parser/HTMLScriptRunner.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 3808001d912aeea101fb1da68546781926476da4..58b27c2ce913bfdbdfbb7deaea6564e817a692be 100644
--- a/Source/core/dom/PendingScript.cpp
+++ b/Source/core/dom/PendingScript.cpp
@@ -35,6 +35,25 @@ PendingScript::~PendingScript()
{
}
+void PendingScript::watchForLoad(ResourceClient* 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);
+ m_watchingForLoad = true;
+}
+
+void PendingScript::stopWatchingForLoad(ResourceClient* client)
+{
+ if (resource() && m_watchingForLoad) {
+ resource()->removeClient(client);
+ m_watchingForLoad = false;
+ }
+}
+
PassRefPtrWillBeRawPtr<Element> PendingScript::releaseElementAndClear()
{
setScriptResource(0);
@@ -57,4 +76,15 @@ void PendingScript::trace(Visitor* visitor)
visitor->trace(m_element);
}
+ScriptSourceCode PendingScript::getSource(const KURL& documentURL, bool& errorOccurred) const
+{
+ if (resource()) {
+ errorOccurred = resource()->errorOccurred();
+ ASSERT(resource()->isLoaded());
+ return ScriptSourceCode(resource());
+ }
+ errorOccurred = false;
+ return ScriptSourceCode(m_element->textContent(), documentURL, startingPosition());
+}
+
}
« no previous file with comments | « Source/core/dom/PendingScript.h ('k') | Source/core/html/parser/HTMLScriptRunner.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698