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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 | 73 |
74 InspectorController::InspectorController(Page* page, InspectorClient* inspectorC
lient) | 74 InspectorController::InspectorController(Page* page, InspectorClient* inspectorC
lient) |
75 : m_instrumentingAgents(InstrumentingAgents::create()) | 75 : m_instrumentingAgents(InstrumentingAgents::create()) |
76 , m_injectedScriptManager(InjectedScriptManager::createForPage()) | 76 , m_injectedScriptManager(InjectedScriptManager::createForPage()) |
77 , m_state(adoptPtr(new InspectorCompositeState(inspectorClient))) | 77 , m_state(adoptPtr(new InspectorCompositeState(inspectorClient))) |
78 , m_overlay(InspectorOverlay::create(page, inspectorClient)) | 78 , m_overlay(InspectorOverlay::create(page, inspectorClient)) |
79 , m_page(page) | 79 , m_page(page) |
80 , m_inspectorClient(inspectorClient) | 80 , m_inspectorClient(inspectorClient) |
81 , m_agents(m_instrumentingAgents.get(), m_state.get()) | 81 , m_agents(m_instrumentingAgents.get(), m_state.get()) |
82 , m_isUnderTest(false) | 82 , m_isUnderTest(false) |
| 83 , m_deferredAgentsInitialized(false) |
83 { | 84 { |
84 m_agents.append(InspectorInspectorAgent::create(page, m_injectedScriptManage
r.get())); | 85 InjectedScriptManager* injectedScriptManager = m_injectedScriptManager.get()
; |
| 86 InspectorOverlay* overlay = m_overlay.get(); |
85 | 87 |
86 OwnPtr<InspectorPageAgent> pageAgentPtr(InspectorPageAgent::create(page, m_i
njectedScriptManager.get(), inspectorClient, m_overlay.get())); | 88 m_agents.append(InspectorInspectorAgent::create(m_page, injectedScriptManage
r)); |
87 InspectorPageAgent* pageAgent = pageAgentPtr.get(); | 89 |
| 90 OwnPtr<InspectorPageAgent> pageAgentPtr(InspectorPageAgent::create(m_page, i
njectedScriptManager, inspectorClient, overlay)); |
| 91 m_pageAgent = pageAgentPtr.get(); |
88 m_agents.append(pageAgentPtr.release()); | 92 m_agents.append(pageAgentPtr.release()); |
89 | 93 |
90 OwnPtr<InspectorDOMAgent> domAgentPtr(InspectorDOMAgent::create(pageAgent, m
_injectedScriptManager.get(), m_overlay.get())); | 94 OwnPtr<InspectorDOMAgent> domAgentPtr(InspectorDOMAgent::create(m_pageAgent,
injectedScriptManager, overlay)); |
91 InspectorDOMAgent* domAgent = domAgentPtr.get(); | 95 m_domAgent = domAgentPtr.get(); |
92 m_agents.append(domAgentPtr.release()); | 96 m_agents.append(domAgentPtr.release()); |
93 | 97 |
94 OwnPtr<InspectorResourceAgent> resourceAgentPtr(InspectorResourceAgent::crea
te(pageAgent, inspectorClient)); | |
95 InspectorResourceAgent* resourceAgent = resourceAgentPtr.get(); | |
96 m_agents.append(resourceAgentPtr.release()); | |
97 | |
98 m_agents.append(InspectorCSSAgent::create(domAgent, pageAgent, resourceAgent
)); | |
99 | |
100 m_agents.append(InspectorDatabaseAgent::create()); | 98 m_agents.append(InspectorDatabaseAgent::create()); |
101 | 99 |
102 m_agents.append(InspectorIndexedDBAgent::create(m_injectedScriptManager.get(
), pageAgent)); | 100 OwnPtr<InspectorTimelineAgent> timelineAgentPtr(InspectorTimelineAgent::crea
te(m_pageAgent, m_domAgent, overlay, |
103 | |
104 m_agents.append(InspectorFileSystemAgent::create(pageAgent)); | |
105 | |
106 m_agents.append(InspectorDOMStorageAgent::create(pageAgent)); | |
107 | |
108 OwnPtr<InspectorMemoryAgent> memoryAgentPtr(InspectorMemoryAgent::create()); | |
109 m_memoryAgent = memoryAgentPtr.get(); | |
110 m_agents.append(memoryAgentPtr.release()); | |
111 | |
112 OwnPtr<InspectorTimelineAgent> timelineAgentPtr(InspectorTimelineAgent::crea
te(pageAgent, domAgent, m_overlay.get(), | |
113 InspectorTimelineAgent::PageInspector, inspectorClient)); | 101 InspectorTimelineAgent::PageInspector, inspectorClient)); |
114 m_timelineAgent = timelineAgentPtr.get(); | 102 m_timelineAgent = timelineAgentPtr.get(); |
115 m_agents.append(timelineAgentPtr.release()); | 103 m_agents.append(timelineAgentPtr.release()); |
116 | 104 |
117 m_agents.append(InspectorApplicationCacheAgent::create(pageAgent)); | |
118 | |
119 PageScriptDebugServer* pageScriptDebugServer = &PageScriptDebugServer::share
d(); | 105 PageScriptDebugServer* pageScriptDebugServer = &PageScriptDebugServer::share
d(); |
120 | 106 |
121 m_agents.append(PageRuntimeAgent::create(m_injectedScriptManager.get(), page
ScriptDebugServer, page, pageAgent)); | 107 m_agents.append(PageRuntimeAgent::create(injectedScriptManager, pageScriptDe
bugServer, m_page, m_pageAgent)); |
122 | 108 |
123 m_agents.append(PageConsoleAgent::create(m_injectedScriptManager.get(), domA
gent, m_timelineAgent)); | 109 m_agents.append(PageConsoleAgent::create(injectedScriptManager, m_domAgent,
m_timelineAgent)); |
124 | |
125 OwnPtr<InspectorDebuggerAgent> debuggerAgentPtr(PageDebuggerAgent::create(pa
geScriptDebugServer, pageAgent, m_injectedScriptManager.get(), m_overlay.get()))
; | |
126 InspectorDebuggerAgent* debuggerAgent = debuggerAgentPtr.get(); | |
127 m_agents.append(debuggerAgentPtr.release()); | |
128 | |
129 m_agents.append(InspectorDOMDebuggerAgent::create(domAgent, debuggerAgent)); | |
130 | |
131 m_agents.append(InspectorProfilerAgent::create(m_injectedScriptManager.get()
, m_overlay.get())); | |
132 | |
133 m_agents.append(InspectorHeapProfilerAgent::create(m_injectedScriptManager.g
et())); | |
134 | |
135 | 110 |
136 m_agents.append(InspectorWorkerAgent::create()); | 111 m_agents.append(InspectorWorkerAgent::create()); |
137 | 112 |
138 m_agents.append(InspectorCanvasAgent::create(pageAgent, m_injectedScriptMana
ger.get())); | |
139 | |
140 m_agents.append(InspectorInputAgent::create(page, inspectorClient)); | |
141 | |
142 m_agents.append(InspectorLayerTreeAgent::create(domAgent, page)); | |
143 | |
144 ASSERT_ARG(inspectorClient, inspectorClient); | 113 ASSERT_ARG(inspectorClient, inspectorClient); |
145 m_injectedScriptManager->injectedScriptHost()->init(m_instrumentingAgents.ge
t(), pageScriptDebugServer); | 114 m_injectedScriptManager->injectedScriptHost()->init(m_instrumentingAgents.ge
t(), pageScriptDebugServer); |
146 } | 115 } |
147 | 116 |
148 InspectorController::~InspectorController() | 117 InspectorController::~InspectorController() |
149 { | 118 { |
150 m_instrumentingAgents->reset(); | 119 m_instrumentingAgents->reset(); |
151 m_agents.discardAgents(); | 120 m_agents.discardAgents(); |
152 ASSERT(!m_inspectorClient); | 121 ASSERT(!m_inspectorClient); |
153 } | 122 } |
154 | 123 |
155 PassOwnPtr<InspectorController> InspectorController::create(Page* page, Inspecto
rClient* client) | 124 PassOwnPtr<InspectorController> InspectorController::create(Page* page, Inspecto
rClient* client) |
156 { | 125 { |
157 return adoptPtr(new InspectorController(page, client)); | 126 return adoptPtr(new InspectorController(page, client)); |
158 } | 127 } |
159 | 128 |
| 129 void InspectorController::initializeDeferredAgents() |
| 130 { |
| 131 if (m_deferredAgentsInitialized) |
| 132 return; |
| 133 m_deferredAgentsInitialized = true; |
| 134 |
| 135 InjectedScriptManager* injectedScriptManager = m_injectedScriptManager.get()
; |
| 136 InspectorOverlay* overlay = m_overlay.get(); |
| 137 |
| 138 OwnPtr<InspectorResourceAgent> resourceAgentPtr(InspectorResourceAgent::crea
te(m_pageAgent, m_inspectorClient)); |
| 139 InspectorResourceAgent* resourceAgent = resourceAgentPtr.get(); |
| 140 m_agents.append(resourceAgentPtr.release()); |
| 141 |
| 142 m_agents.append(InspectorCSSAgent::create(m_domAgent, m_pageAgent, resourceA
gent)); |
| 143 |
| 144 m_agents.append(InspectorIndexedDBAgent::create(injectedScriptManager, m_pag
eAgent)); |
| 145 |
| 146 m_agents.append(InspectorFileSystemAgent::create(m_pageAgent)); |
| 147 |
| 148 m_agents.append(InspectorDOMStorageAgent::create(m_pageAgent)); |
| 149 |
| 150 m_agents.append(InspectorMemoryAgent::create()); |
| 151 |
| 152 m_agents.append(InspectorApplicationCacheAgent::create(m_pageAgent)); |
| 153 |
| 154 PageScriptDebugServer* pageScriptDebugServer = &PageScriptDebugServer::share
d(); |
| 155 |
| 156 OwnPtr<InspectorDebuggerAgent> debuggerAgentPtr(PageDebuggerAgent::create(pa
geScriptDebugServer, m_pageAgent, injectedScriptManager, overlay)); |
| 157 InspectorDebuggerAgent* debuggerAgent = debuggerAgentPtr.get(); |
| 158 m_agents.append(debuggerAgentPtr.release()); |
| 159 |
| 160 m_agents.append(InspectorDOMDebuggerAgent::create(m_domAgent, debuggerAgent)
); |
| 161 |
| 162 m_agents.append(InspectorProfilerAgent::create(injectedScriptManager, overla
y)); |
| 163 |
| 164 m_agents.append(InspectorHeapProfilerAgent::create(injectedScriptManager)); |
| 165 |
| 166 m_agents.append(InspectorCanvasAgent::create(m_pageAgent, injectedScriptMana
ger)); |
| 167 |
| 168 m_agents.append(InspectorInputAgent::create(m_page, m_inspectorClient)); |
| 169 |
| 170 m_agents.append(InspectorLayerTreeAgent::create(m_domAgent, m_page)); |
| 171 } |
| 172 |
160 void InspectorController::inspectedPageDestroyed() | 173 void InspectorController::inspectedPageDestroyed() |
161 { | 174 { |
162 disconnectFrontend(); | 175 disconnectFrontend(); |
163 m_injectedScriptManager->disconnect(); | 176 m_injectedScriptManager->disconnect(); |
164 m_inspectorClient = 0; | 177 m_inspectorClient = 0; |
165 m_page = 0; | 178 m_page = 0; |
166 } | 179 } |
167 | 180 |
168 void InspectorController::registerModuleAgent(PassOwnPtr<InspectorAgent> agent) | 181 void InspectorController::registerModuleAgent(PassOwnPtr<InspectorAgent> agent) |
169 { | 182 { |
(...skipping 13 matching lines...) Expand all Loading... |
183 // If the page is supposed to serve as InspectorFrontend notify inspector fr
ontend | 196 // If the page is supposed to serve as InspectorFrontend notify inspector fr
ontend |
184 // client that it's cleared so that the client can expose inspector bindings
. | 197 // client that it's cleared so that the client can expose inspector bindings
. |
185 if (m_inspectorFrontendClient && frame == m_page->mainFrame()) | 198 if (m_inspectorFrontendClient && frame == m_page->mainFrame()) |
186 m_inspectorFrontendClient->windowObjectCleared(); | 199 m_inspectorFrontendClient->windowObjectCleared(); |
187 } | 200 } |
188 | 201 |
189 void InspectorController::connectFrontend(InspectorFrontendChannel* frontendChan
nel) | 202 void InspectorController::connectFrontend(InspectorFrontendChannel* frontendChan
nel) |
190 { | 203 { |
191 ASSERT(frontendChannel); | 204 ASSERT(frontendChannel); |
192 | 205 |
| 206 initializeDeferredAgents(); |
| 207 |
193 m_inspectorFrontend = adoptPtr(new InspectorFrontend(frontendChannel)); | 208 m_inspectorFrontend = adoptPtr(new InspectorFrontend(frontendChannel)); |
194 // We can reconnect to existing front-end -> unmute state. | 209 // We can reconnect to existing front-end -> unmute state. |
195 m_state->unmute(); | 210 m_state->unmute(); |
196 | 211 |
197 m_agents.setFrontend(m_inspectorFrontend.get()); | 212 m_agents.setFrontend(m_inspectorFrontend.get()); |
198 | 213 |
199 InspectorInstrumentation::registerInstrumentingAgents(m_instrumentingAgents.
get()); | 214 InspectorInstrumentation::registerInstrumentingAgents(m_instrumentingAgents.
get()); |
200 InspectorInstrumentation::frontendCreated(); | 215 InspectorInstrumentation::frontendCreated(); |
201 | 216 |
202 ASSERT(m_inspectorClient); | 217 ASSERT(m_inspectorClient); |
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
435 timelineAgent->didComposite(); | 450 timelineAgent->didComposite(); |
436 } | 451 } |
437 | 452 |
438 void InspectorController::processGPUEvent(double timestamp, int phase, bool fore
ign, size_t usedGPUMemoryBytes) | 453 void InspectorController::processGPUEvent(double timestamp, int phase, bool fore
ign, size_t usedGPUMemoryBytes) |
439 { | 454 { |
440 if (InspectorTimelineAgent* timelineAgent = m_instrumentingAgents->inspector
TimelineAgent()) | 455 if (InspectorTimelineAgent* timelineAgent = m_instrumentingAgents->inspector
TimelineAgent()) |
441 timelineAgent->processGPUEvent(InspectorTimelineAgent::GPUEvent(timestam
p, phase, foreign, usedGPUMemoryBytes)); | 456 timelineAgent->processGPUEvent(InspectorTimelineAgent::GPUEvent(timestam
p, phase, foreign, usedGPUMemoryBytes)); |
442 } | 457 } |
443 | 458 |
444 } // namespace WebCore | 459 } // namespace WebCore |
OLD | NEW |