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/v8/ScriptDebugServer.h" | 34 #include "bindings/v8/ScriptDebugServer.h" |
35 #include "core/inspector/WorkerInspectorController.h" | |
35 #include "core/workers/WorkerGlobalScope.h" | 36 #include "core/workers/WorkerGlobalScope.h" |
36 #include "core/workers/WorkerThread.h" | 37 #include "core/workers/WorkerThread.h" |
37 #include "wtf/MessageQueue.h" | 38 #include "wtf/MessageQueue.h" |
38 | 39 |
39 namespace WebCore { | 40 namespace WebCore { |
40 | 41 |
41 namespace { | 42 namespace { |
42 | 43 |
43 Mutex& workerDebuggerAgentsMutex() | |
44 { | |
45 AtomicallyInitializedStatic(Mutex&, mutex = *new Mutex); | |
46 return mutex; | |
47 } | |
48 | |
49 typedef HashMap<WorkerThread*, WorkerDebuggerAgent*> WorkerDebuggerAgents; | |
50 | |
51 WorkerDebuggerAgents& workerDebuggerAgents() | |
52 { | |
53 DEFINE_STATIC_LOCAL(WorkerDebuggerAgents, agents, ()); | |
54 return agents; | |
55 } | |
56 | |
57 | |
58 class RunInspectorCommandsTask FINAL : public ScriptDebugServer::Task { | 44 class RunInspectorCommandsTask FINAL : public ScriptDebugServer::Task { |
59 public: | 45 public: |
60 explicit RunInspectorCommandsTask(WorkerThread* thread) | 46 explicit RunInspectorCommandsTask(WorkerThread* thread) |
61 : m_thread(thread) { } | 47 : m_thread(thread) { } |
62 virtual ~RunInspectorCommandsTask() { } | 48 virtual ~RunInspectorCommandsTask() { } |
63 virtual void run() OVERRIDE | 49 virtual void run() OVERRIDE |
64 { | 50 { |
65 // Process all queued debugger commands. WorkerThread is certainly | 51 // Process all queued debugger commands. WorkerThread is certainly |
66 // alive if this task is being executed. | 52 // alive if this task is being executed. |
67 while (MessageQueueMessageReceived == m_thread->runLoop().runDebuggerTas k(WorkerRunLoop::DontWaitForMessage)) { } | 53 while (MessageQueueMessageReceived == m_thread->runLoop().runDebuggerTas k(WorkerRunLoop::DontWaitForMessage)) { } |
68 } | 54 } |
69 | 55 |
70 private: | 56 private: |
71 WorkerThread* m_thread; | 57 WorkerThread* m_thread; |
72 }; | 58 }; |
73 | 59 |
74 } // namespace | 60 } // namespace |
75 | 61 |
76 PassOwnPtr<WorkerDebuggerAgent> WorkerDebuggerAgent::create(WorkerScriptDebugSer ver* scriptDebugServer, WorkerGlobalScope* inspectedWorkerGlobalScope, InjectedS criptManager* injectedScriptManager) | 62 PassOwnPtrWillBeRawPtr<WorkerDebuggerAgent> WorkerDebuggerAgent::create(WorkerSc riptDebugServer* scriptDebugServer, WorkerGlobalScope* inspectedWorkerGlobalScop e, InjectedScriptManager* injectedScriptManager) |
77 { | 63 { |
78 return adoptPtr(new WorkerDebuggerAgent(scriptDebugServer, inspectedWorkerGl obalScope, injectedScriptManager)); | 64 return adoptPtrWillBeNoop(new WorkerDebuggerAgent(scriptDebugServer, inspect edWorkerGlobalScope, injectedScriptManager)); |
79 } | 65 } |
80 | 66 |
81 WorkerDebuggerAgent::WorkerDebuggerAgent(WorkerScriptDebugServer* scriptDebugSer ver, WorkerGlobalScope* inspectedWorkerGlobalScope, InjectedScriptManager* injec tedScriptManager) | 67 WorkerDebuggerAgent::WorkerDebuggerAgent(WorkerScriptDebugServer* scriptDebugSer ver, WorkerGlobalScope* inspectedWorkerGlobalScope, InjectedScriptManager* injec tedScriptManager) |
82 : InspectorDebuggerAgent(injectedScriptManager) | 68 : InspectorDebuggerAgent(injectedScriptManager) |
83 , m_scriptDebugServer(scriptDebugServer) | 69 , m_scriptDebugServer(scriptDebugServer) |
84 , m_inspectedWorkerGlobalScope(inspectedWorkerGlobalScope) | 70 , m_inspectedWorkerGlobalScope(inspectedWorkerGlobalScope) |
85 { | 71 { |
86 MutexLocker lock(workerDebuggerAgentsMutex()); | |
87 workerDebuggerAgents().set(inspectedWorkerGlobalScope->thread(), this); | |
88 } | 72 } |
89 | 73 |
90 WorkerDebuggerAgent::~WorkerDebuggerAgent() | 74 WorkerDebuggerAgent::~WorkerDebuggerAgent() |
91 { | 75 { |
92 MutexLocker lock(workerDebuggerAgentsMutex()); | 76 } |
93 ASSERT(workerDebuggerAgents().contains(m_inspectedWorkerGlobalScope->thread( ))); | 77 |
94 workerDebuggerAgents().remove(m_inspectedWorkerGlobalScope->thread()); | 78 void WorkerDebuggerAgent::trace(Visitor* visitor) |
79 { | |
80 visitor->trace(m_inspectedWorkerGlobalScope); | |
81 InspectorDebuggerAgent::trace(visitor); | |
95 } | 82 } |
96 | 83 |
97 void WorkerDebuggerAgent::interruptAndDispatchInspectorCommands(WorkerThread* th read) | 84 void WorkerDebuggerAgent::interruptAndDispatchInspectorCommands(WorkerThread* th read) |
98 { | 85 { |
99 MutexLocker lock(workerDebuggerAgentsMutex()); | 86 WorkerGlobalScope* workerGlobalScope = thread->workerGlobalScope(); |
100 WorkerDebuggerAgent* agent = workerDebuggerAgents().get(thread); | 87 if (!workerGlobalScope) |
yurys
2014/06/19 07:37:03
This method is called on the main thread while Wor
keishi
2014/06/19 12:52:07
I was able to make the map solution work in oilpan
| |
101 if (agent) | 88 return; |
102 agent->m_scriptDebugServer->interruptAndRunTask(adoptPtr(new RunInspecto rCommandsTask(thread))); | 89 WorkerInspectorController* workerInspectorController = workerGlobalScope->wo rkerInspectorController(); |
90 ASSERT(workerInspectorController); | |
91 WorkerDebuggerAgent* workerDebuggerAgent = workerInspectorController->worker DebuggerAgent(); | |
92 ASSERT(workerDebuggerAgent); | |
93 workerDebuggerAgent->scriptDebugServer().interruptAndRunTask(adoptPtr(new Ru nInspectorCommandsTask(thread))); | |
103 } | 94 } |
104 | 95 |
105 void WorkerDebuggerAgent::startListeningScriptDebugServer() | 96 void WorkerDebuggerAgent::startListeningScriptDebugServer() |
106 { | 97 { |
107 scriptDebugServer().addListener(this); | 98 scriptDebugServer().addListener(this); |
108 } | 99 } |
109 | 100 |
110 void WorkerDebuggerAgent::stopListeningScriptDebugServer() | 101 void WorkerDebuggerAgent::stopListeningScriptDebugServer() |
111 { | 102 { |
112 scriptDebugServer().removeListener(this); | 103 scriptDebugServer().removeListener(this); |
(...skipping 17 matching lines...) Expand all Loading... | |
130 { | 121 { |
131 // We don't need to mute console for workers. | 122 // We don't need to mute console for workers. |
132 } | 123 } |
133 | 124 |
134 void WorkerDebuggerAgent::unmuteConsole() | 125 void WorkerDebuggerAgent::unmuteConsole() |
135 { | 126 { |
136 // We don't need to mute console for workers. | 127 // We don't need to mute console for workers. |
137 } | 128 } |
138 | 129 |
139 } // namespace WebCore | 130 } // namespace WebCore |
OLD | NEW |