#ifndef InspectorBaseAgent_h
#define InspectorBaseAgent_h
#include "InspectorBackendDispatcher.h"
#include "wtf/Forward.h"
#include "wtf/Vector.h"
#include "wtf/text/WTFString.h"
namespace WebCore {
class InspectorFrontend;
class InspectorCompositeState;
class InspectorState;
class InstrumentingAgents;
class InspectorAgent {
public:
explicit InspectorAgent(const String&);
virtual ~InspectorAgent();
virtual void init() { }
virtual void setFrontend(InspectorFrontend*) { }
virtual void clearFrontend() { }
virtual void restore() { }
virtual void registerInDispatcher(InspectorBackendDispatcher*) = 0;
virtual void discardAgent() { }
virtual void didCommitLoadForMainFrame() { }
virtual void flushPendingFrontendMessages() { }
String name() { return m_name; }
void appended(InstrumentingAgents*, InspectorState*);
protected:
InstrumentingAgents* m_instrumentingAgents;
InspectorState* m_state;
private:
String m_name;
};
class InspectorAgentRegistry {
public:
InspectorAgentRegistry(InstrumentingAgents*, InspectorCompositeState*);
void append(PassOwnPtr<InspectorAgent>);
void setFrontend(InspectorFrontend*);
void clearFrontend();
void restore();
void registerInDispatcher(InspectorBackendDispatcher*);
void discardAgents();
void flushPendingFrontendMessages();
private:
InstrumentingAgents* m_instrumentingAgents;
InspectorCompositeState* m_inspectorState;
Vector<OwnPtr<InspectorAgent> > m_agents;
};
template<typename T>
class InspectorBaseAgent : public InspectorAgent {
public:
virtual ~InspectorBaseAgent() { }
virtual void registerInDispatcher(InspectorBackendDispatcher* dispatcher) OVERRIDE FINAL
{
dispatcher->registerAgent(static_cast<T*>(this));
}
protected:
InspectorBaseAgent(const String& name) : InspectorAgent(name)
{
}
};
}
#endif