Commit 593547ab authored by josyulavn's avatar josyulavn Committed by Commit Bot

[bindings] Refactor bindings to accept v8::Isolate* as first parameter.

Refactor V8ScriptRunner & AbstractEventlistener to make v8::Isolate* as first parameter
BUG=424446

Change-Id: I6349a8699efb3e69e27b91a313167f310c1219dc
Reviewed-on: https://chromium-review.googlesource.com/826765Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Commit-Queue: srirama chandra sekhar <srirama.m@samsung.com>
Cr-Commit-Position: refs/heads/master@{#524046}
parent e8e8903d
......@@ -96,8 +96,8 @@ ScriptValue ScriptModule::Evaluate(ScriptState* script_state) const {
// TODO(kouhei): We currently don't have a code-path which use return value of
// EvaluateModule. Stop ignoring result once we have such path.
v8::Local<v8::Value> result;
if (!V8ScriptRunner::EvaluateModule(module_->NewLocal(isolate),
script_state->GetContext(), isolate)
if (!V8ScriptRunner::EvaluateModule(isolate, module_->NewLocal(isolate),
script_state->GetContext())
.ToLocal(&result)) {
DCHECK(try_catch.HasCaught());
return ScriptValue(script_state, try_catch.Exception());
......
......@@ -93,9 +93,8 @@ int ScriptRegexp::Match(const String& string,
v8::Local<v8::Value> argv[] = {
V8String(isolate, string.Substring(start_from))};
v8::Local<v8::Value> return_value;
if (!V8ScriptRunner::CallInternalFunction(exec.As<v8::Function>(), regex,
WTF_ARRAY_LENGTH(argv), argv,
isolate)
if (!V8ScriptRunner::CallInternalFunction(isolate, exec.As<v8::Function>(),
regex, WTF_ARRAY_LENGTH(argv), argv)
.ToLocal(&return_value))
return -1;
......
......@@ -46,9 +46,9 @@
namespace blink {
V8AbstractEventListener::V8AbstractEventListener(bool is_attribute,
DOMWrapperWorld& world,
v8::Isolate* isolate)
V8AbstractEventListener::V8AbstractEventListener(v8::Isolate* isolate,
bool is_attribute,
DOMWrapperWorld& world)
: EventListener(kJSEventListenerType),
listener_(nullptr),
is_attribute_(is_attribute),
......
......@@ -115,7 +115,7 @@ class CORE_EXPORT V8AbstractEventListener : public EventListener {
virtual void TraceWrappers(const ScriptWrappableVisitor*) const;
protected:
V8AbstractEventListener(bool is_attribute, DOMWrapperWorld&, v8::Isolate*);
V8AbstractEventListener(v8::Isolate*, bool is_attribute, DOMWrapperWorld&);
virtual v8::Local<v8::Object> GetListenerObjectInternal(
ExecutionContext* execution_context) {
......
......@@ -40,9 +40,9 @@
namespace blink {
V8EventListener::V8EventListener(bool is_attribute, ScriptState* script_state)
: V8AbstractEventListener(is_attribute,
script_state->World(),
script_state->GetIsolate()) {}
: V8AbstractEventListener(script_state->GetIsolate(),
is_attribute,
script_state->World()) {}
v8::Local<v8::Function> V8EventListener::GetListenerFunction(
ScriptState* script_state) {
......
......@@ -459,10 +459,9 @@ void V8GCController::CollectGarbage(v8::Isolate* isolate, bool only_minor_gc) {
builder.Append(only_minor_gc ? "true" : "false");
builder.Append(")");
V8ScriptRunner::CompileAndRunInternalScript(
script_state.get(),
isolate, script_state.get(),
ScriptSourceCode(builder.ToString(), ScriptSourceLocationType::kInternal,
nullptr, KURL(), TextPosition()),
isolate);
nullptr, KURL(), TextPosition()));
script_state->DisposePerContextData();
}
......
......@@ -60,7 +60,7 @@ V8LazyEventListener::V8LazyEventListener(
const String source_url,
const TextPosition& position,
Node* node)
: V8AbstractEventListener(true, DOMWrapperWorld::MainWorld(), isolate),
: V8AbstractEventListener(isolate, true, DOMWrapperWorld::MainWorld()),
was_compilation_failed_(false),
function_name_(function_name),
event_parameter_name_(event_parameter_name),
......
......@@ -523,9 +523,9 @@ v8::MaybeLocal<v8::Value> V8ScriptRunner::RunCompiledScript(
}
v8::MaybeLocal<v8::Value> V8ScriptRunner::CompileAndRunInternalScript(
v8::Isolate* isolate,
ScriptState* script_state,
const ScriptSourceCode& source_code,
v8::Isolate* isolate) {
const ScriptSourceCode& source_code) {
DCHECK_EQ(isolate, script_state->GetIsolate());
v8::Local<v8::Script> script;
......@@ -640,11 +640,11 @@ v8::MaybeLocal<v8::Value> V8ScriptRunner::CallFunction(
}
v8::MaybeLocal<v8::Value> V8ScriptRunner::CallInternalFunction(
v8::Isolate* isolate,
v8::Local<v8::Function> function,
v8::Local<v8::Value> receiver,
int argc,
v8::Local<v8::Value> args[],
v8::Isolate* isolate) {
v8::Local<v8::Value> args[]) {
TRACE_EVENT0("v8", "v8.callFunction");
RuntimeCallStatsScopedTracer rcs_scoped_tracer(isolate);
RUNTIME_CALL_TIMER_SCOPE(isolate, RuntimeCallStats::CounterId::kV8);
......@@ -659,9 +659,9 @@ v8::MaybeLocal<v8::Value> V8ScriptRunner::CallInternalFunction(
}
v8::MaybeLocal<v8::Value> V8ScriptRunner::EvaluateModule(
v8::Isolate* isolate,
v8::Local<v8::Module> module,
v8::Local<v8::Context> context,
v8::Isolate* isolate) {
v8::Local<v8::Context> context) {
TRACE_EVENT0("v8,devtools.timeline", "v8.evaluateModule");
RUNTIME_CALL_TIMER_SCOPE(isolate, RuntimeCallStats::CounterId::kV8);
v8::MicrotasksScope microtasks_scope(isolate,
......@@ -714,8 +714,8 @@ v8::MaybeLocal<v8::Value> V8ScriptRunner::CallExtraHelper(
.ToLocal(&function_value))
return v8::MaybeLocal<v8::Value>();
v8::Local<v8::Function> function = function_value.As<v8::Function>();
return V8ScriptRunner::CallInternalFunction(function, v8::Undefined(isolate),
num_args, args, isolate);
return V8ScriptRunner::CallInternalFunction(
isolate, function, v8::Undefined(isolate), num_args, args);
}
// static
......
......@@ -79,9 +79,9 @@ class CORE_EXPORT V8ScriptRunner final {
v8::Local<v8::Script>,
ExecutionContext*);
static v8::MaybeLocal<v8::Value> CompileAndRunInternalScript(
v8::Isolate*,
ScriptState*,
const ScriptSourceCode&,
v8::Isolate*);
const ScriptSourceCode&);
static v8::MaybeLocal<v8::Value> RunCompiledInternalScript(
v8::Isolate*,
v8::Local<v8::Script>);
......@@ -92,20 +92,20 @@ class CORE_EXPORT V8ScriptRunner final {
int argc = 0,
v8::Local<v8::Value> argv[] = nullptr);
static v8::MaybeLocal<v8::Value> CallInternalFunction(
v8::Isolate*,
v8::Local<v8::Function>,
v8::Local<v8::Value> receiver,
int argc,
v8::Local<v8::Value> info[],
v8::Isolate*);
v8::Local<v8::Value> info[]);
static v8::MaybeLocal<v8::Value> CallFunction(v8::Local<v8::Function>,
ExecutionContext*,
v8::Local<v8::Value> receiver,
int argc,
v8::Local<v8::Value> info[],
v8::Isolate*);
static v8::MaybeLocal<v8::Value> EvaluateModule(v8::Local<v8::Module>,
v8::Local<v8::Context>,
v8::Isolate*);
static v8::MaybeLocal<v8::Value> EvaluateModule(v8::Isolate*,
v8::Local<v8::Module>,
v8::Local<v8::Context>);
// Only to be used from ScriptModule::ReportException().
static void ReportExceptionForModule(v8::Isolate*,
......
......@@ -140,8 +140,8 @@ void DevToolsHost::EvaluateScript(const String& expression) {
v8::MicrotasksScope::kRunMicrotasks);
ScriptSourceCode source_code(expression, ScriptSourceLocationType::kInternal,
nullptr, KURL(), TextPosition());
V8ScriptRunner::CompileAndRunInternalScript(script_state, source_code,
script_state->GetIsolate());
V8ScriptRunner::CompileAndRunInternalScript(script_state->GetIsolate(),
script_state, source_code);
}
void DevToolsHost::DisconnectClient() {
......
......@@ -278,11 +278,10 @@ void ThreadDebugger::installAdditionalCommandLineAPI(
v8::Local<v8::Value> function_value;
bool success =
V8ScriptRunner::CompileAndRunInternalScript(
ScriptState::From(context),
isolate_, ScriptState::From(context),
ScriptSourceCode("(function(e) { console.log(e.type, e); })",
ScriptSourceLocationType::kInternal, nullptr, KURL(),
TextPosition()),
isolate_)
TextPosition()))
.ToLocal(&function_value) &&
function_value->IsFunction();
DCHECK(success);
......
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