| 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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 return mutex; | 75 return mutex; |
| 76 } | 76 } |
| 77 | 77 |
| 78 } | 78 } |
| 79 | 79 |
| 80 MainThreadDebugger* MainThreadDebugger::s_instance = nullptr; | 80 MainThreadDebugger* MainThreadDebugger::s_instance = nullptr; |
| 81 | 81 |
| 82 MainThreadDebugger::MainThreadDebugger(v8::Isolate* isolate) | 82 MainThreadDebugger::MainThreadDebugger(v8::Isolate* isolate) |
| 83 : ThreadDebugger(isolate) | 83 : ThreadDebugger(isolate) |
| 84 , m_taskRunner(wrapUnique(new InspectorTaskRunner())) | 84 , m_taskRunner(wrapUnique(new InspectorTaskRunner())) |
| 85 , m_paused(false) |
| 86 , m_muteConsoleCount(0) |
| 85 { | 87 { |
| 86 MutexLocker locker(creationMutex()); | 88 MutexLocker locker(creationMutex()); |
| 87 ASSERT(!s_instance); | 89 ASSERT(!s_instance); |
| 88 s_instance = this; | 90 s_instance = this; |
| 89 } | 91 } |
| 90 | 92 |
| 91 MainThreadDebugger::~MainThreadDebugger() | 93 MainThreadDebugger::~MainThreadDebugger() |
| 92 { | 94 { |
| 93 MutexLocker locker(creationMutex()); | 95 MutexLocker locker(creationMutex()); |
| 94 ASSERT(s_instance == this); | 96 ASSERT(s_instance == this); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 118 } | 120 } |
| 119 | 121 |
| 120 void MainThreadDebugger::contextWillBeDestroyed(ScriptState* scriptState) | 122 void MainThreadDebugger::contextWillBeDestroyed(ScriptState* scriptState) |
| 121 { | 123 { |
| 122 v8::HandleScope handles(scriptState->isolate()); | 124 v8::HandleScope handles(scriptState->isolate()); |
| 123 debugger()->contextDestroyed(scriptState->context()); | 125 debugger()->contextDestroyed(scriptState->context()); |
| 124 } | 126 } |
| 125 | 127 |
| 126 void MainThreadDebugger::exceptionThrown(LocalFrame* frame, const String& errorM
essage, std::unique_ptr<SourceLocation> location) | 128 void MainThreadDebugger::exceptionThrown(LocalFrame* frame, const String& errorM
essage, std::unique_ptr<SourceLocation> location) |
| 127 { | 129 { |
| 130 if (m_muteConsoleCount) |
| 131 return; |
| 128 debugger()->exceptionThrown(contextGroupId(frame), errorMessage, location->u
rl(), location->lineNumber(), location->columnNumber(), location->cloneStackTrac
e(), location->scriptId()); | 132 debugger()->exceptionThrown(contextGroupId(frame), errorMessage, location->u
rl(), location->lineNumber(), location->columnNumber(), location->cloneStackTrac
e(), location->scriptId()); |
| 129 } | 133 } |
| 130 | 134 |
| 135 bool MainThreadDebugger::addConsoleMessage(LocalFrame* frame, ConsoleMessage* co
nsoleMessage) |
| 136 { |
| 137 if (m_muteConsoleCount) |
| 138 return false; |
| 139 debugger()->addConsoleMessage( |
| 140 contextGroupId(frame), |
| 141 consoleMessage->source(), |
| 142 consoleMessage->level(), |
| 143 consoleMessage->message(), |
| 144 consoleMessage->location()->url(), |
| 145 consoleMessage->location()->lineNumber(), |
| 146 consoleMessage->location()->columnNumber(), |
| 147 consoleMessage->location()->cloneStackTrace(), |
| 148 consoleMessage->location()->scriptId(), |
| 149 IdentifiersFactory::requestId(consoleMessage->requestIdentifier()), |
| 150 consoleMessage->workerId()); |
| 151 return true; |
| 152 } |
| 153 |
| 131 int MainThreadDebugger::contextGroupId(LocalFrame* frame) | 154 int MainThreadDebugger::contextGroupId(LocalFrame* frame) |
| 132 { | 155 { |
| 133 LocalFrame* localFrameRoot = frame->localFrameRoot(); | 156 LocalFrame* localFrameRoot = frame->localFrameRoot(); |
| 134 return frameId(localFrameRoot); | 157 return frameId(localFrameRoot); |
| 135 } | 158 } |
| 136 | 159 |
| 137 MainThreadDebugger* MainThreadDebugger::instance() | 160 MainThreadDebugger* MainThreadDebugger::instance() |
| 138 { | 161 { |
| 139 ASSERT(isMainThread()); | 162 ASSERT(isMainThread()); |
| 140 V8PerIsolateData* data = V8PerIsolateData::from(V8PerIsolateData::mainThread
Isolate()); | 163 V8PerIsolateData* data = V8PerIsolateData::from(V8PerIsolateData::mainThread
Isolate()); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 151 } | 174 } |
| 152 } | 175 } |
| 153 | 176 |
| 154 void MainThreadDebugger::runMessageLoopOnPause(int contextGroupId) | 177 void MainThreadDebugger::runMessageLoopOnPause(int contextGroupId) |
| 155 { | 178 { |
| 156 LocalFrame* pausedFrame = WeakIdentifierMap<LocalFrame>::lookup(contextGroup
Id); | 179 LocalFrame* pausedFrame = WeakIdentifierMap<LocalFrame>::lookup(contextGroup
Id); |
| 157 // Do not pause in Context of detached frame. | 180 // Do not pause in Context of detached frame. |
| 158 if (!pausedFrame) | 181 if (!pausedFrame) |
| 159 return; | 182 return; |
| 160 ASSERT(pausedFrame == pausedFrame->localFrameRoot()); | 183 ASSERT(pausedFrame == pausedFrame->localFrameRoot()); |
| 184 m_paused = true; |
| 161 | 185 |
| 162 if (UserGestureToken* token = UserGestureIndicator::currentToken()) | 186 if (UserGestureToken* token = UserGestureIndicator::currentToken()) |
| 163 token->setPauseInDebugger(); | 187 token->setPauseInDebugger(); |
| 164 // Wait for continue or step command. | 188 // Wait for continue or step command. |
| 165 if (m_clientMessageLoop) | 189 if (m_clientMessageLoop) |
| 166 m_clientMessageLoop->run(pausedFrame); | 190 m_clientMessageLoop->run(pausedFrame); |
| 167 } | 191 } |
| 168 | 192 |
| 169 void MainThreadDebugger::quitMessageLoopOnPause() | 193 void MainThreadDebugger::quitMessageLoopOnPause() |
| 170 { | 194 { |
| 195 m_paused = false; |
| 171 if (m_clientMessageLoop) | 196 if (m_clientMessageLoop) |
| 172 m_clientMessageLoop->quitNow(); | 197 m_clientMessageLoop->quitNow(); |
| 173 } | 198 } |
| 174 | 199 |
| 175 void MainThreadDebugger::muteWarningsAndDeprecations() | 200 void MainThreadDebugger::muteWarningsAndDeprecations() |
| 176 { | 201 { |
| 177 UseCounter::muteForInspector(); | 202 UseCounter::muteForInspector(); |
| 203 m_muteConsoleCount++; |
| 178 } | 204 } |
| 179 | 205 |
| 180 void MainThreadDebugger::unmuteWarningsAndDeprecations() | 206 void MainThreadDebugger::unmuteWarningsAndDeprecations() |
| 181 { | 207 { |
| 182 UseCounter::unmuteForInspector(); | 208 UseCounter::unmuteForInspector(); |
| 209 m_muteConsoleCount--; |
| 183 } | 210 } |
| 184 | 211 |
| 185 bool MainThreadDebugger::callingContextCanAccessContext(v8::Local<v8::Context> c
alling, v8::Local<v8::Context> target) | 212 bool MainThreadDebugger::callingContextCanAccessContext(v8::Local<v8::Context> c
alling, v8::Local<v8::Context> target) |
| 186 { | 213 { |
| 187 return BindingSecurity::shouldAllowAccessTo(m_isolate, calling, target, DoNo
tReportSecurityError); | 214 return BindingSecurity::shouldAllowAccessTo(m_isolate, calling, target, DoNo
tReportSecurityError); |
| 188 } | 215 } |
| 189 | 216 |
| 190 v8::Local<v8::Context> MainThreadDebugger::ensureDefaultContextInGroup(int conte
xtGroupId) | 217 v8::Local<v8::Context> MainThreadDebugger::ensureDefaultContextInGroup(int conte
xtGroupId) |
| 191 { | 218 { |
| 192 LocalFrame* frame = WeakIdentifierMap<LocalFrame>::lookup(contextGroupId); | 219 LocalFrame* frame = WeakIdentifierMap<LocalFrame>::lookup(contextGroupId); |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 308 return; | 335 return; |
| 309 if (!nodes->Set(context, index++, toV8(node, info.Holder(), info.Get
Isolate())).FromMaybe(false)) | 336 if (!nodes->Set(context, index++, toV8(node, info.Holder(), info.Get
Isolate())).FromMaybe(false)) |
| 310 return; | 337 return; |
| 311 } | 338 } |
| 312 info.GetReturnValue().Set(nodes); | 339 info.GetReturnValue().Set(nodes); |
| 313 } | 340 } |
| 314 exceptionState.throwIfNeeded(); | 341 exceptionState.throwIfNeeded(); |
| 315 } | 342 } |
| 316 | 343 |
| 317 } // namespace blink | 344 } // namespace blink |
| OLD | NEW |