OLD | NEW |
---|---|
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" | |
8 #include "bindings/core/v8/ScriptValue.h" | |
7 #include "bindings/core/v8/V8Binding.h" | 9 #include "bindings/core/v8/V8Binding.h" |
8 #include "bindings/core/v8/V8DOMException.h" | 10 #include "bindings/core/v8/V8DOMException.h" |
9 #include "bindings/core/v8/V8DOMTokenList.h" | 11 #include "bindings/core/v8/V8DOMTokenList.h" |
10 #include "bindings/core/v8/V8HTMLAllCollection.h" | 12 #include "bindings/core/v8/V8HTMLAllCollection.h" |
11 #include "bindings/core/v8/V8HTMLCollection.h" | 13 #include "bindings/core/v8/V8HTMLCollection.h" |
12 #include "bindings/core/v8/V8Node.h" | 14 #include "bindings/core/v8/V8Node.h" |
13 #include "bindings/core/v8/V8NodeList.h" | 15 #include "bindings/core/v8/V8NodeList.h" |
16 #include "core/inspector/ConsoleMessage.h" | |
17 #include "core/inspector/InspectorConsoleInstrumentation.h" | |
14 #include "core/inspector/InspectorDOMDebuggerAgent.h" | 18 #include "core/inspector/InspectorDOMDebuggerAgent.h" |
19 #include "core/inspector/InspectorTraceEvents.h" | |
20 #include "core/inspector/ScriptArguments.h" | |
15 #include "platform/ScriptForbiddenScope.h" | 21 #include "platform/ScriptForbiddenScope.h" |
16 #include "wtf/CurrentTime.h" | 22 #include "wtf/CurrentTime.h" |
17 | 23 |
18 namespace blink { | 24 namespace blink { |
19 | 25 |
20 ThreadDebugger::ThreadDebugger(v8::Isolate* isolate) | 26 ThreadDebugger::ThreadDebugger(v8::Isolate* isolate) |
21 : m_isolate(isolate) | 27 : m_isolate(isolate) |
22 , m_debugger(V8Debugger::create(isolate, this)) | 28 , m_debugger(V8Debugger::create(isolate, this)) |
23 { | 29 { |
24 } | 30 } |
(...skipping 30 matching lines...) Expand all Loading... | |
55 bool ThreadDebugger::isExecutionAllowed() | 61 bool ThreadDebugger::isExecutionAllowed() |
56 { | 62 { |
57 return !ScriptForbiddenScope::isScriptForbidden(); | 63 return !ScriptForbiddenScope::isScriptForbidden(); |
58 } | 64 } |
59 | 65 |
60 double ThreadDebugger::currentTimeMS() | 66 double ThreadDebugger::currentTimeMS() |
61 { | 67 { |
62 return WTF::currentTimeMS(); | 68 return WTF::currentTimeMS(); |
63 } | 69 } |
64 | 70 |
71 void ThreadDebugger::reportMessageToConsole(v8::Local<v8::Context> context, Mess ageType type, MessageLevel level, const v8::FunctionCallbackInfo<v8::Value>& arg uments, unsigned skipArgumentCount) | |
72 { | |
73 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.
| |
74 RawPtr<ScriptArguments> scriptArguments; | |
75 if (scriptState->contextIsValid()) | |
76 scriptArguments = ScriptArguments::create(scriptState, arguments, skipAr gumentCount); | |
77 String message; | |
78 if (scriptArguments) | |
79 scriptArguments->getFirstArgumentAsString(message); | |
80 | |
81 ConsoleMessage* consoleMessage = ConsoleMessage::create(ConsoleAPIMessageSou rce, level, message); | |
82 consoleMessage->setType(type); | |
83 consoleMessage->setScriptState(scriptState); | |
84 consoleMessage->setScriptArguments(scriptArguments.release()); | |
85 consoleMessage->setCallStack(ScriptCallStack::captureForConsole()); | |
86 reportMessageToConsole(context, consoleMessage); | |
87 } | |
88 | |
89 void ThreadDebugger::reportMessageToConsole(v8::Local<v8::Context> context, Mess ageType type, MessageLevel level, const String16& text) | |
90 { | |
91 ConsoleMessage* consoleMessage = ConsoleMessage::create(ConsoleAPIMessageSou rce, level, text); | |
92 consoleMessage->setType(type); | |
93 consoleMessage->setCallStack(ScriptCallStack::capture(1)); | |
94 reportMessageToConsole(context, consoleMessage); | |
95 } | |
96 | |
97 void ThreadDebugger::time(v8::Isolate* isolate, const String16& title) | |
98 { | |
99 TRACE_EVENT_COPY_ASYNC_BEGIN0("blink.console", ((String)title).utf8().data() , this); | |
100 } | |
101 | |
102 void ThreadDebugger::timeEnd(v8::Isolate* isolate, const String16& title) | |
103 { | |
104 TRACE_EVENT_COPY_ASYNC_END0("blink.console", ((String)title).utf8().data(), this); | |
105 } | |
106 | |
107 void ThreadDebugger::timeStamp(v8::Isolate* isolate, const String16& title) | |
108 { | |
109 TRACE_EVENT_INSTANT1("devtools.timeline", "TimeStamp", TRACE_EVENT_SCOPE_THR EAD, "data", InspectorTimeStampEvent::data(currentExecutionContext(isolate), tit le)); | |
110 } | |
111 | |
112 void ThreadDebugger::profile(v8::Local<v8::Context> context, const String16& tit le) | |
113 { | |
114 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.
| |
115 } | |
116 | |
117 void ThreadDebugger::profileEnd(v8::Local<v8::Context> context, const String16& title) | |
118 { | |
119 InspectorInstrumentation::consoleProfileEnd(toExecutionContext(context), tit le); | |
120 } | |
65 | 121 |
66 } // namespace blink | 122 } // namespace blink |
OLD | NEW |