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