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 24 matching lines...) Expand all Loading... |
35 #include "bindings/core/v8/ScriptController.h" | 35 #include "bindings/core/v8/ScriptController.h" |
36 #include "bindings/core/v8/V8Window.h" | 36 #include "bindings/core/v8/V8Window.h" |
37 #include "core/dom/ExecutionContext.h" | 37 #include "core/dom/ExecutionContext.h" |
38 #include "core/frame/FrameConsole.h" | 38 #include "core/frame/FrameConsole.h" |
39 #include "core/frame/LocalDOMWindow.h" | 39 #include "core/frame/LocalDOMWindow.h" |
40 #include "core/frame/LocalFrame.h" | 40 #include "core/frame/LocalFrame.h" |
41 #include "core/frame/UseCounter.h" | 41 #include "core/frame/UseCounter.h" |
42 #include "core/inspector/IdentifiersFactory.h" | 42 #include "core/inspector/IdentifiersFactory.h" |
43 #include "core/inspector/InspectedFrames.h" | 43 #include "core/inspector/InspectedFrames.h" |
44 #include "core/inspector/InspectorTaskRunner.h" | 44 #include "core/inspector/InspectorTaskRunner.h" |
| 45 #include "core/timing/MemoryInfo.h" |
45 #include "core/workers/MainThreadWorkletGlobalScope.h" | 46 #include "core/workers/MainThreadWorkletGlobalScope.h" |
46 #include "platform/UserGestureIndicator.h" | 47 #include "platform/UserGestureIndicator.h" |
47 #include "platform/v8_inspector/public/V8Debugger.h" | 48 #include "platform/v8_inspector/public/V8Debugger.h" |
48 #include "public/platform/Platform.h" | 49 #include "public/platform/Platform.h" |
49 #include "wtf/OwnPtr.h" | 50 #include "wtf/OwnPtr.h" |
50 #include "wtf/PassOwnPtr.h" | 51 #include "wtf/PassOwnPtr.h" |
51 #include "wtf/ThreadingPrimitives.h" | 52 #include "wtf/ThreadingPrimitives.h" |
52 | 53 |
53 namespace blink { | 54 namespace blink { |
54 | 55 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 m_clientMessageLoop = clientMessageLoop; | 97 m_clientMessageLoop = clientMessageLoop; |
97 } | 98 } |
98 | 99 |
99 void MainThreadDebugger::contextCreated(ScriptState* scriptState, LocalFrame* fr
ame, SecurityOrigin* origin) | 100 void MainThreadDebugger::contextCreated(ScriptState* scriptState, LocalFrame* fr
ame, SecurityOrigin* origin) |
100 { | 101 { |
101 ASSERT(isMainThread()); | 102 ASSERT(isMainThread()); |
102 v8::HandleScope handles(scriptState->isolate()); | 103 v8::HandleScope handles(scriptState->isolate()); |
103 DOMWrapperWorld& world = scriptState->world(); | 104 DOMWrapperWorld& world = scriptState->world(); |
104 if (frame->localFrameRoot() == frame && world.isMainWorld()) | 105 if (frame->localFrameRoot() == frame && world.isMainWorld()) |
105 debugger()->resetContextGroup(contextGroupId(frame)); | 106 debugger()->resetContextGroup(contextGroupId(frame)); |
106 debugger()->contextCreated(V8ContextInfo(scriptState->context(), contextGrou
pId(frame), world.isMainWorld(), origin ? origin->toRawString() : "", world.isIs
olatedWorld() ? world.isolatedWorldHumanReadableName() : "", IdentifiersFactory:
:frameId(frame))); | 107 debugger()->contextCreated(V8ContextInfo(scriptState->context(), contextGrou
pId(frame), world.isMainWorld(), origin ? origin->toRawString() : "", world.isIs
olatedWorld() ? world.isolatedWorldHumanReadableName() : "", IdentifiersFactory:
:frameId(frame), scriptState->getExecutionContext()->isDocument())); |
107 } | 108 } |
108 | 109 |
109 void MainThreadDebugger::contextWillBeDestroyed(ScriptState* scriptState) | 110 void MainThreadDebugger::contextWillBeDestroyed(ScriptState* scriptState) |
110 { | 111 { |
111 v8::HandleScope handles(scriptState->isolate()); | 112 v8::HandleScope handles(scriptState->isolate()); |
112 debugger()->contextDestroyed(scriptState->context()); | 113 debugger()->contextDestroyed(scriptState->context()); |
113 } | 114 } |
114 | 115 |
115 int MainThreadDebugger::contextGroupId(LocalFrame* frame) | 116 int MainThreadDebugger::contextGroupId(LocalFrame* frame) |
116 { | 117 { |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 LocalFrame* frame = WeakIdentifierMap<LocalFrame>::lookup(contextGroupId); | 198 LocalFrame* frame = WeakIdentifierMap<LocalFrame>::lookup(contextGroupId); |
198 if (!frame) | 199 if (!frame) |
199 return 0; | 200 return 0; |
200 ScriptState* scriptState = ScriptState::forMainWorld(frame); | 201 ScriptState* scriptState = ScriptState::forMainWorld(frame); |
201 if (!scriptState) | 202 if (!scriptState) |
202 return 0; | 203 return 0; |
203 v8::HandleScope scopes(scriptState->isolate()); | 204 v8::HandleScope scopes(scriptState->isolate()); |
204 return V8Debugger::contextId(scriptState->context()); | 205 return V8Debugger::contextId(scriptState->context()); |
205 } | 206 } |
206 | 207 |
| 208 void MainThreadDebugger::reportMessageToConsole(v8::Local<v8::Context> context,
ConsoleMessage* consoleMessage) |
| 209 { |
| 210 ExecutionContext* executionContext = toExecutionContext(context); |
| 211 ASSERT(executionContext); |
| 212 if (executionContext->isWorkletGlobalScope()) { |
| 213 executionContext->addConsoleMessage(consoleMessage); |
| 214 return; |
| 215 } |
| 216 |
| 217 DOMWindow* window = toDOMWindow(context); |
| 218 if (!window) |
| 219 return; |
| 220 LocalDOMWindow* localDomWindow = toLocalDOMWindow(window); |
| 221 if (!localDomWindow) |
| 222 return; |
| 223 LocalFrame* frame = localDomWindow->frame(); |
| 224 if (!frame) |
| 225 return; |
| 226 frame->console().addMessage(consoleMessage); |
| 227 } |
| 228 |
| 229 v8::MaybeLocal<v8::Value> MainThreadDebugger::memoryInfo(v8::Isolate* isolate, v
8::Local<v8::Context> context, v8::Local<v8::Object> creationContext) |
| 230 { |
| 231 ExecutionContext* executionContext = toExecutionContext(context); |
| 232 ASSERT_UNUSED(executionContext, executionContext); |
| 233 ASSERT(executionContext->isDocument()); |
| 234 return toV8(MemoryInfo::create(), creationContext, isolate); |
| 235 } |
| 236 |
207 } // namespace blink | 237 } // namespace blink |
OLD | NEW |