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/ScriptValue.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" |
11 #include "bindings/core/v8/V8Event.h" | 11 #include "bindings/core/v8/V8Event.h" |
12 #include "bindings/core/v8/V8EventListener.h" | 12 #include "bindings/core/v8/V8EventListener.h" |
13 #include "bindings/core/v8/V8EventListenerInfo.h" | 13 #include "bindings/core/v8/V8EventListenerInfo.h" |
14 #include "bindings/core/v8/V8EventListenerList.h" | 14 #include "bindings/core/v8/V8EventListenerList.h" |
15 #include "bindings/core/v8/V8HTMLAllCollection.h" | 15 #include "bindings/core/v8/V8HTMLAllCollection.h" |
16 #include "bindings/core/v8/V8HTMLCollection.h" | 16 #include "bindings/core/v8/V8HTMLCollection.h" |
17 #include "bindings/core/v8/V8Node.h" | 17 #include "bindings/core/v8/V8Node.h" |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 if (m_asyncInstrumentationEnabled) | 93 if (m_asyncInstrumentationEnabled) |
94 m_debugger->asyncTaskStarted(task); | 94 m_debugger->asyncTaskStarted(task); |
95 } | 95 } |
96 | 96 |
97 void ThreadDebugger::asyncTaskFinished(void* task) | 97 void ThreadDebugger::asyncTaskFinished(void* task) |
98 { | 98 { |
99 if (m_asyncInstrumentationEnabled) | 99 if (m_asyncInstrumentationEnabled) |
100 m_debugger->asyncTaskFinished(task); | 100 m_debugger->asyncTaskFinished(task); |
101 } | 101 } |
102 | 102 |
| 103 unsigned ThreadDebugger::promiseRejected(v8::Local<v8::Context> context, const S
tring16& errorMessage, v8::Local<v8::Value> exception, std::unique_ptr<SourceLoc
ation> location) |
| 104 { |
| 105 const String16 defaultMessage = "Uncaught (in promise)"; |
| 106 String16 message = errorMessage; |
| 107 if (message.isEmpty()) |
| 108 message = defaultMessage; |
| 109 else if (message.startWith("Uncaught ")) |
| 110 message = message.substring(0, 8) + " (in promise)" + message.substring(
8); |
| 111 |
| 112 unsigned result = debugger()->promiseRejected(context, message, exception, l
ocation->url(), location->lineNumber(), location->columnNumber(), location->clon
eStackTrace(), location->scriptId()); |
| 113 // TODO(dgozman): maybe not wrap in ConsoleMessage. |
| 114 reportConsoleMessage(toExecutionContext(context), ConsoleMessage::create(JSM
essageSource, ErrorMessageLevel, message, std::move(location))); |
| 115 return result; |
| 116 } |
| 117 |
103 void ThreadDebugger::beginUserGesture() | 118 void ThreadDebugger::beginUserGesture() |
104 { | 119 { |
105 m_userGestureIndicator = wrapUnique(new UserGestureIndicator(DefinitelyProce
ssingNewUserGesture)); | 120 m_userGestureIndicator = wrapUnique(new UserGestureIndicator(DefinitelyProce
ssingNewUserGesture)); |
106 } | 121 } |
107 | 122 |
108 void ThreadDebugger::endUserGesture() | 123 void ThreadDebugger::endUserGesture() |
109 { | 124 { |
110 m_userGestureIndicator.reset(); | 125 m_userGestureIndicator.reset(); |
111 } | 126 } |
112 | 127 |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
228 | 243 |
229 void ThreadDebugger::logCallback(const v8::FunctionCallbackInfo<v8::Value>& info
) | 244 void ThreadDebugger::logCallback(const v8::FunctionCallbackInfo<v8::Value>& info
) |
230 { | 245 { |
231 if (info.Length() < 1) | 246 if (info.Length() < 1) |
232 return; | 247 return; |
233 ThreadDebugger* debugger = static_cast<ThreadDebugger*>(v8::Local<v8::Extern
al>::Cast(info.Data())->Value()); | 248 ThreadDebugger* debugger = static_cast<ThreadDebugger*>(v8::Local<v8::Extern
al>::Cast(info.Data())->Value()); |
234 DCHECK(debugger); | 249 DCHECK(debugger); |
235 Event* event = V8Event::toImplWithTypeCheck(info.GetIsolate(), info[0]); | 250 Event* event = V8Event::toImplWithTypeCheck(info.GetIsolate(), info[0]); |
236 if (!event) | 251 if (!event) |
237 return; | 252 return; |
238 debugger->debugger()->logToConsole(info.GetIsolate()->GetCurrentContext(), e
vent->type(), v8String(info.GetIsolate(), event->type()), info[0]); | 253 debugger->debugger()->logToConsole(info.GetIsolate()->GetCurrentContext(), v
8String(info.GetIsolate(), event->type()), info[0]); |
239 } | 254 } |
240 | 255 |
241 v8::Local<v8::Function> ThreadDebugger::eventLogFunction() | 256 v8::Local<v8::Function> ThreadDebugger::eventLogFunction() |
242 { | 257 { |
243 if (m_eventLogFunction.IsEmpty()) | 258 if (m_eventLogFunction.IsEmpty()) |
244 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()); | 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()); |
245 return m_eventLogFunction.Get(m_isolate); | 260 return m_eventLogFunction.Get(m_isolate); |
246 } | 261 } |
247 | 262 |
248 static EventTarget* firstArgumentAsEventTarget(const v8::FunctionCallbackInfo<v8
::Value>& info) | 263 static EventTarget* firstArgumentAsEventTarget(const v8::FunctionCallbackInfo<v8
::Value>& info) |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
370 { | 385 { |
371 for (size_t index = 0; index < m_timers.size(); ++index) { | 386 for (size_t index = 0; index < m_timers.size(); ++index) { |
372 if (m_timers[index].get() == timer) { | 387 if (m_timers[index].get() == timer) { |
373 m_timerCallbacks[index](m_timerData[index]); | 388 m_timerCallbacks[index](m_timerData[index]); |
374 return; | 389 return; |
375 } | 390 } |
376 } | 391 } |
377 } | 392 } |
378 | 393 |
379 } // namespace blink | 394 } // namespace blink |
OLD | NEW |