Chromium Code Reviews| Index: third_party/WebKit/Source/core/inspector/ThreadDebugger.cpp |
| diff --git a/third_party/WebKit/Source/core/inspector/ThreadDebugger.cpp b/third_party/WebKit/Source/core/inspector/ThreadDebugger.cpp |
| index 9b5c11a7e05357045413fc61453be8f44f851a35..d5e82ab413d5993f365090bd97ce5b4b6d7d13c9 100644 |
| --- a/third_party/WebKit/Source/core/inspector/ThreadDebugger.cpp |
| +++ b/third_party/WebKit/Source/core/inspector/ThreadDebugger.cpp |
| @@ -241,22 +241,29 @@ static Vector<String> normalizeEventTypes(const v8::FunctionCallbackInfo<v8::Val |
| return outputTypes; |
| } |
| -void ThreadDebugger::logCallback(const v8::FunctionCallbackInfo<v8::Value>& info) |
| +namespace { |
| + |
| +v8::MaybeLocal<v8::Value> compileAndRunInternalScript(v8::Isolate* isolate, v8::Local<v8::Context> context, v8::Local<v8::String> code) |
|
dgozman
2016/07/25 18:35:37
Why don't we use V8ScriptRunner?
kozy
2016/07/25 18:48:45
I'd like to remove usage of isInternalScript flag
|
| { |
| - if (info.Length() < 1) |
| - return; |
| - ThreadDebugger* debugger = static_cast<ThreadDebugger*>(v8::Local<v8::External>::Cast(info.Data())->Value()); |
| - DCHECK(debugger); |
| - Event* event = V8Event::toImplWithTypeCheck(info.GetIsolate(), info[0]); |
| - if (!event) |
| - return; |
| - debugger->debugger()->logToConsole(info.GetIsolate()->GetCurrentContext(), v8String(info.GetIsolate(), event->type()), info[0]); |
| + v8::ScriptOrigin origin(v8::String::Empty(isolate), v8::Integer::New(isolate, 0), v8::Integer::New(isolate, 0), v8::False(isolate), v8::Local<v8::Integer>(), v8::True(isolate), v8::String::Empty(isolate), v8::True(isolate)); |
| + v8::ScriptCompiler::Source source(code, origin); |
| + v8::Local<v8::Script> script; |
| + if (!v8::ScriptCompiler::Compile(context, &source, v8::ScriptCompiler::kNoCompileOptions).ToLocal(&script)) |
| + return v8::MaybeLocal<v8::Value>(); |
| + v8::MicrotasksScope microtasksScope(isolate, v8::MicrotasksScope::kDoNotRunMicrotasks); |
| + return script->Run(context); |
| } |
| +} // namespace |
| + |
| v8::Local<v8::Function> ThreadDebugger::eventLogFunction() |
| { |
| - if (m_eventLogFunction.IsEmpty()) |
| - m_eventLogFunction.Reset(m_isolate, v8::Function::New(m_isolate->GetCurrentContext(), logCallback, v8::External::New(m_isolate, this), 0, v8::ConstructorBehavior::kThrow).ToLocalChecked()); |
| + if (m_eventLogFunction.IsEmpty()) { |
| + v8::Local<v8::Value> logFunctionValue; |
| + bool success = compileAndRunInternalScript(m_isolate, m_isolate->GetCurrentContext(), v8String(m_isolate, "(function(arg) { console.log(arg); })")).ToLocal(&logFunctionValue) && logFunctionValue->IsFunction(); |
|
dgozman
2016/07/25 18:35:37
We used to log type and event object, now we log o
kozy
2016/07/25 18:48:45
Done.
|
| + DCHECK(success); |
| + m_eventLogFunction.Reset(m_isolate, v8::Local<v8::Function>::Cast(logFunctionValue)); |
| + } |
| return m_eventLogFunction.Get(m_isolate); |
| } |