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

Unified Diff: third_party/WebKit/Source/core/dom/PendingScript.h

Issue 2828193003: Explicitly track the lifecycle of PendingScript. (Closed)
Patch Set: document, and replace watching_for_load_ Created 3 years, 8 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: 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 0be3dcfaacfa6df6aabdf69964b4fca89ff747e7..c45f845e2bd31c63801a7b4a081cf97898b4ebe8 100644
--- a/third_party/WebKit/Source/core/dom/PendingScript.h
+++ b/third_party/WebKit/Source/core/dom/PendingScript.h
@@ -90,6 +90,7 @@ class CORE_EXPORT PendingScript final
void WatchForLoad(PendingScriptClient*);
void StopWatchingForLoad();
+ bool WatchingForLoad() const { return client_; }
ScriptElementBase* GetElement() const;
@@ -101,8 +102,14 @@ class CORE_EXPORT PendingScript final
void SetStreamer(ScriptStreamer*);
void StreamingFinished();
- bool IsReady() const;
- bool ErrorOccurred() const;
+ bool IsReady() const {
+ CheckState();
+ return ready_state_ >= kReady;
+ }
+ bool ErrorOccurred() const {
+ CheckState();
+ return ready_state_ == kErrorOccurred;
+ }
void StartStreamingIfPossible(Document*, ScriptStreamer::Type);
void Dispose();
@@ -124,7 +131,20 @@ class CORE_EXPORT PendingScript final
// MemoryCoordinatorClient
void OnPurgeMemory() override;
- bool watching_for_load_;
+ enum ReadyState {
+ // These states are considered "not ready".
+ kWaitingForResource,
+ kWaitingForStreaming,
+ // These states are considered "ready".
+ kReady,
+ kErrorOccurred,
+ };
+
+ // Advances the current state of the script, reporting to the client is
hiroshige 2017/04/24 19:16:53 nit: reporting to the client *if*?
jbroman 2017/05/01 15:08:02 Done.
+ // appropriate.
+ void AdvanceReadyState(ReadyState);
+
+ ReadyState ready_state_;
// |m_element| must points to the corresponding ScriptLoader's
// ScriptElementBase and thus must be non-null before dispose() is called

Powered by Google App Engine
This is Rietveld 408576698