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

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

Issue 1998353003: Reduce ConsoleMessage API surface. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@1999463002
Patch Set: rebased Created 4 years, 7 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/ScriptCallStack.h" 7 #include "bindings/core/v8/ScriptCallStack.h"
8 #include "bindings/core/v8/ScriptValue.h" 8 #include "bindings/core/v8/ScriptValue.h"
9 #include "bindings/core/v8/V8Binding.h" 9 #include "bindings/core/v8/V8Binding.h"
10 #include "bindings/core/v8/V8DOMException.h" 10 #include "bindings/core/v8/V8DOMException.h"
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 return; 200 return;
201 201
202 v8::Local<v8::Context> context = info.GetIsolate()->GetCurrentContext(); 202 v8::Local<v8::Context> context = info.GetIsolate()->GetCurrentContext();
203 ScriptState* scriptState = ScriptState::from(context); 203 ScriptState* scriptState = ScriptState::from(context);
204 DCHECK(scriptState->contextIsValid()); 204 DCHECK(scriptState->contextIsValid());
205 Vector<ScriptValue> arguments = Vector<ScriptValue>({ 205 Vector<ScriptValue> arguments = Vector<ScriptValue>({
206 ScriptValue(scriptState, v8String(info.GetIsolate(), event->type())), 206 ScriptValue(scriptState, v8String(info.GetIsolate(), event->type())),
207 ScriptValue(scriptState, info[0]) 207 ScriptValue(scriptState, info[0])
208 }); 208 });
209 209
210 ConsoleMessage* consoleMessage = ConsoleMessage::create(ConsoleAPIMessageSou rce, LogMessageLevel, event->type()); 210 ConsoleMessage* consoleMessage = ConsoleMessage::createForConsoleAPI(LogMess ageLevel, LogMessageType, event->type(), ScriptArguments::create(scriptState, ar guments));
211 consoleMessage->setType(LogMessageType);
212 consoleMessage->setScriptState(scriptState);
213 consoleMessage->setScriptArguments(ScriptArguments::create(scriptState, argu ments));
214 debugger->reportMessageToConsole(context, consoleMessage); 211 debugger->reportMessageToConsole(context, consoleMessage);
215 } 212 }
216 213
217 v8::Local<v8::Function> ThreadDebugger::eventLogFunction() 214 v8::Local<v8::Function> ThreadDebugger::eventLogFunction()
218 { 215 {
219 if (m_eventLogFunction.IsEmpty()) 216 if (m_eventLogFunction.IsEmpty())
220 m_eventLogFunction.Reset(m_isolate, v8::Function::New(m_isolate, logCall back, v8::External::New(m_isolate, this))); 217 m_eventLogFunction.Reset(m_isolate, v8::Function::New(m_isolate, logCall back, v8::External::New(m_isolate, this)));
221 return m_eventLogFunction.Get(m_isolate); 218 return m_eventLogFunction.Get(m_isolate);
222 } 219 }
223 220
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
338 void ThreadDebugger::reportMessageToConsole(v8::Local<v8::Context> context, Mess ageType type, MessageLevel level, const String16& message, const v8::FunctionCal lbackInfo<v8::Value>* arguments, unsigned skipArgumentCount) 335 void ThreadDebugger::reportMessageToConsole(v8::Local<v8::Context> context, Mess ageType type, MessageLevel level, const String16& message, const v8::FunctionCal lbackInfo<v8::Value>* arguments, unsigned skipArgumentCount)
339 { 336 {
340 ScriptState* scriptState = ScriptState::from(context); 337 ScriptState* scriptState = ScriptState::from(context);
341 ScriptArguments* scriptArguments = nullptr; 338 ScriptArguments* scriptArguments = nullptr;
342 if (arguments && scriptState->contextIsValid()) 339 if (arguments && scriptState->contextIsValid())
343 scriptArguments = ScriptArguments::create(scriptState, *arguments, skipA rgumentCount); 340 scriptArguments = ScriptArguments::create(scriptState, *arguments, skipA rgumentCount);
344 String messageText = message; 341 String messageText = message;
345 if (messageText.isEmpty() && scriptArguments) 342 if (messageText.isEmpty() && scriptArguments)
346 scriptArguments->getFirstArgumentAsString(messageText); 343 scriptArguments->getFirstArgumentAsString(messageText);
347 344
348 ConsoleMessage* consoleMessage = ConsoleMessage::create(ConsoleAPIMessageSou rce, level, messageText); 345 reportMessageToConsole(context, ConsoleMessage::createForConsoleAPI(level, t ype, messageText, scriptArguments));
349 consoleMessage->setType(type);
350 consoleMessage->setScriptState(scriptState);
351 if (arguments)
352 consoleMessage->setScriptArguments(scriptArguments);
353 reportMessageToConsole(context, consoleMessage);
354 } 346 }
355 347
356 void ThreadDebugger::consoleTime(const String16& title) 348 void ThreadDebugger::consoleTime(const String16& title)
357 { 349 {
358 TRACE_EVENT_COPY_ASYNC_BEGIN0("blink.console", String(title).utf8().data(), this); 350 TRACE_EVENT_COPY_ASYNC_BEGIN0("blink.console", String(title).utf8().data(), this);
359 } 351 }
360 352
361 void ThreadDebugger::consoleTimeEnd(const String16& title) 353 void ThreadDebugger::consoleTimeEnd(const String16& title)
362 { 354 {
363 TRACE_EVENT_COPY_ASYNC_END0("blink.console", String(title).utf8().data(), th is); 355 TRACE_EVENT_COPY_ASYNC_END0("blink.console", String(title).utf8().data(), th is);
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
397 { 389 {
398 for (size_t index = 0; index < m_timers.size(); ++index) { 390 for (size_t index = 0; index < m_timers.size(); ++index) {
399 if (m_timers[index] == timer) { 391 if (m_timers[index] == timer) {
400 m_timerCallbacks[index](m_timerData[index]); 392 m_timerCallbacks[index](m_timerData[index]);
401 return; 393 return;
402 } 394 }
403 } 395 }
404 } 396 }
405 397
406 } // namespace blink 398 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698