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 17 matching lines...) Expand all Loading... |
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 | 32 |
33 #if ENABLE(INSPECTOR) && ENABLE(WORKERS) | 33 #if ENABLE(INSPECTOR) && ENABLE(WORKERS) |
34 | 34 |
35 #include "WorkerRuntimeAgent.h" | 35 #include "WorkerRuntimeAgent.h" |
36 | 36 |
37 #include "InjectedScript.h" | 37 #include "InjectedScript.h" |
| 38 #include "InstrumentingAgents.h" |
38 #include "ScriptState.h" | 39 #include "ScriptState.h" |
| 40 #include "WorkerContext.h" |
| 41 #include "WorkerDebuggerAgent.h" |
| 42 #include "WorkerRunLoop.h" |
| 43 #include "WorkerThread.h" |
39 | 44 |
40 namespace WebCore { | 45 namespace WebCore { |
41 | 46 |
42 WorkerRuntimeAgent::WorkerRuntimeAgent(InstrumentingAgents* instrumentingAgents,
InspectorState* state, InjectedScriptManager* injectedScriptManager, WorkerCont
ext* workerContext) | 47 WorkerRuntimeAgent::WorkerRuntimeAgent(InstrumentingAgents* instrumentingAgents,
InspectorState* state, InjectedScriptManager* injectedScriptManager, WorkerCont
ext* workerContext) |
43 : InspectorRuntimeAgent(instrumentingAgents, state, injectedScriptManager) | 48 : InspectorRuntimeAgent(instrumentingAgents, state, injectedScriptManager) |
44 , m_workerContext(workerContext) | 49 , m_workerContext(workerContext) |
| 50 , m_paused(false) |
45 { | 51 { |
| 52 m_instrumentingAgents->setWorkerRuntimeAgent(this); |
46 } | 53 } |
47 | 54 |
48 WorkerRuntimeAgent::~WorkerRuntimeAgent() | 55 WorkerRuntimeAgent::~WorkerRuntimeAgent() |
49 { | 56 { |
| 57 m_instrumentingAgents->setWorkerRuntimeAgent(0); |
50 } | 58 } |
51 | 59 |
52 InjectedScript WorkerRuntimeAgent::injectedScriptForEval(ErrorString* error, con
st int* executionContextId) | 60 InjectedScript WorkerRuntimeAgent::injectedScriptForEval(ErrorString* error, con
st int* executionContextId) |
53 { | 61 { |
54 if (executionContextId) { | 62 if (executionContextId) { |
55 *error = "Execution context id is not supported for workers as there is
only one execution context."; | 63 *error = "Execution context id is not supported for workers as there is
only one execution context."; |
56 return InjectedScript(); | 64 return InjectedScript(); |
57 } | 65 } |
58 ScriptState* scriptState = scriptStateFromWorkerContext(m_workerContext); | 66 ScriptState* scriptState = scriptStateFromWorkerContext(m_workerContext); |
59 return injectedScriptManager()->injectedScriptFor(scriptState); | 67 return injectedScriptManager()->injectedScriptFor(scriptState); |
60 } | 68 } |
61 | 69 |
62 void WorkerRuntimeAgent::muteConsole() | 70 void WorkerRuntimeAgent::muteConsole() |
63 { | 71 { |
64 // We don't need to mute console for workers. | 72 // We don't need to mute console for workers. |
65 } | 73 } |
66 | 74 |
67 void WorkerRuntimeAgent::unmuteConsole() | 75 void WorkerRuntimeAgent::unmuteConsole() |
68 { | 76 { |
69 // We don't need to mute console for workers. | 77 // We don't need to mute console for workers. |
70 } | 78 } |
71 | 79 |
| 80 void WorkerRuntimeAgent::run(ErrorString*) |
| 81 { |
| 82 m_paused = false; |
| 83 } |
| 84 |
| 85 #if ENABLE(JAVASCRIPT_DEBUGGER) |
| 86 void WorkerRuntimeAgent::pauseWorkerContext(WorkerContext* context) |
| 87 { |
| 88 m_paused = true; |
| 89 MessageQueueWaitResult result; |
| 90 do { |
| 91 result = context->thread()->runLoop().runInMode(context, WorkerDebuggerA
gent::debuggerTaskMode); |
| 92 // Keep waiting until execution is resumed. |
| 93 } while (result == MessageQueueMessageReceived && m_paused); |
| 94 } |
| 95 #endif // ENABLE(JAVASCRIPT_DEBUGGER) |
| 96 |
72 } // namespace WebCore | 97 } // namespace WebCore |
73 | 98 |
74 #endif // ENABLE(INSPECTOR) && ENABLE(WORKERS) | 99 #endif // ENABLE(INSPECTOR) && ENABLE(WORKERS) |
OLD | NEW |