Commit 8c892903 authored by Hiroshige Hayashizaki's avatar Hiroshige Hayashizaki Committed by Commit Bot

Remove PendingScript::ErrorOccurred()

In order to make "GetSource() == nullptr"
the single source of truth for whether "the script's script is null".

Bug: 686281
Change-Id: I517c22c38e0b2851722a1cb9211654216d459f13
Reviewed-on: https://chromium-review.googlesource.com/1179558
Commit-Queue: Hiroshige Hayashizaki <hiroshige@chromium.org>
Reviewed-by: default avatarKouhei Ueno <kouhei@chromium.org>
Cr-Commit-Position: refs/heads/master@{#584374}
parent 20d192c8
......@@ -335,7 +335,7 @@ ClassicScript* ClassicPendingScript::GetSource(const KURL& document_url) const {
CheckState();
DCHECK(IsReady());
if (ErrorOccurred())
if (ready_state_ == kErrorOccurred)
return nullptr;
if (!is_external_) {
......@@ -424,11 +424,6 @@ bool ClassicPendingScript::IsReady() const {
return ready_state_ >= kReady;
}
bool ClassicPendingScript::ErrorOccurred() const {
CheckState();
return ready_state_ == kErrorOccurred;
}
void ClassicPendingScript::AdvanceReadyState(ReadyState new_ready_state) {
// We will allow exactly these state transitions:
//
......
......@@ -62,7 +62,6 @@ class CORE_EXPORT ClassicPendingScript final : public PendingScript,
ClassicScript* GetSource(const KURL& document_url) const override;
bool IsReady() const override;
bool IsExternal() const override { return is_external_; }
bool ErrorOccurred() const override;
bool WasCanceled() const override;
bool StartStreamingIfPossible(base::OnceClosure) override;
bool IsCurrentlyStreaming() const override;
......
......@@ -80,14 +80,9 @@ std::unique_ptr<TracedValue> GetTraceArgsForScriptElement(
}
void DoExecuteScript(PendingScript* pending_script, const KURL& document_url) {
ScriptElementBase* element = pending_script->GetElement();
const char* const trace_event_name =
pending_script->ErrorOccurred()
? "HTMLParserScriptRunner ExecuteScriptFailed"
: "HTMLParserScriptRunner ExecuteScript";
TRACE_EVENT_WITH_FLOW1("blink", trace_event_name, element,
TRACE_EVENT_FLAG_FLOW_IN, "data",
GetTraceArgsForScriptElement(pending_script));
TRACE_EVENT_WITH_FLOW1("blink", "HTMLParserScriptRunner ExecuteScript",
pending_script->GetElement(), TRACE_EVENT_FLAG_FLOW_IN,
"data", GetTraceArgsForScriptElement(pending_script));
pending_script->ExecuteScriptBlock(document_url);
}
......
......@@ -67,16 +67,7 @@ void ModulePendingScript::NotifyModuleTreeLoadFinished() {
Script* ModulePendingScript::GetSource(const KURL& document_url) const {
CHECK(IsReady());
if (ErrorOccurred())
return nullptr;
DCHECK(GetModuleScript());
return GetModuleScript();
}
bool ModulePendingScript::ErrorOccurred() const {
CHECK(IsReady());
return !GetModuleScript();
}
} // namespace blink
......@@ -75,7 +75,6 @@ class CORE_EXPORT ModulePendingScript : public PendingScript {
Script* GetSource(const KURL& document_url) const override;
bool IsReady() const override { return ready_; }
bool IsExternal() const override { return is_external_; }
bool ErrorOccurred() const override;
bool WasCanceled() const override { return false; }
bool StartStreamingIfPossible(base::OnceClosure) override { return false; }
......
......@@ -93,7 +93,6 @@ class CORE_EXPORT PendingScript
// https://html.spec.whatwg.org/multipage/scripting.html#the-script-is-ready
virtual bool IsReady() const = 0;
virtual bool IsExternal() const = 0;
virtual bool ErrorOccurred() const = 0;
virtual bool WasCanceled() const = 0;
// Support for script streaming.
......
......@@ -39,7 +39,6 @@ class MockPendingScript : public PendingScript {
MOCK_CONST_METHOD1(CheckMIMETypeBeforeRunScript, bool(Document*));
MOCK_CONST_METHOD1(GetSource, Script*(const KURL&));
MOCK_CONST_METHOD0(IsExternal, bool());
MOCK_CONST_METHOD0(ErrorOccurred, bool());
MOCK_CONST_METHOD0(WasCanceled, bool());
MOCK_CONST_METHOD0(UrlForTracing, KURL());
MOCK_METHOD0(RemoveFromMemoryCache, void());
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment