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 13 matching lines...) Loading... |
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
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/ScriptDebugServer.h" | 34 #include "bindings/core/v8/WorkerScriptDebugServer.h" |
35 #include "core/inspector/InjectedScript.h" | 35 #include "core/inspector/InjectedScript.h" |
36 #include "core/inspector/WorkerInspectorController.h" | 36 #include "core/inspector/WorkerInspectorController.h" |
37 #include "core/workers/WorkerGlobalScope.h" | 37 #include "core/workers/WorkerGlobalScope.h" |
38 #include "core/workers/WorkerThread.h" | 38 #include "core/workers/WorkerThread.h" |
39 #include "wtf/MessageQueue.h" | 39 #include "wtf/MessageQueue.h" |
40 | 40 |
41 namespace blink { | 41 namespace blink { |
42 | 42 |
43 namespace { | 43 namespace { |
44 | 44 |
45 class RunInspectorCommandsTask final : public ScriptDebugServer::Task { | 45 class RunInspectorCommandsTask final : public ScriptDebugServer::Task { |
46 public: | 46 public: |
47 explicit RunInspectorCommandsTask(WorkerThread* thread) | 47 explicit RunInspectorCommandsTask(WorkerThread* thread, WebThread::TaskObser
ver* taskObserver) |
48 : m_thread(thread) { } | 48 : m_thread(thread) |
| 49 , m_taskObserver(taskObserver) { } |
49 virtual ~RunInspectorCommandsTask() { } | 50 virtual ~RunInspectorCommandsTask() { } |
50 virtual void run() override | 51 virtual void run() override |
51 { | 52 { |
52 // Process all queued debugger commands. WorkerThread is certainly | 53 m_taskObserver->willProcessTask(); |
53 // alive if this task is being executed. | |
54 m_thread->willEnterNestedLoop(); | |
55 while (MessageQueueMessageReceived == m_thread->runDebuggerTask(WorkerTh
read::DontWaitForMessage)) { } | 54 while (MessageQueueMessageReceived == m_thread->runDebuggerTask(WorkerTh
read::DontWaitForMessage)) { } |
56 m_thread->didLeaveNestedLoop(); | 55 m_taskObserver->didProcessTask(); |
57 } | 56 } |
58 | 57 |
59 private: | 58 private: |
60 WorkerThread* m_thread; | 59 WorkerThread* m_thread; |
| 60 WebThread::TaskObserver* m_taskObserver; |
61 }; | 61 }; |
62 | 62 |
63 } // namespace | 63 } // namespace |
64 | 64 |
65 PassOwnPtrWillBeRawPtr<WorkerDebuggerAgent> WorkerDebuggerAgent::create(WorkerSc
riptDebugServer* scriptDebugServer, WorkerGlobalScope* inspectedWorkerGlobalScop
e, InjectedScriptManager* injectedScriptManager) | 65 PassOwnPtrWillBeRawPtr<WorkerDebuggerAgent> WorkerDebuggerAgent::create(WorkerSc
riptDebugServer* scriptDebugServer, WorkerGlobalScope* inspectedWorkerGlobalScop
e, InjectedScriptManager* injectedScriptManager, WebThread::TaskObserver* taskOb
server) |
66 { | 66 { |
67 return adoptPtrWillBeNoop(new WorkerDebuggerAgent(scriptDebugServer, inspect
edWorkerGlobalScope, injectedScriptManager)); | 67 return adoptPtrWillBeNoop(new WorkerDebuggerAgent(scriptDebugServer, inspect
edWorkerGlobalScope, injectedScriptManager, taskObserver)); |
68 } | 68 } |
69 | 69 |
70 WorkerDebuggerAgent::WorkerDebuggerAgent(WorkerScriptDebugServer* scriptDebugSer
ver, WorkerGlobalScope* inspectedWorkerGlobalScope, InjectedScriptManager* injec
tedScriptManager) | 70 WorkerDebuggerAgent::WorkerDebuggerAgent(WorkerScriptDebugServer* scriptDebugSer
ver, WorkerGlobalScope* inspectedWorkerGlobalScope, InjectedScriptManager* injec
tedScriptManager, WebThread::TaskObserver* taskObserver) |
71 : InspectorDebuggerAgent(injectedScriptManager, scriptDebugServer->scriptDeb
ugServer()->isolate()) | 71 : InspectorDebuggerAgent(injectedScriptManager, scriptDebugServer->scriptDeb
ugServer()->isolate()) |
72 , m_scriptDebugServer(scriptDebugServer) | 72 , m_scriptDebugServer(scriptDebugServer) |
73 , m_inspectedWorkerGlobalScope(inspectedWorkerGlobalScope) | 73 , m_inspectedWorkerGlobalScope(inspectedWorkerGlobalScope) |
| 74 , m_taskObserver(taskObserver) |
74 { | 75 { |
75 } | 76 } |
76 | 77 |
77 WorkerDebuggerAgent::~WorkerDebuggerAgent() | 78 WorkerDebuggerAgent::~WorkerDebuggerAgent() |
78 { | 79 { |
79 } | 80 } |
80 | 81 |
81 DEFINE_TRACE(WorkerDebuggerAgent) | 82 DEFINE_TRACE(WorkerDebuggerAgent) |
82 { | 83 { |
83 visitor->trace(m_inspectedWorkerGlobalScope); | 84 visitor->trace(m_inspectedWorkerGlobalScope); |
84 InspectorDebuggerAgent::trace(visitor); | 85 InspectorDebuggerAgent::trace(visitor); |
85 } | 86 } |
86 | 87 |
87 void WorkerDebuggerAgent::interruptAndDispatchInspectorCommands() | 88 void WorkerDebuggerAgent::interruptAndDispatchInspectorCommands() |
88 { | 89 { |
89 scriptDebugServer().interruptAndRun(adoptPtr(new RunInspectorCommandsTask(m_
inspectedWorkerGlobalScope->thread()))); | 90 scriptDebugServer().interruptAndRun(adoptPtr(new RunInspectorCommandsTask(m_
inspectedWorkerGlobalScope->thread(), m_taskObserver))); |
90 } | 91 } |
91 | 92 |
92 void WorkerDebuggerAgent::startListeningScriptDebugServer() | 93 void WorkerDebuggerAgent::startListeningScriptDebugServer() |
93 { | 94 { |
94 m_scriptDebugServer->addListener(this); | 95 m_scriptDebugServer->addListener(this); |
95 } | 96 } |
96 | 97 |
97 void WorkerDebuggerAgent::stopListeningScriptDebugServer() | 98 void WorkerDebuggerAgent::stopListeningScriptDebugServer() |
98 { | 99 { |
99 m_scriptDebugServer->removeListener(this); | 100 m_scriptDebugServer->removeListener(this); |
(...skipping 19 matching lines...) Loading... |
119 { | 120 { |
120 // We don't need to mute console for workers. | 121 // We don't need to mute console for workers. |
121 } | 122 } |
122 | 123 |
123 void WorkerDebuggerAgent::unmuteConsole() | 124 void WorkerDebuggerAgent::unmuteConsole() |
124 { | 125 { |
125 // We don't need to mute console for workers. | 126 // We don't need to mute console for workers. |
126 } | 127 } |
127 | 128 |
128 } // namespace blink | 129 } // namespace blink |
OLD | NEW |