#ifndef InspectorConsoleAgent_h
#define InspectorConsoleAgent_h
#include "InspectorFrontend.h"
#include "bindings/v8/ScriptState.h"
#include "bindings/v8/ScriptString.h"
#include "core/inspector/ConsoleAPITypes.h"
#include "core/inspector/InspectorBaseAgent.h"
#include "core/frame/ConsoleTypes.h"
#include "wtf/Forward.h"
#include "wtf/HashCountedSet.h"
#include "wtf/HashMap.h"
#include "wtf/Noncopyable.h"
#include "wtf/Vector.h"
#include "wtf/text/StringHash.h"
namespace WebCore {
class ConsoleMessage;
class DocumentLoader;
class DOMWindow;
class LocalFrame;
class InspectorFrontend;
class InjectedScriptManager;
class InspectorTimelineAgent;
class InstrumentingAgents;
class ResourceError;
class ResourceLoader;
class ResourceResponse;
class ScriptArguments;
class ScriptCallStack;
class ScriptProfile;
class ThreadableLoaderClient;
class XMLHttpRequest;
typedef String ErrorString;
class InspectorConsoleAgent : public InspectorBaseAgent<InspectorConsoleAgent>, public InspectorBackendDispatcher::ConsoleCommandHandler {
WTF_MAKE_NONCOPYABLE(InspectorConsoleAgent);
public:
InspectorConsoleAgent(InspectorTimelineAgent*, InjectedScriptManager*);
virtual ~InspectorConsoleAgent();
virtual void init() OVERRIDE;
virtual void enable(ErrorString*) OVERRIDE FINAL;
virtual void disable(ErrorString*) OVERRIDE FINAL;
virtual void clearMessages(ErrorString*) OVERRIDE;
bool enabled() { return m_enabled; }
void reset();
virtual void setFrontend(InspectorFrontend*) OVERRIDE FINAL;
virtual void clearFrontend() OVERRIDE FINAL;
virtual void restore() OVERRIDE FINAL;
void addMessageToConsole(MessageSource, MessageType, MessageLevel, const String& message, ScriptState*, ScriptArguments*, unsigned long requestIdentifier = 0);
void addMessageToConsole(MessageSource, MessageType, MessageLevel, const String& message, const String& scriptId, unsigned lineNumber, unsigned columnNumber = 0, ScriptState* = 0, unsigned long requestIdentifier = 0);
void addMessageToConsole(MessageSource, MessageType, MessageLevel, const String& message, ScriptCallStack*, unsigned long requestIdentifier = 0);
Vector<unsigned> consoleMessageArgumentCounts();
void consoleTime(ExecutionContext*, const String& title);
void consoleTimeEnd(ExecutionContext*, const String& title, ScriptState*);
void consoleTimeline(ExecutionContext*, const String& title, ScriptState*);
void consoleTimelineEnd(ExecutionContext*, const String& title, ScriptState*);
void consoleCount(ScriptState*, PassRefPtr<ScriptArguments>);
void frameWindowDiscarded(DOMWindow*);
void didCommitLoad(LocalFrame*, DocumentLoader*);
void didFinishXHRLoading(XMLHttpRequest*, ThreadableLoaderClient*, unsigned long requestIdentifier, ScriptString, const AtomicString& method, const String& url, const String& sendURL, unsigned sendLineNumber);
void didReceiveResourceResponse(LocalFrame*, unsigned long requestIdentifier, DocumentLoader*, const ResourceResponse&, ResourceLoader*);
void didFailLoading(unsigned long requestIdentifier, const ResourceError&);
void addProfileFinishedMessageToConsole(PassRefPtr<ScriptProfile>, unsigned lineNumber, const String& sourceURL);
void addStartProfilingMessageToConsole(const String& title, unsigned lineNumber, const String& sourceURL);
virtual void setMonitoringXHREnabled(ErrorString*, bool enabled) OVERRIDE;
virtual void addInspectedNode(ErrorString*, int nodeId) = 0;
virtual void addInspectedHeapObject(ErrorString*, int inspectedHeapObjectId) OVERRIDE;
virtual bool isWorkerAgent() = 0;
protected:
void addConsoleMessage(PassOwnPtr<ConsoleMessage>);
InspectorTimelineAgent* m_timelineAgent;
InjectedScriptManager* m_injectedScriptManager;
InspectorFrontend::Console* m_frontend;
Vector<OwnPtr<ConsoleMessage> > m_consoleMessages;
int m_expiredConsoleMessageCount;
HashCountedSet<String> m_counts;
HashMap<String, double> m_times;
bool m_enabled;
private:
static int s_enabledAgentCount;
};
}
#endif