WorkerRuntimeAgent.cpp [plain text]
#include "config.h"
#if ENABLE(INSPECTOR) && ENABLE(WORKERS)
#include "WorkerRuntimeAgent.h"
#include "InjectedScript.h"
#include "InstrumentingAgents.h"
#include "ScriptState.h"
#include "WorkerContext.h"
#include "WorkerDebuggerAgent.h"
#include "WorkerRunLoop.h"
#include "WorkerThread.h"
namespace WebCore {
WorkerRuntimeAgent::WorkerRuntimeAgent(InstrumentingAgents* instrumentingAgents, InspectorCompositeState* state, InjectedScriptManager* injectedScriptManager, WorkerContext* workerContext)
: InspectorRuntimeAgent(instrumentingAgents, state, injectedScriptManager)
, m_workerContext(workerContext)
, m_paused(false)
{
m_instrumentingAgents->setWorkerRuntimeAgent(this);
}
WorkerRuntimeAgent::~WorkerRuntimeAgent()
{
m_instrumentingAgents->setWorkerRuntimeAgent(0);
}
InjectedScript WorkerRuntimeAgent::injectedScriptForEval(ErrorString* error, const int* executionContextId)
{
if (executionContextId) {
*error = "Execution context id is not supported for workers as there is only one execution context.";
return InjectedScript();
}
ScriptState* scriptState = scriptStateFromWorkerContext(m_workerContext);
return injectedScriptManager()->injectedScriptFor(scriptState);
}
void WorkerRuntimeAgent::muteConsole()
{
}
void WorkerRuntimeAgent::unmuteConsole()
{
}
void WorkerRuntimeAgent::run(ErrorString*)
{
m_paused = false;
}
#if ENABLE(JAVASCRIPT_DEBUGGER)
void WorkerRuntimeAgent::pauseWorkerContext(WorkerContext* context)
{
m_paused = true;
MessageQueueWaitResult result;
do {
result = context->thread()->runLoop().runInMode(context, WorkerDebuggerAgent::debuggerTaskMode);
} while (result == MessageQueueMessageReceived && m_paused);
}
#endif // ENABLE(JAVASCRIPT_DEBUGGER)
}
#endif // ENABLE(INSPECTOR) && ENABLE(WORKERS)