WorkerRuntimeAgent.cpp [plain text]
#include "config.h"
#include "WorkerRuntimeAgent.h"
#if ENABLE(INSPECTOR)
#include "InstrumentingAgents.h"
#include "JSDOMWindowBase.h"
#include "ScriptState.h"
#include "WorkerDebuggerAgent.h"
#include "WorkerGlobalScope.h"
#include "WorkerRunLoop.h"
#include "WorkerThread.h"
#include <inspector/InjectedScript.h>
#include <inspector/InjectedScriptManager.h>
using namespace Inspector;
namespace WebCore {
WorkerRuntimeAgent::WorkerRuntimeAgent(InjectedScriptManager* injectedScriptManager, WorkerGlobalScope* workerGlobalScope)
: InspectorRuntimeAgent(injectedScriptManager)
, m_workerGlobalScope(workerGlobalScope)
, m_paused(false)
{
}
void WorkerRuntimeAgent::didCreateFrontendAndBackend(Inspector::InspectorFrontendChannel*, InspectorBackendDispatcher* backendDispatcher)
{
m_backendDispatcher = InspectorRuntimeBackendDispatcher::create(backendDispatcher, this);
}
void WorkerRuntimeAgent::willDestroyFrontendAndBackend(InspectorDisconnectReason)
{
m_backendDispatcher.clear();
}
InjectedScript WorkerRuntimeAgent::injectedScriptForEval(ErrorString* error, const int* executionContextId)
{
if (executionContextId) {
*error = ASCIILiteral("Execution context id is not supported for workers as there is only one execution context.");
return InjectedScript();
}
JSC::ExecState* scriptState = execStateFromWorkerGlobalScope(m_workerGlobalScope);
return injectedScriptManager()->injectedScriptFor(scriptState);
}
void WorkerRuntimeAgent::muteConsole()
{
}
void WorkerRuntimeAgent::unmuteConsole()
{
}
void WorkerRuntimeAgent::run(ErrorString*)
{
m_paused = false;
}
JSC::VM& WorkerRuntimeAgent::globalVM()
{
return JSDOMWindowBase::commonVM();
}
void WorkerRuntimeAgent::pauseWorkerGlobalScope(WorkerGlobalScope* context)
{
m_paused = true;
MessageQueueWaitResult result;
do {
result = context->thread().runLoop().runInMode(context, WorkerDebuggerAgent::debuggerTaskMode);
} while (result == MessageQueueMessageReceived && m_paused);
}
}
#endif // ENABLE(INSPECTOR)