Index: Source/core/inspector/InspectorBaseAgent.h |
diff --git a/Source/core/inspector/InspectorBaseAgent.h b/Source/core/inspector/InspectorBaseAgent.h |
index e372bd9eba2be97a2290bdc845522bc87e54b8d1..1d724fc2354faab628c3a0c2b78219653cc6304c 100644 |
--- a/Source/core/inspector/InspectorBaseAgent.h |
+++ b/Source/core/inspector/InspectorBaseAgent.h |
@@ -32,9 +32,11 @@ |
#define InspectorBaseAgent_h |
#include "InspectorBackendDispatcher.h" |
-#include <wtf/Forward.h> |
-#include <wtf/Vector.h> |
-#include <wtf/text/WTFString.h> |
+#include "wtf/Forward.h" |
+#include "wtf/PassOwnPtr.h" |
+#include "wtf/RefCounted.h" |
+#include "wtf/Vector.h" |
+#include "wtf/text/WTFString.h" |
namespace WebCore { |
@@ -43,18 +45,37 @@ class InspectorCompositeState; |
class InspectorState; |
class InstrumentingAgents; |
-class InspectorBaseAgentInterface { |
+class InspectorBaseAgent : public RefCounted<InspectorBaseAgent> { |
public: |
- InspectorBaseAgentInterface(const String&, InstrumentingAgents*, InspectorCompositeState*); |
- virtual ~InspectorBaseAgentInterface(); |
+ InspectorBaseAgent(InstrumentingAgents*, InspectorState*); |
+ virtual ~InspectorBaseAgent(); |
+ // FIXME(kaznacheev) Remove the below 4 methods once all agent instances are created on enable (see crbug.com/248092) |
virtual void setFrontend(InspectorFrontend*) { } |
virtual void clearFrontend() { } |
virtual void restore() { } |
- virtual void registerInDispatcher(InspectorBackendDispatcher*) = 0; |
virtual void discardAgent() { } |
- String name() { return m_name; } |
+ virtual void reportMemoryUsage(MemoryObjectInfo*) const; |
+ |
+protected: |
+ InstrumentingAgents* m_instrumentingAgents; |
+ InspectorState* m_state; |
+}; |
+ |
+class InspectorBaseFactoryInterface { |
+public: |
+ |
+ InspectorBaseFactoryInterface(const String& name, InstrumentingAgents*, InspectorCompositeState*); |
+ virtual ~InspectorBaseFactoryInterface(); |
+ |
+ void setAgent(PassRefPtr<InspectorBaseAgent>); |
+ |
+ virtual void setFrontend(InspectorFrontend*); |
+ virtual void clearFrontend(); |
+ virtual void restore(); |
+ virtual void registerInDispatcher(InspectorBackendDispatcher*) = 0; |
+ virtual void discardDependencies(); |
virtual void reportMemoryUsage(MemoryObjectInfo*) const; |
@@ -62,39 +83,45 @@ protected: |
InstrumentingAgents* m_instrumentingAgents; |
InspectorState* m_state; |
+ RefPtr<InspectorBaseAgent> m_agent; |
+ |
private: |
- String m_name; |
+ InspectorFrontend* m_frontend; |
}; |
-class InspectorAgentRegistry { |
+class InspectorFactoryRegistry { |
public: |
- void append(PassOwnPtr<InspectorBaseAgentInterface>); |
+ void append(PassOwnPtr<InspectorBaseFactoryInterface>); |
void setFrontend(InspectorFrontend*); |
void clearFrontend(); |
void restore(); |
void registerInDispatcher(InspectorBackendDispatcher*); |
- void discardAgents(); |
+ void discardDependencies(); |
virtual void reportMemoryUsage(MemoryObjectInfo*) const; |
private: |
- Vector<OwnPtr<InspectorBaseAgentInterface> > m_agents; |
+ Vector<OwnPtr<InspectorBaseFactoryInterface> > m_controllers; |
}; |
-template<typename T> |
-class InspectorBaseAgent : public InspectorBaseAgentInterface { |
+template<typename T, typename Agent> |
+class InspectorBaseFactory : public InspectorBaseFactoryInterface, public Agent::Factory { |
public: |
- virtual ~InspectorBaseAgent() { } |
- |
+ // InspectorBaseFactoryInterface implementation |
virtual void registerInDispatcher(InspectorBackendDispatcher* dispatcher) |
{ |
dispatcher->registerAgent(static_cast<T*>(this)); |
} |
+ Agent* agent() { return static_cast<Agent*>(m_agent.get()); } |
+ |
+ // Agent::Factory implementation |
+ virtual Agent* commandHandler() { return agent(); } |
+ |
protected: |
- InspectorBaseAgent(const String& name, InstrumentingAgents* instrumentingAgents, InspectorCompositeState* inspectorState) |
- : InspectorBaseAgentInterface(name, instrumentingAgents, inspectorState) |
+ InspectorBaseFactory(const String& name, InstrumentingAgents* instrumentingAgents, InspectorCompositeState* compositeState) |
+ : InspectorBaseFactoryInterface(name, instrumentingAgents, compositeState) |
{ |
} |
}; |