WorkerConsoleClient.cpp [plain text]
#include "config.h"
#include "WorkerConsoleClient.h"
#include "InspectorInstrumentation.h"
#include "WorkerGlobalScope.h"
#include <JavaScriptCore/ConsoleMessage.h>
#include <JavaScriptCore/ScriptArguments.h>
#include <JavaScriptCore/ScriptCallStack.h>
#include <JavaScriptCore/ScriptCallStackFactory.h>
namespace WebCore {
using namespace Inspector;
WorkerConsoleClient::WorkerConsoleClient(WorkerOrWorkletGlobalScope& globalScope)
: m_globalScope(globalScope)
{
}
WorkerConsoleClient::~WorkerConsoleClient() = default;
void WorkerConsoleClient::messageWithTypeAndLevel(MessageType type, MessageLevel level, JSC::JSGlobalObject* exec, Ref<Inspector::ScriptArguments>&& arguments)
{
String messageText;
arguments->getFirstArgumentAsString(messageText);
auto message = makeUnique<Inspector::ConsoleMessage>(MessageSource::ConsoleAPI, type, level, messageText, WTFMove(arguments), exec);
m_globalScope.addConsoleMessage(WTFMove(message));
}
void WorkerConsoleClient::count(JSC::JSGlobalObject* exec, const String& label)
{
if (is<WorkerGlobalScope>(m_globalScope))
InspectorInstrumentation::consoleCount(downcast<WorkerGlobalScope>(m_globalScope), exec, label);
}
void WorkerConsoleClient::countReset(JSC::JSGlobalObject* exec, const String& label)
{
if (is<WorkerGlobalScope>(m_globalScope))
InspectorInstrumentation::consoleCountReset(downcast<WorkerGlobalScope>(m_globalScope), exec, label);
}
void WorkerConsoleClient::time(JSC::JSGlobalObject* exec, const String& label)
{
if (is<WorkerGlobalScope>(m_globalScope))
InspectorInstrumentation::startConsoleTiming(downcast<WorkerGlobalScope>(m_globalScope), exec, label);
}
void WorkerConsoleClient::timeLog(JSC::JSGlobalObject* exec, const String& label, Ref<ScriptArguments>&& arguments)
{
if (is<WorkerGlobalScope>(m_globalScope))
InspectorInstrumentation::logConsoleTiming(downcast<WorkerGlobalScope>(m_globalScope), exec, label, WTFMove(arguments));
}
void WorkerConsoleClient::timeEnd(JSC::JSGlobalObject* exec, const String& label)
{
if (is<WorkerGlobalScope>(m_globalScope))
InspectorInstrumentation::stopConsoleTiming(downcast<WorkerGlobalScope>(m_globalScope), exec, label);
}
void WorkerConsoleClient::profile(JSC::JSGlobalObject*, const String&) { }
void WorkerConsoleClient::profileEnd(JSC::JSGlobalObject*, const String&) { }
void WorkerConsoleClient::takeHeapSnapshot(JSC::JSGlobalObject*, const String&) { }
void WorkerConsoleClient::timeStamp(JSC::JSGlobalObject*, Ref<ScriptArguments>&&) { }
void WorkerConsoleClient::record(JSC::JSGlobalObject*, Ref<ScriptArguments>&&) { }
void WorkerConsoleClient::recordEnd(JSC::JSGlobalObject*, Ref<ScriptArguments>&&) { }
void WorkerConsoleClient::screenshot(JSC::JSGlobalObject*, Ref<ScriptArguments>&&) { }
}