| 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 14 matching lines...) Expand all Loading... |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 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 "config.h" | 31 #include "config.h" |
| 32 #include "core/inspector/WorkerDebuggerAgent.h" | 32 #include "core/inspector/WorkerDebuggerAgent.h" |
| 33 | 33 |
| 34 #include "bindings/core/v8/V8Debugger.h" | 34 #include "bindings/core/v8/V8Debugger.h" |
| 35 #include "bindings/core/v8/WorkerThreadDebugger.h" |
| 35 #include "core/inspector/InjectedScript.h" | 36 #include "core/inspector/InjectedScript.h" |
| 36 #include "core/workers/WorkerGlobalScope.h" | 37 #include "core/workers/WorkerGlobalScope.h" |
| 37 #include "core/workers/WorkerThread.h" | |
| 38 #include "wtf/MessageQueue.h" | |
| 39 | 38 |
| 40 namespace blink { | 39 namespace blink { |
| 41 | 40 |
| 42 namespace { | |
| 43 | |
| 44 class RunInspectorCommandsTask final : public V8Debugger::Task { | |
| 45 public: | |
| 46 explicit RunInspectorCommandsTask(WorkerThread* thread) | |
| 47 : m_thread(thread) { } | |
| 48 virtual ~RunInspectorCommandsTask() { } | |
| 49 virtual void run() override | |
| 50 { | |
| 51 // Process all queued debugger commands. WorkerThread is certainly | |
| 52 // alive if this task is being executed. | |
| 53 m_thread->willEnterNestedLoop(); | |
| 54 while (MessageQueueMessageReceived == m_thread->runDebuggerTask(WorkerTh
read::DontWaitForMessage)) { } | |
| 55 m_thread->didLeaveNestedLoop(); | |
| 56 } | |
| 57 | |
| 58 private: | |
| 59 WorkerThread* m_thread; | |
| 60 }; | |
| 61 | |
| 62 } // namespace | |
| 63 | |
| 64 PassOwnPtrWillBeRawPtr<WorkerDebuggerAgent> WorkerDebuggerAgent::create(WorkerTh
readDebugger* workerThreadDebugger, WorkerGlobalScope* inspectedWorkerGlobalScop
e, InjectedScriptManager* injectedScriptManager) | 41 PassOwnPtrWillBeRawPtr<WorkerDebuggerAgent> WorkerDebuggerAgent::create(WorkerTh
readDebugger* workerThreadDebugger, WorkerGlobalScope* inspectedWorkerGlobalScop
e, InjectedScriptManager* injectedScriptManager) |
| 65 { | 42 { |
| 66 return adoptPtrWillBeNoop(new WorkerDebuggerAgent(workerThreadDebugger, insp
ectedWorkerGlobalScope, injectedScriptManager)); | 43 return adoptPtrWillBeNoop(new WorkerDebuggerAgent(workerThreadDebugger, insp
ectedWorkerGlobalScope, injectedScriptManager)); |
| 67 } | 44 } |
| 68 | 45 |
| 69 WorkerDebuggerAgent::WorkerDebuggerAgent(WorkerThreadDebugger* workerThreadDebug
ger, WorkerGlobalScope* inspectedWorkerGlobalScope, InjectedScriptManager* injec
tedScriptManager) | 46 WorkerDebuggerAgent::WorkerDebuggerAgent(WorkerThreadDebugger* workerThreadDebug
ger, WorkerGlobalScope* inspectedWorkerGlobalScope, InjectedScriptManager* injec
tedScriptManager) |
| 70 : InspectorDebuggerAgent(injectedScriptManager, workerThreadDebugger->debugg
er()->isolate()) | 47 : InspectorDebuggerAgent(injectedScriptManager, workerThreadDebugger->debugg
er()->isolate()) |
| 71 , m_workerThreadDebugger(workerThreadDebugger) | 48 , m_workerThreadDebugger(workerThreadDebugger) |
| 72 , m_inspectedWorkerGlobalScope(inspectedWorkerGlobalScope) | 49 , m_inspectedWorkerGlobalScope(inspectedWorkerGlobalScope) |
| 73 { | 50 { |
| 74 } | 51 } |
| 75 | 52 |
| 76 WorkerDebuggerAgent::~WorkerDebuggerAgent() | 53 WorkerDebuggerAgent::~WorkerDebuggerAgent() |
| 77 { | 54 { |
| 78 } | 55 } |
| 79 | 56 |
| 80 DEFINE_TRACE(WorkerDebuggerAgent) | 57 DEFINE_TRACE(WorkerDebuggerAgent) |
| 81 { | 58 { |
| 82 visitor->trace(m_inspectedWorkerGlobalScope); | 59 visitor->trace(m_inspectedWorkerGlobalScope); |
| 83 InspectorDebuggerAgent::trace(visitor); | 60 InspectorDebuggerAgent::trace(visitor); |
| 84 } | 61 } |
| 85 | 62 |
| 86 void WorkerDebuggerAgent::interruptAndDispatchInspectorCommands() | |
| 87 { | |
| 88 debugger().interruptAndRun(adoptPtr(new RunInspectorCommandsTask(m_inspected
WorkerGlobalScope->thread()))); | |
| 89 } | |
| 90 | |
| 91 void WorkerDebuggerAgent::startListeningV8Debugger() | 63 void WorkerDebuggerAgent::startListeningV8Debugger() |
| 92 { | 64 { |
| 93 m_workerThreadDebugger->addListener(this); | 65 m_workerThreadDebugger->addListener(this); |
| 94 } | 66 } |
| 95 | 67 |
| 96 void WorkerDebuggerAgent::stopListeningV8Debugger() | 68 void WorkerDebuggerAgent::stopListeningV8Debugger() |
| 97 { | 69 { |
| 98 m_workerThreadDebugger->removeListener(this); | 70 m_workerThreadDebugger->removeListener(this); |
| 99 } | 71 } |
| 100 | 72 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 118 { | 90 { |
| 119 // We don't need to mute console for workers. | 91 // We don't need to mute console for workers. |
| 120 } | 92 } |
| 121 | 93 |
| 122 void WorkerDebuggerAgent::unmuteConsole() | 94 void WorkerDebuggerAgent::unmuteConsole() |
| 123 { | 95 { |
| 124 // We don't need to mute console for workers. | 96 // We don't need to mute console for workers. |
| 125 } | 97 } |
| 126 | 98 |
| 127 } // namespace blink | 99 } // namespace blink |
| OLD | NEW |