Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(77)

Side by Side Diff: third_party/WebKit/Source/core/inspector/ThreadDebugger.cpp

Issue 2176283002: [DevTools] Remove V8Debugger::logToConsole method (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: addressed comments Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "core/inspector/ThreadDebugger.h" 5 #include "core/inspector/ThreadDebugger.h"
6 6
7 #include "bindings/core/v8/SourceLocation.h" 7 #include "bindings/core/v8/SourceLocation.h"
8 #include "bindings/core/v8/V8Binding.h" 8 #include "bindings/core/v8/V8Binding.h"
9 #include "bindings/core/v8/V8DOMException.h" 9 #include "bindings/core/v8/V8DOMException.h"
10 #include "bindings/core/v8/V8DOMTokenList.h" 10 #include "bindings/core/v8/V8DOMTokenList.h"
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 else if (types[i] == "pointer") 234 else if (types[i] == "pointer")
235 outputTypes.appendVector(Vector<String>({ "pointerover", "pointerout ", "pointerenter", "pointerleave", "pointerdown", "pointerup", "pointermove", "p ointercancel", "gotpointercapture", "lostpointercapture" })); 235 outputTypes.appendVector(Vector<String>({ "pointerover", "pointerout ", "pointerenter", "pointerleave", "pointerdown", "pointerup", "pointermove", "p ointercancel", "gotpointercapture", "lostpointercapture" }));
236 else if (types[i] == "control") 236 else if (types[i] == "control")
237 outputTypes.appendVector(Vector<String>({ "resize", "scroll", "zoom" , "focus", "blur", "select", "input", "change", "submit", "reset" })); 237 outputTypes.appendVector(Vector<String>({ "resize", "scroll", "zoom" , "focus", "blur", "select", "input", "change", "submit", "reset" }));
238 else 238 else
239 outputTypes.append(types[i]); 239 outputTypes.append(types[i]);
240 } 240 }
241 return outputTypes; 241 return outputTypes;
242 } 242 }
243 243
244 void ThreadDebugger::logCallback(const v8::FunctionCallbackInfo<v8::Value>& info ) 244 namespace {
245
246 v8::MaybeLocal<v8::Value> compileAndRunInternalScript(v8::Isolate* isolate, v8:: Local<v8::Context> context, v8::Local<v8::String> code)
245 { 247 {
246 if (info.Length() < 1) 248 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));
247 return; 249 v8::ScriptCompiler::Source source(code, origin);
248 ThreadDebugger* debugger = static_cast<ThreadDebugger*>(v8::Local<v8::Extern al>::Cast(info.Data())->Value()); 250 v8::Local<v8::Script> script;
249 DCHECK(debugger); 251 if (!v8::ScriptCompiler::Compile(context, &source, v8::ScriptCompiler::kNoCo mpileOptions).ToLocal(&script))
250 Event* event = V8Event::toImplWithTypeCheck(info.GetIsolate(), info[0]); 252 return v8::MaybeLocal<v8::Value>();
251 if (!event) 253 v8::MicrotasksScope microtasksScope(isolate, v8::MicrotasksScope::kDoNotRunM icrotasks);
252 return; 254 return script->Run(context);
253 debugger->debugger()->logToConsole(info.GetIsolate()->GetCurrentContext(), v 8String(info.GetIsolate(), event->type()), info[0]);
254 } 255 }
255 256
257 } // namespace
258
256 v8::Local<v8::Function> ThreadDebugger::eventLogFunction() 259 v8::Local<v8::Function> ThreadDebugger::eventLogFunction()
dgozman 2016/07/25 19:05:51 Let's not store it, but compile every time.
kozy 2016/07/25 19:13:14 Done.
257 { 260 {
258 if (m_eventLogFunction.IsEmpty()) 261 if (m_eventLogFunction.IsEmpty()) {
259 m_eventLogFunction.Reset(m_isolate, v8::Function::New(m_isolate->GetCurr entContext(), logCallback, v8::External::New(m_isolate, this), 0, v8::Constructo rBehavior::kThrow).ToLocalChecked()); 262 v8::Local<v8::Value> logFunctionValue;
263 bool success = compileAndRunInternalScript(m_isolate, m_isolate->GetCurr entContext(), v8String(m_isolate, "(function(e) { console.log(e.type, e); })")). ToLocal(&logFunctionValue) && logFunctionValue->IsFunction();
dgozman 2016/07/25 19:05:51 As discussed offline, use V8ScriptRunner here.
kozy 2016/07/25 19:13:14 Done.
264 DCHECK(success);
265 m_eventLogFunction.Reset(m_isolate, v8::Local<v8::Function>::Cast(logFun ctionValue));
266 }
260 return m_eventLogFunction.Get(m_isolate); 267 return m_eventLogFunction.Get(m_isolate);
261 } 268 }
262 269
263 static EventTarget* firstArgumentAsEventTarget(const v8::FunctionCallbackInfo<v8 ::Value>& info) 270 static EventTarget* firstArgumentAsEventTarget(const v8::FunctionCallbackInfo<v8 ::Value>& info)
264 { 271 {
265 if (info.Length() < 1) 272 if (info.Length() < 1)
266 return nullptr; 273 return nullptr;
267 if (EventTarget* target = V8EventTarget::toImplWithTypeCheck(info.GetIsolate (), info[0])) 274 if (EventTarget* target = V8EventTarget::toImplWithTypeCheck(info.GetIsolate (), info[0]))
268 return target; 275 return target;
269 return toDOMWindow(info.GetIsolate(), info[0]); 276 return toDOMWindow(info.GetIsolate(), info[0]);
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
388 { 395 {
389 for (size_t index = 0; index < m_timers.size(); ++index) { 396 for (size_t index = 0; index < m_timers.size(); ++index) {
390 if (m_timers[index].get() == timer) { 397 if (m_timers[index].get() == timer) {
391 m_timerCallbacks[index](m_timerData[index]); 398 m_timerCallbacks[index](m_timerData[index]);
392 return; 399 return;
393 } 400 }
394 } 401 }
395 } 402 }
396 403
397 } // namespace blink 404 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698