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

Unified Diff: third_party/WebKit/Source/core/dom/ClassicPendingScript.cpp

Issue 2855733002: Make ClassicPendingScript always become ready asynchronously.
Patch Set: .. Created 3 years, 7 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 | « third_party/WebKit/Source/core/dom/ClassicPendingScript.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/dom/ClassicPendingScript.cpp
diff --git a/third_party/WebKit/Source/core/dom/ClassicPendingScript.cpp b/third_party/WebKit/Source/core/dom/ClassicPendingScript.cpp
index 027fd3921e968d020e2912b8ab89bec478460e8d..fe08bac52a7832a549d5449f45a718125e502ebd 100644
--- a/third_party/WebKit/Source/core/dom/ClassicPendingScript.cpp
+++ b/third_party/WebKit/Source/core/dom/ClassicPendingScript.cpp
@@ -32,11 +32,12 @@ ClassicPendingScript::ClassicPendingScript(
ScriptResource* resource,
const TextPosition& starting_position)
: PendingScript(element, starting_position),
- ready_state_(resource ? kWaitingForResource : kReady),
+ ready_state_(kInConstructor),
integrity_failure_(false) {
CheckState();
SetResource(resource);
MemoryCoordinator::Instance().RegisterClient(this);
+ AdvanceReadyState(resource ? kWaitingForResource : kReady);
}
ClassicPendingScript::~ClassicPendingScript() {}
@@ -121,6 +122,16 @@ static bool CheckScriptResourceIntegrity(Resource* resource,
}
void ClassicPendingScript::NotifyFinished(Resource* resource) {
+ // If we're notified that the resource is synchronously ready, defer the
+ // notification until later anyway.
+ if (ready_state_ == kInConstructor) {
+ TaskRunnerHelper::Get(TaskType::kNetworking, &GetElement()->GetDocument())
+ ->PostTask(BLINK_FROM_HERE,
+ WTF::Bind(&ClassicPendingScript::NotifyFinished,
+ WrapPersistent(this), WrapPersistent(resource)));
+ return;
+ }
+
// The following SRI checks need to be here because, unfortunately, fetches
// are not done purely according to the Fetch spec. In particular,
// different requests for the same resource do not have different
« no previous file with comments | « third_party/WebKit/Source/core/dom/ClassicPendingScript.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698