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 e2681cea7cfbd41d44761944e072498eaa8b0bf9..1474fa236da070cc50e9ebac163d98b68de42cfa 100644 |
| --- a/third_party/WebKit/Source/core/inspector/ThreadDebugger.cpp |
| +++ b/third_party/WebKit/Source/core/inspector/ThreadDebugger.cpp |
| @@ -4,6 +4,8 @@ |
| #include "core/inspector/ThreadDebugger.h" |
| +#include "bindings/core/v8/ScriptCallStack.h" |
| +#include "bindings/core/v8/ScriptValue.h" |
| #include "bindings/core/v8/V8Binding.h" |
| #include "bindings/core/v8/V8DOMException.h" |
| #include "bindings/core/v8/V8DOMTokenList.h" |
| @@ -11,7 +13,10 @@ |
| #include "bindings/core/v8/V8HTMLCollection.h" |
| #include "bindings/core/v8/V8Node.h" |
| #include "bindings/core/v8/V8NodeList.h" |
| +#include "core/inspector/ConsoleMessage.h" |
| #include "core/inspector/InspectorDOMDebuggerAgent.h" |
| +#include "core/inspector/InspectorTraceEvents.h" |
| +#include "core/inspector/ScriptArguments.h" |
| #include "platform/ScriptForbiddenScope.h" |
| #include "wtf/CurrentTime.h" |
| @@ -62,5 +67,45 @@ double ThreadDebugger::currentTimeMS() |
| return WTF::currentTimeMS(); |
| } |
| +void ThreadDebugger::reportMessageToConsole(v8::Local<v8::Context> context, MessageType type, MessageLevel level, const v8::FunctionCallbackInfo<v8::Value>& arguments, unsigned skipArgumentCount) |
| +{ |
| + ScriptState* scriptState = ScriptState::from(context); |
| + RawPtr<ScriptArguments> scriptArguments; |
| + if (scriptState->contextIsValid()) |
| + scriptArguments = ScriptArguments::create(scriptState, arguments, skipArgumentCount); |
| + String message; |
| + if (scriptArguments) |
| + scriptArguments->getFirstArgumentAsString(message); |
| + |
| + ConsoleMessage* consoleMessage = ConsoleMessage::create(ConsoleAPIMessageSource, level, message); |
| + consoleMessage->setType(type); |
| + consoleMessage->setScriptState(scriptState); |
| + consoleMessage->setScriptArguments(scriptArguments.release()); |
| + consoleMessage->setCallStack(ScriptCallStack::captureForConsole()); |
| + reportMessageToConsole(context, consoleMessage); |
| +} |
| + |
| +void ThreadDebugger::reportMessageToConsole(v8::Local<v8::Context> context, MessageType type, MessageLevel level, const String16& text) |
| +{ |
| + ConsoleMessage* consoleMessage = ConsoleMessage::create(ConsoleAPIMessageSource, level, text); |
| + consoleMessage->setType(type); |
| + consoleMessage->setCallStack(ScriptCallStack::capture(1)); |
|
dgozman
2016/04/12 03:32:15
consoleMessage->setScriptState(scriptState);
kozy
2016/04/12 21:58:32
Done.
|
| + reportMessageToConsole(context, consoleMessage); |
| +} |
| + |
| +void ThreadDebugger::consoleTime(v8::Isolate* isolate, const String16& title) |
| +{ |
| + TRACE_EVENT_COPY_ASYNC_BEGIN0("blink.console", ((String)title).utf8().data(), this); |
|
dgozman
2016/04/12 03:32:15
String(title).utf8().data()
kozy
2016/04/12 21:58:32
Done.
|
| +} |
| + |
| +void ThreadDebugger::consoleTimeEnd(v8::Isolate* isolate, const String16& title) |
| +{ |
| + TRACE_EVENT_COPY_ASYNC_END0("blink.console", ((String)title).utf8().data(), this); |
|
dgozman
2016/04/12 03:32:15
ditto
kozy
2016/04/12 21:58:32
Done.
|
| +} |
| + |
| +void ThreadDebugger::consoleTimeStamp(v8::Isolate* isolate, const String16& title) |
| +{ |
| + TRACE_EVENT_INSTANT1("devtools.timeline", "TimeStamp", TRACE_EVENT_SCOPE_THREAD, "data", InspectorTimeStampEvent::data(currentExecutionContext(isolate), title)); |
| +} |
| } // namespace blink |