Index: third_party/WebKit/Source/core/dom/PendingScript.h |
diff --git a/third_party/WebKit/Source/core/dom/PendingScript.h b/third_party/WebKit/Source/core/dom/PendingScript.h |
index 1a82229fcee7ebf389cc7c099c2c214d5840658f..c6fab8c2c2c116a6cbd3d1db9b133b24eb73dd28 100644 |
--- a/third_party/WebKit/Source/core/dom/PendingScript.h |
+++ b/third_party/WebKit/Source/core/dom/PendingScript.h |
@@ -26,6 +26,7 @@ |
#ifndef PendingScript_h |
#define PendingScript_h |
+#include "bindings/core/v8/CompiledScript.h" |
#include "bindings/core/v8/ScriptStreamer.h" |
#include "core/CoreExport.h" |
#include "core/loader/resource/ScriptResource.h" |
@@ -97,11 +98,13 @@ class CORE_EXPORT PendingScript final |
ScriptSourceCode getSource(const KURL& documentURL, |
bool& errorOccurred) const; |
+ CompiledScript* getCompiledScript() const { return m_compiledScript.get(); } |
void setStreamer(ScriptStreamer*); |
void streamingFinished(); |
- bool isReady() const; |
+ // TODO(jbroman): disambiguate what "ready" means |
+ bool isReady() const; // { return m_isReady; } |
bool errorOccurred() const; |
void dispose(); |
@@ -113,6 +116,13 @@ class CORE_EXPORT PendingScript final |
bool isForTesting = false); |
PendingScript() = delete; |
+ // Called when the final source is available (i.e. the resource has loaded, |
+ // and streaming, if applicable, has completed). |
+ void fetchFinished(); |
+ |
+ // Called when the script compile step is complete or determined unnecessary. |
+ void compileFinished(); |
+ |
void checkState() const; |
// ScriptResourceClient |
@@ -125,6 +135,29 @@ class CORE_EXPORT PendingScript final |
bool m_watchingForLoad; |
+ enum ReadyState { |
+ kWaitingForResource, |
+ kWaitingForStreaming, |
+ kWaitingForCompile, |
+ kReady, |
+ }; |
+ void advanceReadyState(ReadyState readyState) { |
+ CHECK_GT(readyState, m_readyState); |
+ m_readyState = readyState; |
+ |
+ if (resource()) { |
+ CHECK_EQ(m_readyState > kWaitingForResource, resource()->isLoaded()); |
+ CHECK_EQ( |
+ m_readyState > kWaitingForStreaming, |
+ resource()->isLoaded() && (!m_streamer || m_streamer->isFinished())) |
+ << "readystate=" << m_readyState << ' ' << resource()->isLoaded() |
+ << ' ' << (m_streamer ? (m_streamer->isFinished() ? 'y' : 'n') : '-'); |
+ } else { |
+ CHECK_EQ(m_readyState, kReady); |
+ } |
+ } |
+ ReadyState m_readyState = kWaitingForResource; |
+ |
// |m_element| must points to the corresponding ScriptLoader's element and |
// thus must be non-null before dispose() is called (except for unit tests). |
Member<Element> m_element; |
@@ -136,6 +169,8 @@ class CORE_EXPORT PendingScript final |
Member<ScriptStreamer> m_streamer; |
Member<PendingScriptClient> m_client; |
+ Member<CompiledScript> m_compiledScript; |
+ |
// This flag is used to skip non-null checks of |m_element| in unit tests, |
// because |m_element| can be null in unit tests. |
const bool m_isForTesting; |