| 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" | 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 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 if (object->InternalFieldCount() < v8DefaultWrapperInternalFieldCount) | 110 if (object->InternalFieldCount() < v8DefaultWrapperInternalFieldCount) |
| 111 return true; | 111 return true; |
| 112 v8::Local<v8::Value> wrapper = object->GetInternalField(v8DOMWrapperObjectIn
dex); | 112 v8::Local<v8::Value> wrapper = object->GetInternalField(v8DOMWrapperObjectIn
dex); |
| 113 // Skip wrapper boilerplates which are like regular wrappers but don't have | 113 // Skip wrapper boilerplates which are like regular wrappers but don't have |
| 114 // native object. | 114 // native object. |
| 115 if (!wrapper.IsEmpty() && wrapper->IsUndefined()) | 115 if (!wrapper.IsEmpty() && wrapper->IsUndefined()) |
| 116 return false; | 116 return false; |
| 117 return true; | 117 return true; |
| 118 } | 118 } |
| 119 | 119 |
| 120 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, int maxStackSize) | 120 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) |
| 121 { | 121 { |
| 122 ScriptState* scriptState = ScriptState::from(context); | 122 ScriptState* scriptState = ScriptState::from(context); |
| 123 ScriptArguments* scriptArguments = nullptr; | 123 ScriptArguments* scriptArguments = nullptr; |
| 124 if (arguments && scriptState->contextIsValid()) | 124 if (arguments && scriptState->contextIsValid()) |
| 125 scriptArguments = ScriptArguments::create(scriptState, *arguments, skipA
rgumentCount); | 125 scriptArguments = ScriptArguments::create(scriptState, *arguments, skipA
rgumentCount); |
| 126 String messageText = message; | 126 String messageText = message; |
| 127 if (messageText.isEmpty() && scriptArguments) | 127 if (messageText.isEmpty() && scriptArguments) |
| 128 scriptArguments->getFirstArgumentAsString(messageText); | 128 scriptArguments->getFirstArgumentAsString(messageText); |
| 129 | 129 |
| 130 ConsoleMessage* consoleMessage = ConsoleMessage::create(ConsoleAPIMessageSou
rce, level, messageText); | 130 ConsoleMessage* consoleMessage = ConsoleMessage::create(ConsoleAPIMessageSou
rce, level, messageText); |
| 131 consoleMessage->setType(type); | 131 consoleMessage->setType(type); |
| 132 consoleMessage->setScriptState(scriptState); | 132 consoleMessage->setScriptState(scriptState); |
| 133 if (arguments) | 133 if (arguments) |
| 134 consoleMessage->setScriptArguments(scriptArguments); | 134 consoleMessage->setScriptArguments(scriptArguments); |
| 135 if (maxStackSize == -1) | |
| 136 consoleMessage->setCallStack(ScriptCallStack::captureForConsole()); | |
| 137 else if (maxStackSize) | |
| 138 consoleMessage->setCallStack(ScriptCallStack::capture(maxStackSize)); | |
| 139 reportMessageToConsole(context, consoleMessage); | 135 reportMessageToConsole(context, consoleMessage); |
| 140 } | 136 } |
| 141 | 137 |
| 142 void ThreadDebugger::consoleTime(const String16& title) | 138 void ThreadDebugger::consoleTime(const String16& title) |
| 143 { | 139 { |
| 144 TRACE_EVENT_COPY_ASYNC_BEGIN0("blink.console", String(title).utf8().data(),
this); | 140 TRACE_EVENT_COPY_ASYNC_BEGIN0("blink.console", String(title).utf8().data(),
this); |
| 145 } | 141 } |
| 146 | 142 |
| 147 void ThreadDebugger::consoleTimeEnd(const String16& title) | 143 void ThreadDebugger::consoleTimeEnd(const String16& title) |
| 148 { | 144 { |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 { | 179 { |
| 184 for (size_t index = 0; index < m_timers.size(); ++index) { | 180 for (size_t index = 0; index < m_timers.size(); ++index) { |
| 185 if (m_timers[index] == timer) { | 181 if (m_timers[index] == timer) { |
| 186 m_timerCallbacks[index](m_timerData[index]); | 182 m_timerCallbacks[index](m_timerData[index]); |
| 187 return; | 183 return; |
| 188 } | 184 } |
| 189 } | 185 } |
| 190 } | 186 } |
| 191 | 187 |
| 192 } // namespace blink | 188 } // namespace blink |
| OLD | NEW |