InspectorConsoleAgent.h [plain text]
#pragma once
#include "InspectorAgentBase.h"
#include "InspectorBackendDispatchers.h"
#include "InspectorFrontendDispatchers.h"
#include <wtf/Forward.h>
#include <wtf/HashMap.h>
#include <wtf/MonotonicTime.h>
#include <wtf/Noncopyable.h>
#include <wtf/Vector.h>
#include <wtf/text/StringHash.h>
namespace JSC {
class CallFrame;
}
namespace Inspector {
class ConsoleMessage;
class InjectedScriptManager;
class InspectorHeapAgent;
class ScriptArguments;
class ScriptCallStack;
class JS_EXPORT_PRIVATE InspectorConsoleAgent : public InspectorAgentBase, public ConsoleBackendDispatcherHandler {
WTF_MAKE_NONCOPYABLE(InspectorConsoleAgent);
WTF_MAKE_FAST_ALLOCATED;
public:
InspectorConsoleAgent(AgentContext&);
~InspectorConsoleAgent() override;
void didCreateFrontendAndBackend(FrontendRouter*, BackendDispatcher*) final;
void willDestroyFrontendAndBackend(DisconnectReason) final;
void discardValues() final;
Protocol::ErrorStringOr<void> enable() final;
Protocol::ErrorStringOr<void> disable() final;
Protocol::ErrorStringOr<void> clearMessages() override;
Protocol::ErrorStringOr<Ref<JSON::ArrayOf<Protocol::Console::Channel>>> getLoggingChannels() override;
Protocol::ErrorStringOr<void> setLoggingChannelLevel(Protocol::Console::ChannelSource, Protocol::Console::ChannelLevel) override;
void setHeapAgent(InspectorHeapAgent* agent) { m_heapAgent = agent; }
bool enabled() const { return m_enabled; }
bool developerExtrasEnabled() const;
void reset();
void addMessageToConsole(std::unique_ptr<ConsoleMessage>);
void startTiming(JSC::JSGlobalObject*, const String& label);
void logTiming(JSC::JSGlobalObject*, const String& label, Ref<ScriptArguments>&&);
void stopTiming(JSC::JSGlobalObject*, const String& label);
void takeHeapSnapshot(const String& title);
void count(JSC::JSGlobalObject*, const String& label);
void countReset(JSC::JSGlobalObject*, const String& label);
protected:
void addConsoleMessage(std::unique_ptr<ConsoleMessage>);
InjectedScriptManager& m_injectedScriptManager;
std::unique_ptr<ConsoleFrontendDispatcher> m_frontendDispatcher;
RefPtr<ConsoleBackendDispatcher> m_backendDispatcher;
InspectorHeapAgent* m_heapAgent { nullptr };
Vector<std::unique_ptr<ConsoleMessage>> m_consoleMessages;
int m_expiredConsoleMessageCount { 0 };
HashMap<String, unsigned> m_counts;
HashMap<String, MonotonicTime> m_times;
bool m_enabled { false };
};
}