Chromium Code Reviews| 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 4ab6c71f21acde2a6f8127d44d7721042da053c8..42646546f853c61723c30e4710dc3622c58bc275 100644 |
| --- a/third_party/WebKit/Source/core/dom/ClassicPendingScript.cpp |
| +++ b/third_party/WebKit/Source/core/dom/ClassicPendingScript.cpp |
| @@ -18,6 +18,7 @@ namespace blink { |
| ClassicPendingScript* ClassicPendingScript::Create(ScriptElementBase* element, |
| ScriptResource* resource) { |
| + CHECK(resource); |
| return new ClassicPendingScript(element, resource, TextPosition()); |
| } |
| @@ -31,9 +32,12 @@ ClassicPendingScript::ClassicPendingScript( |
| ScriptElementBase* element, |
| ScriptResource* resource, |
| const TextPosition& starting_position) |
| - : PendingScript(element, starting_position), integrity_failure_(false) { |
| - CheckState(); |
| + : PendingScript(element, starting_position), |
| + is_external_(resource), |
| + integrity_failure_(false) { |
| + CHECK(GetElement()); |
| SetResource(resource); |
| + CheckState(); |
| MemoryCoordinator::Instance().RegisterClient(this); |
| } |
| @@ -43,6 +47,7 @@ NOINLINE void ClassicPendingScript::CheckState() const { |
| // TODO(hiroshige): Turn these CHECK()s into DCHECK() before going to beta. |
| CHECK(!prefinalizer_called_); |
| CHECK(GetElement()); |
| + CHECK_EQ(is_external_, !!GetResource()); |
| CHECK(GetResource() || !streamer_); |
| CHECK(!streamer_ || streamer_->GetResource() == GetResource()); |
| } |
| @@ -169,7 +174,7 @@ ClassicScript* ClassicPendingScript::GetSource(const KURL& document_url, |
| CheckState(); |
| error_occurred = this->ErrorOccurred(); |
| - if (GetResource()) { |
| + if (is_external_) { |
|
sof
2017/04/29 15:01:10
Why is this (and all the other is_external_ checks
|
| DCHECK(GetResource()->IsLoaded()); |
| if (streamer_ && !streamer_->StreamingSuppressed()) |
| return ClassicScript::Create(ScriptSourceCode(streamer_, GetResource())); |
| @@ -189,7 +194,7 @@ void ClassicPendingScript::SetStreamer(ScriptStreamer* streamer) { |
| bool ClassicPendingScript::IsReady() const { |
| CheckState(); |
| - if (GetResource()) { |
| + if (is_external_) { |
| return GetResource()->IsLoaded() && (!streamer_ || streamer_->IsFinished()); |
| } |
| @@ -198,7 +203,7 @@ bool ClassicPendingScript::IsReady() const { |
| bool ClassicPendingScript::ErrorOccurred() const { |
| CheckState(); |
| - if (GetResource()) |
| + if (is_external_) |
| return GetResource()->ErrorOccurred() || integrity_failure_; |
| return false; |