Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(24)

Side by Side Diff: third_party/WebKit/Source/core/inspector/MainThreadDebugger.cpp

Issue 2035653006: [DevTools] Move Console to v8 inspector. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: all tests pass Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 15 matching lines...) Expand all
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #include "core/inspector/MainThreadDebugger.h" 31 #include "core/inspector/MainThreadDebugger.h"
32 32
33 #include "bindings/core/v8/BindingSecurity.h" 33 #include "bindings/core/v8/BindingSecurity.h"
34 #include "bindings/core/v8/DOMWrapperWorld.h" 34 #include "bindings/core/v8/DOMWrapperWorld.h"
35 #include "bindings/core/v8/ScriptController.h" 35 #include "bindings/core/v8/ScriptController.h"
36 #include "bindings/core/v8/SourceLocation.h"
36 #include "bindings/core/v8/V8Node.h" 37 #include "bindings/core/v8/V8Node.h"
37 #include "bindings/core/v8/V8Window.h" 38 #include "bindings/core/v8/V8Window.h"
38 #include "core/dom/ContainerNode.h" 39 #include "core/dom/ContainerNode.h"
39 #include "core/dom/Document.h" 40 #include "core/dom/Document.h"
40 #include "core/dom/Element.h" 41 #include "core/dom/Element.h"
41 #include "core/dom/ExecutionContext.h" 42 #include "core/dom/ExecutionContext.h"
42 #include "core/dom/StaticNodeList.h" 43 #include "core/dom/StaticNodeList.h"
43 #include "core/frame/FrameConsole.h" 44 #include "core/frame/FrameConsole.h"
44 #include "core/frame/LocalDOMWindow.h" 45 #include "core/frame/LocalDOMWindow.h"
45 #include "core/frame/LocalFrame.h" 46 #include "core/frame/LocalFrame.h"
46 #include "core/frame/UseCounter.h" 47 #include "core/frame/UseCounter.h"
48 #include "core/inspector/ConsoleMessage.h"
47 #include "core/inspector/IdentifiersFactory.h" 49 #include "core/inspector/IdentifiersFactory.h"
48 #include "core/inspector/InspectedFrames.h" 50 #include "core/inspector/InspectedFrames.h"
49 #include "core/inspector/InspectorTaskRunner.h" 51 #include "core/inspector/InspectorTaskRunner.h"
50 #include "core/timing/MemoryInfo.h" 52 #include "core/timing/MemoryInfo.h"
51 #include "core/workers/MainThreadWorkletGlobalScope.h" 53 #include "core/workers/MainThreadWorkletGlobalScope.h"
52 #include "core/xml/XPathEvaluator.h" 54 #include "core/xml/XPathEvaluator.h"
53 #include "core/xml/XPathResult.h" 55 #include "core/xml/XPathResult.h"
54 #include "platform/UserGestureIndicator.h" 56 #include "platform/UserGestureIndicator.h"
55 #include "platform/v8_inspector/public/V8Debugger.h" 57 #include "platform/v8_inspector/public/V8Debugger.h"
56 #include "wtf/OwnPtr.h" 58 #include "wtf/OwnPtr.h"
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 } 157 }
156 158
157 void MainThreadDebugger::quitMessageLoopOnPause() 159 void MainThreadDebugger::quitMessageLoopOnPause()
158 { 160 {
159 if (m_clientMessageLoop) 161 if (m_clientMessageLoop)
160 m_clientMessageLoop->quitNow(); 162 m_clientMessageLoop->quitNow();
161 } 163 }
162 164
163 void MainThreadDebugger::muteWarningsAndDeprecations() 165 void MainThreadDebugger::muteWarningsAndDeprecations()
164 { 166 {
165 FrameConsole::mute();
166 UseCounter::muteForInspector(); 167 UseCounter::muteForInspector();
167 } 168 }
168 169
169 void MainThreadDebugger::unmuteWarningsAndDeprecations() 170 void MainThreadDebugger::unmuteWarningsAndDeprecations()
170 { 171 {
171 FrameConsole::unmute();
172 UseCounter::unmuteForInspector(); 172 UseCounter::unmuteForInspector();
173 } 173 }
174 174
175 void MainThreadDebugger::muteConsole()
176 {
177 FrameConsole::mute();
178 }
179
180 void MainThreadDebugger::unmuteConsole()
181 {
182 FrameConsole::unmute();
183 }
184
185 bool MainThreadDebugger::callingContextCanAccessContext(v8::Local<v8::Context> c alling, v8::Local<v8::Context> target) 175 bool MainThreadDebugger::callingContextCanAccessContext(v8::Local<v8::Context> c alling, v8::Local<v8::Context> target)
186 { 176 {
187 ExecutionContext* executionContext = toExecutionContext(target); 177 ExecutionContext* executionContext = toExecutionContext(target);
188 ASSERT(executionContext); 178 ASSERT(executionContext);
189 179
190 if (executionContext->isMainThreadWorkletGlobalScope()) { 180 if (executionContext->isMainThreadWorkletGlobalScope()) {
191 MainThreadWorkletGlobalScope* globalScope = toMainThreadWorkletGlobalSco pe(executionContext); 181 MainThreadWorkletGlobalScope* globalScope = toMainThreadWorkletGlobalSco pe(executionContext);
192 return globalScope && BindingSecurity::shouldAllowAccessTo(m_isolate, to LocalDOMWindow(toDOMWindow(calling)), globalScope, DoNotReportSecurityError); 182 return globalScope && BindingSecurity::shouldAllowAccessTo(m_isolate, to LocalDOMWindow(toDOMWindow(calling)), globalScope, DoNotReportSecurityError);
193 } 183 }
194 184
195 DOMWindow* window = toDOMWindow(target); 185 DOMWindow* window = toDOMWindow(target);
196 return window && BindingSecurity::shouldAllowAccessTo(m_isolate, toLocalDOMW indow(toDOMWindow(calling)), window, DoNotReportSecurityError); 186 return window && BindingSecurity::shouldAllowAccessTo(m_isolate, toLocalDOMW indow(toDOMWindow(calling)), window, DoNotReportSecurityError);
197 } 187 }
198 188
199 int MainThreadDebugger::ensureDefaultContextInGroup(int contextGroupId) 189 v8::Local<v8::Context> MainThreadDebugger::ensureDefaultContextInGroup(int conte xtGroupId)
190 {
191 LocalFrame* frame = WeakIdentifierMap<LocalFrame>::lookup(contextGroupId);
192 ScriptState* scriptState = frame ? ScriptState::forMainWorld(frame) : nullpt r;
193 return scriptState ? scriptState->context() : v8::Local<v8::Context>();
194 }
195
196 void MainThreadDebugger::messageAddedToConsole(int contextGroupId, MessageSource source, MessageLevel level, const String16& message, const String16& url, unsig ned lineNumber, unsigned columnNumber, V8StackTrace* stackTrace)
200 { 197 {
201 LocalFrame* frame = WeakIdentifierMap<LocalFrame>::lookup(contextGroupId); 198 LocalFrame* frame = WeakIdentifierMap<LocalFrame>::lookup(contextGroupId);
202 if (!frame) 199 if (!frame)
203 return 0;
204 ScriptState* scriptState = ScriptState::forMainWorld(frame);
205 if (!scriptState)
206 return 0;
207 v8::HandleScope scopes(scriptState->isolate());
208 return V8Debugger::contextId(scriptState->context());
209 }
210
211 void MainThreadDebugger::reportMessageToConsole(v8::Local<v8::Context> context, ConsoleMessage* consoleMessage)
212 {
213 ExecutionContext* executionContext = toExecutionContext(context);
214 ASSERT(executionContext);
215 if (executionContext->isWorkletGlobalScope()) {
216 executionContext->addConsoleMessage(consoleMessage);
217 return; 200 return;
218 } 201 ConsoleMessage* consoleMessage = ConsoleMessage::create(source, level, messa ge, SourceLocation::create(url, lineNumber, columnNumber, stackTrace ? stackTrac e->clone() : nullptr, 0));
219 202 frame->console().reportMessageToClient(consoleMessage);
220 DOMWindow* window = toDOMWindow(context);
221 if (!window)
222 return;
223 LocalDOMWindow* localDomWindow = toLocalDOMWindow(window);
224 if (!localDomWindow)
225 return;
226 LocalFrame* frame = localDomWindow->frame();
227 if (!frame)
228 return;
229 frame->console().addMessage(consoleMessage);
230 } 203 }
231 204
232 v8::MaybeLocal<v8::Value> MainThreadDebugger::memoryInfo(v8::Isolate* isolate, v 8::Local<v8::Context> context) 205 v8::MaybeLocal<v8::Value> MainThreadDebugger::memoryInfo(v8::Isolate* isolate, v 8::Local<v8::Context> context)
233 { 206 {
234 ExecutionContext* executionContext = toExecutionContext(context); 207 ExecutionContext* executionContext = toExecutionContext(context);
235 ASSERT_UNUSED(executionContext, executionContext); 208 ASSERT_UNUSED(executionContext, executionContext);
236 ASSERT(executionContext->isDocument()); 209 ASSERT(executionContext->isDocument());
237 return toV8(MemoryInfo::create(), context->Global(), isolate); 210 return toV8(MemoryInfo::create(), context->Global(), isolate);
238 } 211 }
239 212
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 return; 307 return;
335 if (!nodes->Set(context, index++, toV8(node, info.Holder(), info.Get Isolate())).FromMaybe(false)) 308 if (!nodes->Set(context, index++, toV8(node, info.Holder(), info.Get Isolate())).FromMaybe(false))
336 return; 309 return;
337 } 310 }
338 info.GetReturnValue().Set(nodes); 311 info.GetReturnValue().Set(nodes);
339 } 312 }
340 exceptionState.throwIfNeeded(); 313 exceptionState.throwIfNeeded();
341 } 314 }
342 315
343 } // namespace blink 316 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698