JSGlobalObjectRuntimeAgent.cpp [plain text]
#include "config.h"
#include "JSGlobalObjectRuntimeAgent.h"
#if ENABLE(INSPECTOR)
#include "InjectedScript.h"
#include "InjectedScriptManager.h"
#include "JSGlobalObject.h"
using namespace JSC;
namespace Inspector {
JSGlobalObjectRuntimeAgent::JSGlobalObjectRuntimeAgent(InjectedScriptManager* injectedScriptManager, JSGlobalObject& globalObject)
: InspectorRuntimeAgent(injectedScriptManager)
, m_globalObject(globalObject)
{
}
void JSGlobalObjectRuntimeAgent::didCreateFrontendAndBackend(InspectorFrontendChannel* frontendChannel, InspectorBackendDispatcher* backendDispatcher)
{
m_frontendDispatcher = std::make_unique<InspectorRuntimeFrontendDispatcher>(frontendChannel);
m_backendDispatcher = InspectorRuntimeBackendDispatcher::create(backendDispatcher, this);
}
void JSGlobalObjectRuntimeAgent::willDestroyFrontendAndBackend(InspectorDisconnectReason)
{
m_frontendDispatcher = nullptr;
m_backendDispatcher.clear();
}
VM& JSGlobalObjectRuntimeAgent::globalVM()
{
return m_globalObject.vm();
}
InjectedScript JSGlobalObjectRuntimeAgent::injectedScriptForEval(ErrorString* errorString, const int* executionContextId)
{
ASSERT_UNUSED(executionContextId, !executionContextId);
JSC::ExecState* scriptState = m_globalObject.globalExec();
InjectedScript injectedScript = injectedScriptManager()->injectedScriptFor(scriptState);
if (injectedScript.hasNoValue())
*errorString = ASCIILiteral("Internal error: main world execution context not found.");
return injectedScript;
}
}
#endif // ENABLE(INSPECTOR)