WorkerRuntimeAgent.cpp [plain text]
#include "config.h"
#include "WorkerRuntimeAgent.h"
#include "DOMWindow.h"
#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::FrontendChannel*, Inspector::BackendDispatcher* backendDispatcher)
{
m_backendDispatcher = Inspector::RuntimeBackendDispatcher::create(backendDispatcher, this);
}
void WorkerRuntimeAgent::willDestroyFrontendAndBackend(Inspector::DisconnectReason reason)
{
m_backendDispatcher = nullptr;
InspectorRuntimeAgent::willDestroyFrontendAndBackend(reason);
}
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);
}
}