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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 #include "core/inspector/ConsoleMessage.h" | 53 #include "core/inspector/ConsoleMessage.h" |
54 #include "core/inspector/ConsoleMessageStorage.h" | 54 #include "core/inspector/ConsoleMessageStorage.h" |
55 #include "core/inspector/IdentifiersFactory.h" | 55 #include "core/inspector/IdentifiersFactory.h" |
56 #include "core/inspector/InspectedFrames.h" | 56 #include "core/inspector/InspectedFrames.h" |
57 #include "core/inspector/InspectorTaskRunner.h" | 57 #include "core/inspector/InspectorTaskRunner.h" |
58 #include "core/timing/MemoryInfo.h" | 58 #include "core/timing/MemoryInfo.h" |
59 #include "core/workers/MainThreadWorkletGlobalScope.h" | 59 #include "core/workers/MainThreadWorkletGlobalScope.h" |
60 #include "core/xml/XPathEvaluator.h" | 60 #include "core/xml/XPathEvaluator.h" |
61 #include "core/xml/XPathResult.h" | 61 #include "core/xml/XPathResult.h" |
62 #include "platform/UserGestureIndicator.h" | 62 #include "platform/UserGestureIndicator.h" |
63 #include "platform/v8_inspector/public/V8Debugger.h" | 63 #include "platform/v8_inspector/public/V8Inspector.h" |
64 #include "wtf/PtrUtil.h" | 64 #include "wtf/PtrUtil.h" |
65 #include "wtf/ThreadingPrimitives.h" | 65 #include "wtf/ThreadingPrimitives.h" |
66 #include <memory> | 66 #include <memory> |
67 | 67 |
68 namespace blink { | 68 namespace blink { |
69 | 69 |
70 namespace { | 70 namespace { |
71 | 71 |
72 int frameId(LocalFrame* frame) | 72 int frameId(LocalFrame* frame) |
73 { | 73 { |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 { | 129 { |
130 ASSERT(!m_clientMessageLoop); | 130 ASSERT(!m_clientMessageLoop); |
131 ASSERT(clientMessageLoop); | 131 ASSERT(clientMessageLoop); |
132 m_clientMessageLoop = std::move(clientMessageLoop); | 132 m_clientMessageLoop = std::move(clientMessageLoop); |
133 } | 133 } |
134 | 134 |
135 void MainThreadDebugger::didClearContextsForFrame(LocalFrame* frame) | 135 void MainThreadDebugger::didClearContextsForFrame(LocalFrame* frame) |
136 { | 136 { |
137 DCHECK(isMainThread()); | 137 DCHECK(isMainThread()); |
138 if (frame->localFrameRoot() == frame) | 138 if (frame->localFrameRoot() == frame) |
139 debugger()->resetContextGroup(contextGroupId(frame)); | 139 v8Inspector()->resetContextGroup(contextGroupId(frame)); |
140 } | 140 } |
141 | 141 |
142 void MainThreadDebugger::contextCreated(ScriptState* scriptState, LocalFrame* fr
ame, SecurityOrigin* origin) | 142 void MainThreadDebugger::contextCreated(ScriptState* scriptState, LocalFrame* fr
ame, SecurityOrigin* origin) |
143 { | 143 { |
144 ASSERT(isMainThread()); | 144 ASSERT(isMainThread()); |
145 v8::HandleScope handles(scriptState->isolate()); | 145 v8::HandleScope handles(scriptState->isolate()); |
146 DOMWrapperWorld& world = scriptState->world(); | 146 DOMWrapperWorld& world = scriptState->world(); |
147 debugger()->contextCreated(V8ContextInfo(scriptState->context(), contextGrou
pId(frame), world.isMainWorld(), origin ? origin->toRawString() : "", world.isIs
olatedWorld() ? world.isolatedWorldHumanReadableName() : "", IdentifiersFactory:
:frameId(frame), scriptState->getExecutionContext()->isDocument())); | 147 v8Inspector()->contextCreated(V8ContextInfo(scriptState->context(), contextG
roupId(frame), world.isMainWorld(), origin ? origin->toRawString() : "", world.i
sIsolatedWorld() ? world.isolatedWorldHumanReadableName() : "", IdentifiersFacto
ry::frameId(frame), scriptState->getExecutionContext()->isDocument())); |
148 } | 148 } |
149 | 149 |
150 void MainThreadDebugger::contextWillBeDestroyed(ScriptState* scriptState) | 150 void MainThreadDebugger::contextWillBeDestroyed(ScriptState* scriptState) |
151 { | 151 { |
152 v8::HandleScope handles(scriptState->isolate()); | 152 v8::HandleScope handles(scriptState->isolate()); |
153 debugger()->contextDestroyed(scriptState->context()); | 153 v8Inspector()->contextDestroyed(scriptState->context()); |
154 } | 154 } |
155 | 155 |
156 void MainThreadDebugger::exceptionThrown(ExecutionContext* context, ErrorEvent*
event) | 156 void MainThreadDebugger::exceptionThrown(ExecutionContext* context, ErrorEvent*
event) |
157 { | 157 { |
158 LocalFrame* frame = nullptr; | 158 LocalFrame* frame = nullptr; |
159 ScriptState* scriptState = nullptr; | 159 ScriptState* scriptState = nullptr; |
160 if (context->isDocument()) { | 160 if (context->isDocument()) { |
161 frame = toDocument(context)->frame(); | 161 frame = toDocument(context)->frame(); |
162 scriptState = event->world() ? ScriptState::forWorld(frame, *event->worl
d()) : nullptr; | 162 scriptState = event->world() ? ScriptState::forWorld(frame, *event->worl
d()) : nullptr; |
163 } | 163 } |
164 if (context->isMainThreadWorkletGlobalScope()) { | 164 if (context->isMainThreadWorkletGlobalScope()) { |
165 frame = toMainThreadWorkletGlobalScope(context)->frame(); | 165 frame = toMainThreadWorkletGlobalScope(context)->frame(); |
166 scriptState = toMainThreadWorkletGlobalScope(context)->scriptController(
)->getScriptState(); | 166 scriptState = toMainThreadWorkletGlobalScope(context)->scriptController(
)->getScriptState(); |
167 } | 167 } |
168 | 168 |
169 if (frame->host() && frame->host()->consoleMessageStorage().isMuted()) | 169 if (frame->host() && frame->host()->consoleMessageStorage().isMuted()) |
170 return; | 170 return; |
171 | 171 |
172 const String16 defaultMessage = "Uncaught"; | 172 const String16 defaultMessage = "Uncaught"; |
173 if (scriptState && scriptState->contextIsValid()) { | 173 if (scriptState && scriptState->contextIsValid()) { |
174 ScriptState::Scope scope(scriptState); | 174 ScriptState::Scope scope(scriptState); |
175 v8::Local<v8::Value> exception = V8ErrorHandler::loadExceptionFromErrorE
ventWrapper(scriptState, event, scriptState->context()->Global()); | 175 v8::Local<v8::Value> exception = V8ErrorHandler::loadExceptionFromErrorE
ventWrapper(scriptState, event, scriptState->context()->Global()); |
176 SourceLocation* location = event->location(); | 176 SourceLocation* location = event->location(); |
177 debugger()->exceptionThrown(scriptState->context(), defaultMessage, exce
ption, event->messageForConsole(), location->url(), location->lineNumber(), loca
tion->columnNumber(), location->cloneStackTrace(), location->scriptId()); | 177 v8Inspector()->exceptionThrown(scriptState->context(), defaultMessage, e
xception, event->messageForConsole(), location->url(), location->lineNumber(), l
ocation->columnNumber(), location->cloneStackTrace(), location->scriptId()); |
178 } | 178 } |
179 | 179 |
180 // TODO(dgozman): do not wrap in ConsoleMessage. | 180 // TODO(dgozman): do not wrap in ConsoleMessage. |
181 frame->console().reportMessageToClient(ConsoleMessage::create(JSMessageSourc
e, ErrorMessageLevel, event->messageForConsole(), event->location()->clone())); | 181 frame->console().reportMessageToClient(ConsoleMessage::create(JSMessageSourc
e, ErrorMessageLevel, event->messageForConsole(), event->location()->clone())); |
182 } | 182 } |
183 | 183 |
184 int MainThreadDebugger::contextGroupId(LocalFrame* frame) | 184 int MainThreadDebugger::contextGroupId(LocalFrame* frame) |
185 { | 185 { |
186 LocalFrame* localFrameRoot = frame->localFrameRoot(); | 186 LocalFrame* localFrameRoot = frame->localFrameRoot(); |
187 return frameId(localFrameRoot); | 187 return frameId(localFrameRoot); |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
385 return; | 385 return; |
386 if (!nodes->Set(context, index++, toV8(node, info.Holder(), info.Get
Isolate())).FromMaybe(false)) | 386 if (!nodes->Set(context, index++, toV8(node, info.Holder(), info.Get
Isolate())).FromMaybe(false)) |
387 return; | 387 return; |
388 } | 388 } |
389 info.GetReturnValue().Set(nodes); | 389 info.GetReturnValue().Set(nodes); |
390 } | 390 } |
391 exceptionState.throwIfNeeded(); | 391 exceptionState.throwIfNeeded(); |
392 } | 392 } |
393 | 393 |
394 } // namespace blink | 394 } // namespace blink |
OLD | NEW |