Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1073)

Unified Diff: Source/core/inspector/InspectorBaseAgent.h

Issue 17030009: Inspector: wrapped inspector agent instances into factory-like wrappers (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Made InspectorBaseAgent RefCounted Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/core/inspector/InspectorBaseAgent.h
diff --git a/Source/core/inspector/InspectorBaseAgent.h b/Source/core/inspector/InspectorBaseAgent.h
index e372bd9eba2be97a2290bdc845522bc87e54b8d1..87fed452f9f00094b939449b2e24d99e2dfadcb9 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,36 @@ 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();
virtual void setFrontend(InspectorFrontend*) { }
pfeldman 2013/06/18 15:36:06 Add a bunch of fixme-s for these and a link to a m
Vladislav Kaznacheev 2013/06/19 12:58:43 Done.
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 InspectorBaseControllerInterface {
+public:
+
+ InspectorBaseControllerInterface(const String& name, InstrumentingAgents*, InspectorCompositeState*);
pfeldman 2013/06/18 15:36:06 Nit: I'd push it even further.
Vladislav Kaznacheev 2013/06/19 12:58:43 We will eventually On 2013/06/18 15:36:06, pfeldma
+ ~InspectorBaseControllerInterface();
pfeldman 2013/06/18 15:36:06 virtual ?
Vladislav Kaznacheev 2013/06/19 12:58:43 Done.
+
+ void setAgent(PassRefPtr<InspectorBaseAgent>);
+
+ virtual void setFrontend(InspectorFrontend*);
+ virtual void clearFrontend();
+ virtual void restore();
+ virtual void registerInDispatcher(InspectorBackendDispatcher*) = 0;
+ virtual void discardAgent();
pfeldman 2013/06/18 15:36:06 discardController
Vladislav Kaznacheev 2013/06/19 12:58:43 Renamed to discardDependencies because that is wha
virtual void reportMemoryUsage(MemoryObjectInfo*) const;
@@ -62,13 +82,15 @@ protected:
InstrumentingAgents* m_instrumentingAgents;
InspectorState* m_state;
+ RefPtr<InspectorBaseAgent> m_agent;
+
private:
- String m_name;
+ InspectorFrontend* m_frontend;
};
class InspectorAgentRegistry {
public:
- void append(PassOwnPtr<InspectorBaseAgentInterface>);
+ void append(PassOwnPtr<InspectorBaseControllerInterface>);
void setFrontend(InspectorFrontend*);
void clearFrontend();
@@ -79,22 +101,26 @@ public:
virtual void reportMemoryUsage(MemoryObjectInfo*) const;
private:
- Vector<OwnPtr<InspectorBaseAgentInterface> > m_agents;
+ Vector<OwnPtr<InspectorBaseControllerInterface> > m_controllers;
};
-template<typename T>
-class InspectorBaseAgent : public InspectorBaseAgentInterface {
+template<typename T, typename AGENT>
pfeldman 2013/06/18 15:36:06 Agent
Vladislav Kaznacheev 2013/06/19 12:58:43 Done.
+class InspectorBaseController : public InspectorBaseControllerInterface, public AGENT::Controller {
public:
- virtual ~InspectorBaseAgent() { }
-
+ // InspectorBaseControllerInterface implementation
virtual void registerInDispatcher(InspectorBackendDispatcher* dispatcher)
{
dispatcher->registerAgent(static_cast<T*>(this));
}
+ AGENT* getAgent() { return static_cast<AGENT*>(m_agent.get()); }
pfeldman 2013/06/18 15:36:06 agent()
Vladislav Kaznacheev 2013/06/19 12:58:43 Done.
+
+ // AGENT::Controller implementation
+ virtual AGENT* getCommandHandler() { return getAgent(); }
pfeldman 2013/06/18 15:36:06 commandHandler
Vladislav Kaznacheev 2013/06/19 12:58:43 Done.
+
protected:
- InspectorBaseAgent(const String& name, InstrumentingAgents* instrumentingAgents, InspectorCompositeState* inspectorState)
- : InspectorBaseAgentInterface(name, instrumentingAgents, inspectorState)
+ InspectorBaseController(const String& name, InstrumentingAgents* instrumentingAgents, InspectorCompositeState* compositeState)
+ : InspectorBaseControllerInterface(name, instrumentingAgents, compositeState)
{
}
};

Powered by Google App Engine
This is Rietveld 408576698