OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 14 matching lines...) Expand all Loading... | |
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 */ | 29 */ |
30 | 30 |
31 #ifndef InspectorBaseAgent_h | 31 #ifndef InspectorBaseAgent_h |
32 #define InspectorBaseAgent_h | 32 #define InspectorBaseAgent_h |
33 | 33 |
34 #include "InspectorBackendDispatcher.h" | 34 #include "InspectorBackendDispatcher.h" |
35 #include <wtf/Forward.h> | 35 #include "wtf/Forward.h" |
36 #include <wtf/Vector.h> | 36 #include "wtf/PassOwnPtr.h" |
37 #include <wtf/text/WTFString.h> | 37 #include "wtf/RefCounted.h" |
38 #include "wtf/Vector.h" | |
39 #include "wtf/text/WTFString.h" | |
38 | 40 |
39 namespace WebCore { | 41 namespace WebCore { |
40 | 42 |
41 class InspectorFrontend; | 43 class InspectorFrontend; |
42 class InspectorCompositeState; | 44 class InspectorCompositeState; |
43 class InspectorState; | 45 class InspectorState; |
44 class InstrumentingAgents; | 46 class InstrumentingAgents; |
45 | 47 |
46 class InspectorBaseAgentInterface { | 48 class InspectorBaseAgent : public RefCounted<InspectorBaseAgent> { |
47 public: | 49 public: |
48 InspectorBaseAgentInterface(const String&, InstrumentingAgents*, InspectorCo mpositeState*); | 50 InspectorBaseAgent(InstrumentingAgents*, InspectorState*); |
49 virtual ~InspectorBaseAgentInterface(); | 51 virtual ~InspectorBaseAgent(); |
50 | 52 |
51 virtual void setFrontend(InspectorFrontend*) { } | 53 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.
| |
52 virtual void clearFrontend() { } | 54 virtual void clearFrontend() { } |
53 virtual void restore() { } | 55 virtual void restore() { } |
54 virtual void registerInDispatcher(InspectorBackendDispatcher*) = 0; | |
55 virtual void discardAgent() { } | 56 virtual void discardAgent() { } |
56 | 57 |
57 String name() { return m_name; } | |
58 | |
59 virtual void reportMemoryUsage(MemoryObjectInfo*) const; | 58 virtual void reportMemoryUsage(MemoryObjectInfo*) const; |
60 | 59 |
60 protected: | |
61 InstrumentingAgents* m_instrumentingAgents; | |
62 InspectorState* m_state; | |
63 }; | |
64 | |
65 class InspectorBaseControllerInterface { | |
66 public: | |
67 | |
68 InspectorBaseControllerInterface(const String& name, InstrumentingAgents*, I nspectorCompositeState*); | |
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
| |
69 ~InspectorBaseControllerInterface(); | |
pfeldman
2013/06/18 15:36:06
virtual ?
Vladislav Kaznacheev
2013/06/19 12:58:43
Done.
| |
70 | |
71 void setAgent(PassRefPtr<InspectorBaseAgent>); | |
72 | |
73 virtual void setFrontend(InspectorFrontend*); | |
74 virtual void clearFrontend(); | |
75 virtual void restore(); | |
76 virtual void registerInDispatcher(InspectorBackendDispatcher*) = 0; | |
77 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
| |
78 | |
79 virtual void reportMemoryUsage(MemoryObjectInfo*) const; | |
80 | |
61 protected: | 81 protected: |
62 InstrumentingAgents* m_instrumentingAgents; | 82 InstrumentingAgents* m_instrumentingAgents; |
63 InspectorState* m_state; | 83 InspectorState* m_state; |
64 | 84 |
85 RefPtr<InspectorBaseAgent> m_agent; | |
86 | |
65 private: | 87 private: |
66 String m_name; | 88 InspectorFrontend* m_frontend; |
67 }; | 89 }; |
68 | 90 |
69 class InspectorAgentRegistry { | 91 class InspectorAgentRegistry { |
70 public: | 92 public: |
71 void append(PassOwnPtr<InspectorBaseAgentInterface>); | 93 void append(PassOwnPtr<InspectorBaseControllerInterface>); |
72 | 94 |
73 void setFrontend(InspectorFrontend*); | 95 void setFrontend(InspectorFrontend*); |
74 void clearFrontend(); | 96 void clearFrontend(); |
75 void restore(); | 97 void restore(); |
76 void registerInDispatcher(InspectorBackendDispatcher*); | 98 void registerInDispatcher(InspectorBackendDispatcher*); |
77 void discardAgents(); | 99 void discardAgents(); |
78 | 100 |
79 virtual void reportMemoryUsage(MemoryObjectInfo*) const; | 101 virtual void reportMemoryUsage(MemoryObjectInfo*) const; |
80 | 102 |
81 private: | 103 private: |
82 Vector<OwnPtr<InspectorBaseAgentInterface> > m_agents; | 104 Vector<OwnPtr<InspectorBaseControllerInterface> > m_controllers; |
83 }; | 105 }; |
84 | 106 |
85 template<typename T> | 107 template<typename T, typename AGENT> |
pfeldman
2013/06/18 15:36:06
Agent
Vladislav Kaznacheev
2013/06/19 12:58:43
Done.
| |
86 class InspectorBaseAgent : public InspectorBaseAgentInterface { | 108 class InspectorBaseController : public InspectorBaseControllerInterface, public AGENT::Controller { |
87 public: | 109 public: |
88 virtual ~InspectorBaseAgent() { } | 110 // InspectorBaseControllerInterface implementation |
89 | |
90 virtual void registerInDispatcher(InspectorBackendDispatcher* dispatcher) | 111 virtual void registerInDispatcher(InspectorBackendDispatcher* dispatcher) |
91 { | 112 { |
92 dispatcher->registerAgent(static_cast<T*>(this)); | 113 dispatcher->registerAgent(static_cast<T*>(this)); |
93 } | 114 } |
94 | 115 |
116 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.
| |
117 | |
118 // AGENT::Controller implementation | |
119 virtual AGENT* getCommandHandler() { return getAgent(); } | |
pfeldman
2013/06/18 15:36:06
commandHandler
Vladislav Kaznacheev
2013/06/19 12:58:43
Done.
| |
120 | |
95 protected: | 121 protected: |
96 InspectorBaseAgent(const String& name, InstrumentingAgents* instrumentingAge nts, InspectorCompositeState* inspectorState) | 122 InspectorBaseController(const String& name, InstrumentingAgents* instrumenti ngAgents, InspectorCompositeState* compositeState) |
97 : InspectorBaseAgentInterface(name, instrumentingAgents, inspectorState) | 123 : InspectorBaseControllerInterface(name, instrumentingAgents, compositeS tate) |
98 { | 124 { |
99 } | 125 } |
100 }; | 126 }; |
101 | 127 |
102 } // namespace WebCore | 128 } // namespace WebCore |
103 | 129 |
104 #endif // !defined(InspectorBaseAgent_h) | 130 #endif // !defined(InspectorBaseAgent_h) |
OLD | NEW |