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 "bindings/core/v8/WorkerScriptDebugServer.h" | 32 #include "bindings/core/v8/WorkerScriptDebugServer.h" |
33 | 33 |
34 #include "bindings/core/v8/V8ScriptRunner.h" | 34 #include "bindings/core/v8/V8ScriptRunner.h" |
35 #include "core/inspector/PerIsolateDebuggerClient.h" | |
36 #include "core/inspector/ScriptDebugListener.h" | 35 #include "core/inspector/ScriptDebugListener.h" |
37 #include "core/inspector/WorkerDebuggerAgent.h" | 36 #include "core/inspector/WorkerDebuggerAgent.h" |
38 #include "core/workers/WorkerGlobalScope.h" | 37 #include "core/workers/WorkerGlobalScope.h" |
39 #include "core/workers/WorkerThread.h" | 38 #include "core/workers/WorkerThread.h" |
40 #include "wtf/MessageQueue.h" | 39 #include "wtf/MessageQueue.h" |
41 #include <v8.h> | 40 #include <v8.h> |
42 | 41 |
43 namespace blink { | 42 namespace blink { |
44 | 43 |
45 static const char* workerContextDebugId = "[worker]"; | 44 static const char* workerContextDebugId = "[worker]"; |
46 | 45 |
47 WorkerScriptDebugServer::WorkerScriptDebugServer(WorkerGlobalScope* workerGlobal
Scope) | 46 WorkerScriptDebugServer::WorkerScriptDebugServer(WorkerGlobalScope* workerGlobal
Scope) |
48 : ScriptDebugServer(v8::Isolate::GetCurrent(), adoptPtr(new PerIsolateDebugg
erClient(v8::Isolate::GetCurrent()))) | 47 : PerIsolateDebuggerClient(v8::Isolate::GetCurrent(), adoptPtr(new ScriptDeb
ugServer(v8::Isolate::GetCurrent(), adoptPtr(this)))) |
49 , m_listener(0) | 48 , m_listener(0) |
50 , m_workerGlobalScope(workerGlobalScope) | 49 , m_workerGlobalScope(workerGlobalScope) |
51 { | 50 { |
52 } | 51 } |
53 | 52 |
54 DEFINE_TRACE(WorkerScriptDebugServer) | |
55 { | |
56 visitor->trace(m_workerGlobalScope); | |
57 ScriptDebugServer::trace(visitor); | |
58 } | |
59 | |
60 void WorkerScriptDebugServer::setContextDebugData(v8::Local<v8::Context> context
) | 53 void WorkerScriptDebugServer::setContextDebugData(v8::Local<v8::Context> context
) |
61 { | 54 { |
62 ScriptDebugServer::setContextDebugData(context, workerContextDebugId); | 55 ScriptDebugServer::setContextDebugData(context, workerContextDebugId); |
63 } | 56 } |
64 | 57 |
65 void WorkerScriptDebugServer::addListener(ScriptDebugListener* listener) | 58 void WorkerScriptDebugServer::addListener(ScriptDebugListener* listener) |
66 { | 59 { |
67 ASSERT(!m_listener); | 60 ASSERT(!m_listener); |
68 enable(); | 61 scriptDebugServer()->enable(); |
69 m_listener = listener; | 62 m_listener = listener; |
70 reportCompiledScripts(workerContextDebugId, listener); | 63 scriptDebugServer()->reportCompiledScripts(workerContextDebugId, listener); |
71 } | 64 } |
72 | 65 |
73 void WorkerScriptDebugServer::removeListener(ScriptDebugListener* listener) | 66 void WorkerScriptDebugServer::removeListener(ScriptDebugListener* listener) |
74 { | 67 { |
75 ASSERT(m_listener == listener); | 68 ASSERT(m_listener == listener); |
76 continueProgram(); | 69 scriptDebugServer()->continueProgram(); |
77 m_listener = 0; | 70 m_listener = 0; |
78 disable(); | 71 scriptDebugServer()->disable(); |
79 } | 72 } |
80 | 73 |
81 ScriptDebugListener* WorkerScriptDebugServer::getDebugListenerForContext(v8::Loc
al<v8::Context>) | 74 ScriptDebugListener* WorkerScriptDebugServer::getDebugListenerForContext(v8::Loc
al<v8::Context>) |
82 { | 75 { |
83 // There is only one worker context in isolate. | 76 // There is only one worker context in isolate. |
84 return m_listener; | 77 return m_listener; |
85 } | 78 } |
86 | 79 |
87 void WorkerScriptDebugServer::runMessageLoopOnPause(v8::Local<v8::Context>) | 80 void WorkerScriptDebugServer::runMessageLoopOnPause(v8::Local<v8::Context>) |
88 { | 81 { |
89 MessageQueueWaitResult result; | 82 MessageQueueWaitResult result; |
90 m_workerGlobalScope->thread()->willEnterNestedLoop(); | 83 m_workerGlobalScope->thread()->willEnterNestedLoop(); |
91 do { | 84 do { |
92 result = m_workerGlobalScope->thread()->runDebuggerTask(); | 85 result = m_workerGlobalScope->thread()->runDebuggerTask(); |
93 // Keep waiting until execution is resumed. | 86 // Keep waiting until execution is resumed. |
94 } while (result == MessageQueueMessageReceived && isPaused()); | 87 } while (result == MessageQueueMessageReceived && scriptDebugServer()->isPau
sed()); |
95 m_workerGlobalScope->thread()->didLeaveNestedLoop(); | 88 m_workerGlobalScope->thread()->didLeaveNestedLoop(); |
96 | 89 |
97 // The listener may have been removed in the nested loop. | 90 // The listener may have been removed in the nested loop. |
98 if (m_listener) | 91 if (m_listener) |
99 m_listener->didContinue(); | 92 m_listener->didContinue(); |
100 } | 93 } |
101 | 94 |
102 void WorkerScriptDebugServer::quitMessageLoopOnPause() | 95 void WorkerScriptDebugServer::quitMessageLoopOnPause() |
103 { | 96 { |
104 // Nothing to do here in case of workers since runMessageLoopOnPause will ch
eck for paused state after each debugger command. | 97 // Nothing to do here in case of workers since runMessageLoopOnPause will ch
eck for paused state after each debugger command. |
105 } | 98 } |
106 | 99 |
107 } // namespace blink | 100 } // namespace blink |
OLD | NEW |