Commit 23c523b0 authored by Hiroshige Hayashizaki's avatar Hiroshige Hayashizaki Committed by Commit Bot

Remove Resource from V8ScriptRunner

Now that ScriptResource is used only in DCHECK()s in V8ScriptRunner,
this CL removes ScriptResource entirely from V8ScriptRunner.

V8ScriptRunner no longer needs to check the consistency between
ScriptResource and other arguments, which is/should be checked by
its callers instead.

This is preparation for removing ScriptSourceCode::Resource().

Bug: 788828
Change-Id: Id41e634b384e04ab2881c317b1f5e661c6026954
Reviewed-on: https://chromium-review.googlesource.com/786533
Commit-Queue: Hiroshige Hayashizaki <hiroshige@chromium.org>
Reviewed-by: default avatarJeremy Roman <jbroman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#520985}
parent 529b40e1
......@@ -39,7 +39,6 @@
#include "core/frame/LocalFrame.h"
#include "core/inspector/InspectorTraceEvents.h"
#include "core/inspector/ThreadDebugger.h"
#include "core/loader/resource/ScriptResource.h"
#include "core/probe/CoreProbes.h"
#include "platform/Histogram.h"
#include "platform/bindings/ScriptForbiddenScope.h"
......@@ -403,9 +402,8 @@ v8::MaybeLocal<v8::Script> V8ScriptRunner::CompileScript(
return CompileScript(script_state, V8String(isolate, source.Source()),
source.Url(), source.SourceMapUrl(),
source.StartPosition(), source.SourceLocationType(),
source.GetResource(), source.Streamer(),
cache_metadata_handler, access_control_status,
v8_cache_options, referrer_info);
source.Streamer(), cache_metadata_handler,
access_control_status, v8_cache_options, referrer_info);
}
v8::MaybeLocal<v8::Script> V8ScriptRunner::CompileScript(
......@@ -415,7 +413,6 @@ v8::MaybeLocal<v8::Script> V8ScriptRunner::CompileScript(
const String& source_map_url,
const TextPosition& script_start_position,
ScriptSourceLocationType source_location_type,
ScriptResource* resource,
ScriptStreamer* streamer,
CachedMetadataHandler* cache_handler,
AccessControlStatus access_control_status,
......@@ -428,11 +425,6 @@ v8::MaybeLocal<v8::Script> V8ScriptRunner::CompileScript(
script_start_position.line_.ZeroBasedInt(),
script_start_position.column_.ZeroBasedInt());
DCHECK(!streamer || resource);
DCHECK(!resource || resource->CacheHandler() == cache_handler);
DCHECK(!resource ||
source_location_type == ScriptSourceLocationType::kExternalFile);
// NOTE: For compatibility with WebCore, ScriptSourceCode's line starts at
// 1, whereas v8 starts at 0.
v8::Isolate* isolate = script_state->GetIsolate();
......@@ -558,7 +550,7 @@ v8::MaybeLocal<v8::Value> V8ScriptRunner::CompileAndRunInternalScript(
// - parser_state: always "not parser inserted" for internal scripts.
if (!V8ScriptRunner::CompileScript(
script_state, source, file_name, String(), script_start_position,
ScriptSourceLocationType::kInternal, nullptr, nullptr, nullptr,
ScriptSourceLocationType::kInternal, nullptr, nullptr,
kSharableCrossOrigin, kV8CacheOptionsDefault, ReferrerScriptInfo())
.ToLocal(&script))
return v8::MaybeLocal<v8::Value>();
......
......@@ -50,7 +50,6 @@ namespace blink {
class CachedMetadata;
class CachedMetadataHandler;
class ExecutionContext;
class ScriptResource;
class ScriptSourceCode;
class ScriptStreamer;
......@@ -65,23 +64,19 @@ class CORE_EXPORT V8ScriptRunner final {
// For the following methods, the caller sites have to hold
// a HandleScope and a ContextScope.
// CachedMetadataHandler is set when metadata caching is supported.
static v8::MaybeLocal<v8::Script> CompileScript(ScriptState*,
const ScriptSourceCode&,
CachedMetadataHandler*,
AccessControlStatus,
V8CacheOptions,
const ReferrerScriptInfo&);
// CachedMetadataHandler is set when metadata caching is supported. For
// normal scripe resources, CachedMetadataHandler is from ScriptResource.
// For worker script, ScriptResource is null but CachedMetadataHandler may be
// set. When ScriptStreamer is set, ScriptResource must be set.
static v8::MaybeLocal<v8::Script> CompileScript(ScriptState*,
v8::Local<v8::String>,
const String& file_name,
const String& source_map_url,
const TextPosition&,
ScriptSourceLocationType,
ScriptResource*,
ScriptStreamer*,
CachedMetadataHandler*,
AccessControlStatus,
......
......@@ -62,8 +62,8 @@ class V8ScriptRunnerTest : public ::testing::Test {
return !V8ScriptRunner::CompileScript(
script_state, V8String(script_state->GetIsolate(), Code()),
Filename(), String(), WTF::TextPosition(),
ScriptSourceLocationType::kExternalFile, resource_.Get(),
nullptr, resource_.Get() ? resource_->CacheHandler() : nullptr,
ScriptSourceLocationType::kExternalFile, nullptr,
resource_.Get() ? resource_->CacheHandler() : nullptr,
kNotSharableCrossOrigin, cache_options, ReferrerScriptInfo())
.IsEmpty();
}
......
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