WorkerScriptDebugServer.cpp [plain text]
#include "config.h"
#if ENABLE(JAVASCRIPT_DEBUGGER) && ENABLE(WORKERS)
#include "WorkerScriptDebugServer.h"
#include "WorkerContext.h"
#include "WorkerDebuggerAgent.h"
#include "WorkerRunLoop.h"
#include "WorkerThread.h"
#include <runtime/VM.h>
#include <wtf/PassOwnPtr.h>
namespace WebCore {
WorkerScriptDebugServer::WorkerScriptDebugServer(WorkerContext* context, const String& mode)
: ScriptDebugServer()
, m_workerContext(context)
, m_debuggerTaskMode(mode)
{
}
void WorkerScriptDebugServer::addListener(ScriptDebugListener* listener)
{
if (!listener)
return;
if (m_listeners.isEmpty())
m_workerContext->script()->attachDebugger(this);
m_listeners.add(listener);
recompileAllJSFunctions(0);
}
void WorkerScriptDebugServer::willExecuteProgram(const JSC::DebuggerCallFrame& debuggerCallFrame, intptr_t sourceID, int lineNumber, int columnNumber)
{
if (!m_paused)
createCallFrame(debuggerCallFrame, sourceID, lineNumber, columnNumber);
}
void WorkerScriptDebugServer::recompileAllJSFunctions(Timer<ScriptDebugServer>*)
{
JSC::VM* vm = m_workerContext->script()->vm();
JSC::JSLockHolder lock(vm);
if (vm->dynamicGlobalObject)
recompileAllJSFunctionsSoon();
else
JSC::Debugger::recompileAllJSFunctions(vm);
}
void WorkerScriptDebugServer::removeListener(ScriptDebugListener* listener)
{
if (!listener)
return;
m_listeners.remove(listener);
if (m_listeners.isEmpty())
m_workerContext->script()->detachDebugger(this);
}
void WorkerScriptDebugServer::runEventLoopWhilePaused()
{
MessageQueueWaitResult result;
do {
result = m_workerContext->thread()->runLoop().runInMode(m_workerContext, m_debuggerTaskMode);
} while (result != MessageQueueTerminated && !m_doneProcessingDebuggerEvents);
}
void WorkerScriptDebugServer::interruptAndRunTask(PassOwnPtr<ScriptDebugServer::Task>)
{
}
}
#endif // ENABLE(JAVASCRIPT_DEBUGGER) && ENABLE(WORKERS)