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

Unified Diff: third_party/WebKit/Source/core/inspector/ThreadDebugger.cpp

Issue 1859293002: [DevTools] Move Console to v8_inspector (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 side-by-side diff with in-line comments
Download patch
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..b9c95005f46ac2600aaf9cee3d3ef1a4bf9ff3e4 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,11 @@
#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/InspectorConsoleInstrumentation.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 +68,55 @@ 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::current(context->GetIsolate());
dgozman 2016/04/08 18:18:46 ScriptState::from(context) or something.
kozy 2016/04/08 23:56:50 Done.
+ 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));
+ reportMessageToConsole(context, consoleMessage);
+}
+
+void ThreadDebugger::time(v8::Isolate* isolate, const String16& title)
+{
+ TRACE_EVENT_COPY_ASYNC_BEGIN0("blink.console", ((String)title).utf8().data(), this);
+}
+
+void ThreadDebugger::timeEnd(v8::Isolate* isolate, const String16& title)
+{
+ TRACE_EVENT_COPY_ASYNC_END0("blink.console", ((String)title).utf8().data(), this);
+}
+
+void ThreadDebugger::timeStamp(v8::Isolate* isolate, const String16& title)
+{
+ TRACE_EVENT_INSTANT1("devtools.timeline", "TimeStamp", TRACE_EVENT_SCOPE_THREAD, "data", InspectorTimeStampEvent::data(currentExecutionContext(isolate), title));
+}
+
+void ThreadDebugger::profile(v8::Local<v8::Context> context, const String16& title)
+{
+ InspectorInstrumentation::consoleProfile(toExecutionContext(context), title);
dgozman 2016/04/08 18:18:46 This could be done entirely in v8_inspector. Remov
kozy 2016/04/08 23:56:50 Done.
+}
+
+void ThreadDebugger::profileEnd(v8::Local<v8::Context> context, const String16& title)
+{
+ InspectorInstrumentation::consoleProfileEnd(toExecutionContext(context), title);
+}
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698