OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2011 Google Inc. All rights reserved. | 2 * Copyright (c) 2011 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 s_instance = this; | 90 s_instance = this; |
91 } | 91 } |
92 | 92 |
93 MainThreadDebugger::~MainThreadDebugger() | 93 MainThreadDebugger::~MainThreadDebugger() |
94 { | 94 { |
95 MutexLocker locker(creationMutex()); | 95 MutexLocker locker(creationMutex()); |
96 ASSERT(s_instance == this); | 96 ASSERT(s_instance == this); |
97 s_instance = nullptr; | 97 s_instance = nullptr; |
98 } | 98 } |
99 | 99 |
| 100 void MainThreadDebugger::reportConsoleMessage(ExecutionContext* context, Console
Message* message) |
| 101 { |
| 102 if (!context) |
| 103 return; |
| 104 LocalFrame* frame = nullptr; |
| 105 if (context->isDocument()) |
| 106 frame = toDocument(context)->frame(); |
| 107 if (context->isMainThreadWorkletGlobalScope()) |
| 108 frame = toMainThreadWorkletGlobalScope(context)->frame(); |
| 109 if (frame) |
| 110 frame->console().reportMessageToClient(message); |
| 111 } |
| 112 |
100 void MainThreadDebugger::setClientMessageLoop(std::unique_ptr<ClientMessageLoop>
clientMessageLoop) | 113 void MainThreadDebugger::setClientMessageLoop(std::unique_ptr<ClientMessageLoop>
clientMessageLoop) |
101 { | 114 { |
102 ASSERT(!m_clientMessageLoop); | 115 ASSERT(!m_clientMessageLoop); |
103 ASSERT(clientMessageLoop); | 116 ASSERT(clientMessageLoop); |
104 m_clientMessageLoop = std::move(clientMessageLoop); | 117 m_clientMessageLoop = std::move(clientMessageLoop); |
105 } | 118 } |
106 | 119 |
107 void MainThreadDebugger::didClearContextsForFrame(LocalFrame* frame) | 120 void MainThreadDebugger::didClearContextsForFrame(LocalFrame* frame) |
108 { | 121 { |
109 DCHECK(isMainThread()); | 122 DCHECK(isMainThread()); |
(...skipping 13 matching lines...) Expand all Loading... |
123 { | 136 { |
124 v8::HandleScope handles(scriptState->isolate()); | 137 v8::HandleScope handles(scriptState->isolate()); |
125 debugger()->contextDestroyed(scriptState->context()); | 138 debugger()->contextDestroyed(scriptState->context()); |
126 } | 139 } |
127 | 140 |
128 void MainThreadDebugger::exceptionThrown(LocalFrame* frame, const String& errorM
essage, std::unique_ptr<SourceLocation> location) | 141 void MainThreadDebugger::exceptionThrown(LocalFrame* frame, const String& errorM
essage, std::unique_ptr<SourceLocation> location) |
129 { | 142 { |
130 if (m_muteConsoleCount) | 143 if (m_muteConsoleCount) |
131 return; | 144 return; |
132 debugger()->exceptionThrown(contextGroupId(frame), errorMessage, location->u
rl(), location->lineNumber(), location->columnNumber(), location->cloneStackTrac
e(), location->scriptId()); | 145 debugger()->exceptionThrown(contextGroupId(frame), errorMessage, location->u
rl(), location->lineNumber(), location->columnNumber(), location->cloneStackTrac
e(), location->scriptId()); |
| 146 frame->console().reportMessageToClient(ConsoleMessage::create(JSMessageSourc
e, ErrorMessageLevel, errorMessage, std::move(location))); |
133 } | 147 } |
134 | 148 |
135 bool MainThreadDebugger::addConsoleMessage(LocalFrame* frame, ConsoleMessage* co
nsoleMessage) | 149 bool MainThreadDebugger::addConsoleMessage(LocalFrame* frame, ConsoleMessage* co
nsoleMessage) |
136 { | 150 { |
137 if (m_muteConsoleCount) | 151 if (m_muteConsoleCount) |
138 return false; | 152 return false; |
139 debugger()->addConsoleMessage( | 153 debugger()->addConsoleMessage( |
140 contextGroupId(frame), | 154 contextGroupId(frame), |
141 consoleMessage->source(), | 155 consoleMessage->source(), |
142 consoleMessage->level(), | 156 consoleMessage->level(), |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 return BindingSecurity::shouldAllowAccessTo(m_isolate, calling, target, DoNo
tReportSecurityError); | 228 return BindingSecurity::shouldAllowAccessTo(m_isolate, calling, target, DoNo
tReportSecurityError); |
215 } | 229 } |
216 | 230 |
217 v8::Local<v8::Context> MainThreadDebugger::ensureDefaultContextInGroup(int conte
xtGroupId) | 231 v8::Local<v8::Context> MainThreadDebugger::ensureDefaultContextInGroup(int conte
xtGroupId) |
218 { | 232 { |
219 LocalFrame* frame = WeakIdentifierMap<LocalFrame>::lookup(contextGroupId); | 233 LocalFrame* frame = WeakIdentifierMap<LocalFrame>::lookup(contextGroupId); |
220 ScriptState* scriptState = frame ? ScriptState::forMainWorld(frame) : nullpt
r; | 234 ScriptState* scriptState = frame ? ScriptState::forMainWorld(frame) : nullpt
r; |
221 return scriptState ? scriptState->context() : v8::Local<v8::Context>(); | 235 return scriptState ? scriptState->context() : v8::Local<v8::Context>(); |
222 } | 236 } |
223 | 237 |
224 void MainThreadDebugger::messageAddedToConsole(int contextGroupId, MessageSource
source, MessageLevel level, const String16& message, const String16& url, unsig
ned lineNumber, unsigned columnNumber, V8StackTrace* stackTrace) | 238 void MainThreadDebugger::consoleAPIMessage(int contextGroupId, MessageLevel leve
l, const String16& message, const String16& url, unsigned lineNumber, unsigned c
olumnNumber, V8StackTrace* stackTrace) |
225 { | 239 { |
226 LocalFrame* frame = WeakIdentifierMap<LocalFrame>::lookup(contextGroupId); | 240 LocalFrame* frame = WeakIdentifierMap<LocalFrame>::lookup(contextGroupId); |
227 if (!frame) | 241 if (!frame) |
228 return; | 242 return; |
229 ConsoleMessage* consoleMessage = ConsoleMessage::create(source, level, messa
ge, SourceLocation::create(url, lineNumber, columnNumber, stackTrace ? stackTrac
e->clone() : nullptr, 0)); | 243 // TODO(dgozman): maybe not wrap with ConsoleMessage. |
| 244 ConsoleMessage* consoleMessage = ConsoleMessage::create(ConsoleAPIMessageSou
rce, level, message, SourceLocation::create(url, lineNumber, columnNumber, stack
Trace ? stackTrace->clone() : nullptr, 0)); |
230 frame->console().reportMessageToClient(consoleMessage); | 245 frame->console().reportMessageToClient(consoleMessage); |
231 } | 246 } |
232 | 247 |
233 v8::MaybeLocal<v8::Value> MainThreadDebugger::memoryInfo(v8::Isolate* isolate, v
8::Local<v8::Context> context) | 248 v8::MaybeLocal<v8::Value> MainThreadDebugger::memoryInfo(v8::Isolate* isolate, v
8::Local<v8::Context> context) |
234 { | 249 { |
235 ExecutionContext* executionContext = toExecutionContext(context); | 250 ExecutionContext* executionContext = toExecutionContext(context); |
236 ASSERT_UNUSED(executionContext, executionContext); | 251 ASSERT_UNUSED(executionContext, executionContext); |
237 ASSERT(executionContext->isDocument()); | 252 ASSERT(executionContext->isDocument()); |
238 return toV8(MemoryInfo::create(), context->Global(), isolate); | 253 return toV8(MemoryInfo::create(), context->Global(), isolate); |
239 } | 254 } |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
335 return; | 350 return; |
336 if (!nodes->Set(context, index++, toV8(node, info.Holder(), info.Get
Isolate())).FromMaybe(false)) | 351 if (!nodes->Set(context, index++, toV8(node, info.Holder(), info.Get
Isolate())).FromMaybe(false)) |
337 return; | 352 return; |
338 } | 353 } |
339 info.GetReturnValue().Set(nodes); | 354 info.GetReturnValue().Set(nodes); |
340 } | 355 } |
341 exceptionState.throwIfNeeded(); | 356 exceptionState.throwIfNeeded(); |
342 } | 357 } |
343 | 358 |
344 } // namespace blink | 359 } // namespace blink |
OLD | NEW |