Chromium Code Reviews| 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 16 matching lines...) Expand all Loading... | |
| 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 #include "config.h" | 31 #include "config.h" |
| 32 #include "core/inspector/InspectorController.h" | 32 #include "core/inspector/InspectorController.h" |
| 33 | 33 |
| 34 #include "InspectorBackendDispatcher.h" | 34 #include "InspectorBackendDispatcher.h" |
| 35 #include "InspectorFrontend.h" | 35 #include "InspectorFrontend.h" |
| 36 #include "bindings/v8/DOMWrapperWorld.h" | 36 #include "bindings/v8/DOMWrapperWorld.h" |
| 37 #include "core/html/VoidCallback.h" | |
| 37 #include "core/inspector/IdentifiersFactory.h" | 38 #include "core/inspector/IdentifiersFactory.h" |
| 38 #include "core/inspector/InjectedScriptHost.h" | 39 #include "core/inspector/InjectedScriptHost.h" |
| 39 #include "core/inspector/InjectedScriptManager.h" | 40 #include "core/inspector/InjectedScriptManager.h" |
| 40 #include "core/inspector/InspectorApplicationCacheAgent.h" | 41 #include "core/inspector/InspectorApplicationCacheAgent.h" |
| 41 #include "core/inspector/InspectorCSSAgent.h" | 42 #include "core/inspector/InspectorCSSAgent.h" |
| 42 #include "core/inspector/InspectorCanvasAgent.h" | 43 #include "core/inspector/InspectorCanvasAgent.h" |
| 43 #include "core/inspector/InspectorClient.h" | 44 #include "core/inspector/InspectorClient.h" |
| 44 #include "core/inspector/InspectorDOMAgent.h" | 45 #include "core/inspector/InspectorDOMAgent.h" |
| 45 #include "core/inspector/InspectorDOMDebuggerAgent.h" | 46 #include "core/inspector/InspectorDOMDebuggerAgent.h" |
| 46 #include "core/inspector/InspectorDOMStorageAgent.h" | 47 #include "core/inspector/InspectorDOMStorageAgent.h" |
| 47 #include "core/inspector/InspectorDebuggerAgent.h" | 48 #include "core/inspector/InspectorDebuggerAgent.h" |
| 48 #include "core/inspector/InspectorFrontendClient.h" | 49 #include "core/inspector/InspectorFrontendClient.h" |
| 49 #include "core/inspector/InspectorHeapProfilerAgent.h" | 50 #include "core/inspector/InspectorHeapProfilerAgent.h" |
| 50 #include "core/inspector/InspectorInputAgent.h" | 51 #include "core/inspector/InspectorInputAgent.h" |
| 51 #include "core/inspector/InspectorInspectorAgent.h" | 52 #include "core/inspector/InspectorInspectorAgent.h" |
| 52 #include "core/inspector/InspectorInstrumentation.h" | 53 #include "core/inspector/InspectorInstrumentation.h" |
| 53 #include "core/inspector/InspectorLayerTreeAgent.h" | 54 #include "core/inspector/InspectorLayerTreeAgent.h" |
| 54 #include "core/inspector/InspectorMemoryAgent.h" | 55 #include "core/inspector/InspectorMemoryAgent.h" |
| 55 #include "core/inspector/InspectorOverlay.h" | 56 #include "core/inspector/InspectorOverlay.h" |
| 56 #include "core/inspector/InspectorPageAgent.h" | 57 #include "core/inspector/InspectorPageAgent.h" |
| 57 #include "core/inspector/InspectorProfilerAgent.h" | 58 #include "core/inspector/InspectorProfilerAgent.h" |
| 58 #include "core/inspector/InspectorResourceAgent.h" | 59 #include "core/inspector/InspectorResourceAgent.h" |
| 60 #include "core/inspector/InspectorResourceContentLoader.h" | |
| 59 #include "core/inspector/InspectorState.h" | 61 #include "core/inspector/InspectorState.h" |
| 60 #include "core/inspector/InspectorTimelineAgent.h" | 62 #include "core/inspector/InspectorTimelineAgent.h" |
| 61 #include "core/inspector/InspectorTracingAgent.h" | 63 #include "core/inspector/InspectorTracingAgent.h" |
| 62 #include "core/inspector/InspectorWorkerAgent.h" | 64 #include "core/inspector/InspectorWorkerAgent.h" |
| 63 #include "core/inspector/InstrumentingAgents.h" | 65 #include "core/inspector/InstrumentingAgents.h" |
| 64 #include "core/inspector/PageConsoleAgent.h" | 66 #include "core/inspector/PageConsoleAgent.h" |
| 65 #include "core/inspector/PageDebuggerAgent.h" | 67 #include "core/inspector/PageDebuggerAgent.h" |
| 66 #include "core/inspector/PageRuntimeAgent.h" | 68 #include "core/inspector/PageRuntimeAgent.h" |
| 67 #include "core/page/Page.h" | 69 #include "core/page/Page.h" |
| 68 #include "core/rendering/RenderLayer.h" | 70 #include "core/rendering/RenderLayer.h" |
| 69 #include "platform/PlatformMouseEvent.h" | 71 #include "platform/PlatformMouseEvent.h" |
| 70 | 72 |
| 71 namespace WebCore { | 73 namespace WebCore { |
| 72 | 74 |
| 75 class InspectorController::InspectorResourceContentLoaderCallback FINAL : public VoidCallback { | |
| 76 public: | |
| 77 InspectorResourceContentLoaderCallback(InspectorController*); | |
| 78 virtual void handleEvent() OVERRIDE; | |
| 79 | |
| 80 private: | |
| 81 InspectorController* m_inspectorController; | |
| 82 }; | |
| 83 | |
| 84 InspectorController::InspectorResourceContentLoaderCallback::InspectorResourceCo ntentLoaderCallback(InspectorController* inspectorController) | |
| 85 : m_inspectorController(inspectorController) | |
| 86 { | |
| 87 } | |
| 88 | |
| 89 void InspectorController::InspectorResourceContentLoaderCallback::handleEvent() | |
| 90 { | |
| 91 m_inspectorController->resourcesContentLoaded(); | |
| 92 } | |
| 93 | |
| 73 InspectorController::InspectorController(Page* page, InspectorClient* inspectorC lient) | 94 InspectorController::InspectorController(Page* page, InspectorClient* inspectorC lient) |
| 74 : m_instrumentingAgents(InstrumentingAgents::create()) | 95 : m_instrumentingAgents(InstrumentingAgents::create()) |
| 75 , m_injectedScriptManager(InjectedScriptManager::createForPage()) | 96 , m_injectedScriptManager(InjectedScriptManager::createForPage()) |
| 76 , m_state(adoptPtr(new InspectorCompositeState(inspectorClient))) | 97 , m_state(adoptPtr(new InspectorCompositeState(inspectorClient))) |
| 77 , m_overlay(InspectorOverlay::create(page, inspectorClient)) | 98 , m_overlay(InspectorOverlay::create(page, inspectorClient)) |
| 78 , m_layerTreeAgent(0) | 99 , m_layerTreeAgent(0) |
| 79 , m_page(page) | 100 , m_page(page) |
| 80 , m_inspectorClient(inspectorClient) | 101 , m_inspectorClient(inspectorClient) |
| 81 , m_agents(m_instrumentingAgents.get(), m_state.get()) | 102 , m_agents(m_instrumentingAgents.get(), m_state.get()) |
| 82 , m_isUnderTest(false) | 103 , m_isUnderTest(false) |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 142 | 163 |
| 143 void InspectorController::initializeDeferredAgents() | 164 void InspectorController::initializeDeferredAgents() |
| 144 { | 165 { |
| 145 if (m_deferredAgentsInitialized) | 166 if (m_deferredAgentsInitialized) |
| 146 return; | 167 return; |
| 147 m_deferredAgentsInitialized = true; | 168 m_deferredAgentsInitialized = true; |
| 148 | 169 |
| 149 InjectedScriptManager* injectedScriptManager = m_injectedScriptManager.get() ; | 170 InjectedScriptManager* injectedScriptManager = m_injectedScriptManager.get() ; |
| 150 InspectorOverlay* overlay = m_overlay.get(); | 171 InspectorOverlay* overlay = m_overlay.get(); |
| 151 | 172 |
| 152 OwnPtr<InspectorResourceAgent> resourceAgentPtr(InspectorResourceAgent::crea te(m_pageAgent)); | 173 m_agents.append(InspectorCSSAgent::create(m_domAgent, m_pageAgent)); |
| 153 InspectorResourceAgent* resourceAgent = resourceAgentPtr.get(); | |
| 154 m_agents.append(resourceAgentPtr.release()); | |
| 155 | |
| 156 m_agents.append(InspectorCSSAgent::create(m_domAgent, m_pageAgent, resourceA gent)); | |
| 157 | 174 |
| 158 m_agents.append(InspectorDOMStorageAgent::create(m_pageAgent)); | 175 m_agents.append(InspectorDOMStorageAgent::create(m_pageAgent)); |
| 159 | 176 |
| 160 m_agents.append(InspectorMemoryAgent::create()); | 177 m_agents.append(InspectorMemoryAgent::create()); |
| 161 | 178 |
| 162 m_agents.append(InspectorApplicationCacheAgent::create(m_pageAgent)); | 179 m_agents.append(InspectorApplicationCacheAgent::create(m_pageAgent)); |
| 163 | 180 |
| 181 m_agents.append(InspectorResourceAgent::create(m_pageAgent)); | |
| 182 | |
| 164 PageScriptDebugServer* pageScriptDebugServer = &PageScriptDebugServer::share d(); | 183 PageScriptDebugServer* pageScriptDebugServer = &PageScriptDebugServer::share d(); |
| 165 | 184 |
| 166 OwnPtr<InspectorDebuggerAgent> debuggerAgentPtr(PageDebuggerAgent::create(pa geScriptDebugServer, m_pageAgent, injectedScriptManager, overlay)); | 185 OwnPtr<InspectorDebuggerAgent> debuggerAgentPtr(PageDebuggerAgent::create(pa geScriptDebugServer, m_pageAgent, injectedScriptManager, overlay)); |
| 167 InspectorDebuggerAgent* debuggerAgent = debuggerAgentPtr.get(); | 186 InspectorDebuggerAgent* debuggerAgent = debuggerAgentPtr.get(); |
| 168 m_agents.append(debuggerAgentPtr.release()); | 187 m_agents.append(debuggerAgentPtr.release()); |
| 169 | 188 |
| 170 m_agents.append(InspectorDOMDebuggerAgent::create(m_domAgent, debuggerAgent) ); | 189 m_agents.append(InspectorDOMDebuggerAgent::create(m_domAgent, debuggerAgent) ); |
| 171 | 190 |
| 172 m_agents.append(InspectorProfilerAgent::create(injectedScriptManager, overla y)); | 191 m_agents.append(InspectorProfilerAgent::create(injectedScriptManager, overla y)); |
| 173 | 192 |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 200 } | 219 } |
| 201 | 220 |
| 202 void InspectorController::didClearDocumentOfWindowObject(LocalFrame* frame) | 221 void InspectorController::didClearDocumentOfWindowObject(LocalFrame* frame) |
| 203 { | 222 { |
| 204 // If the page is supposed to serve as InspectorFrontend notify inspector fr ontend | 223 // If the page is supposed to serve as InspectorFrontend notify inspector fr ontend |
| 205 // client that it's cleared so that the client can expose inspector bindings . | 224 // client that it's cleared so that the client can expose inspector bindings . |
| 206 if (m_inspectorFrontendClient && frame == m_page->mainFrame()) | 225 if (m_inspectorFrontendClient && frame == m_page->mainFrame()) |
| 207 m_inspectorFrontendClient->windowObjectCleared(); | 226 m_inspectorFrontendClient->windowObjectCleared(); |
| 208 } | 227 } |
| 209 | 228 |
| 210 void InspectorController::connectFrontend(InspectorFrontendChannel* frontendChan nel) | 229 void InspectorController::connectFrontend(InspectorFrontendChannel* frontendChan nel, bool isReusing) |
| 211 { | 230 { |
| 212 ASSERT(frontendChannel); | 231 ASSERT(frontendChannel); |
| 213 | 232 |
| 214 initializeDeferredAgents(); | 233 initializeDeferredAgents(); |
| 215 | 234 |
| 216 m_inspectorFrontend = adoptPtr(new InspectorFrontend(frontendChannel)); | 235 m_inspectorFrontend = adoptPtr(new InspectorFrontend(frontendChannel)); |
| 217 // We can reconnect to existing front-end -> unmute state. | 236 // We can reconnect to existing front-end -> unmute state. |
| 218 m_state->unmute(); | 237 m_state->unmute(); |
| 219 | 238 |
| 220 m_agents.setFrontend(m_inspectorFrontend.get()); | 239 m_agents.setFrontend(m_inspectorFrontend.get()); |
| 221 | 240 |
| 222 InspectorInstrumentation::registerInstrumentingAgents(m_instrumentingAgents. get()); | 241 InspectorInstrumentation::registerInstrumentingAgents(m_instrumentingAgents. get()); |
| 223 InspectorInstrumentation::frontendCreated(); | 242 InspectorInstrumentation::frontendCreated(); |
| 224 | 243 |
| 225 ASSERT(m_inspectorClient); | 244 ASSERT(m_inspectorClient); |
| 226 m_inspectorBackendDispatcher = InspectorBackendDispatcher::create(frontendCh annel); | 245 m_inspectorBackendDispatcher = InspectorBackendDispatcher::create(frontendCh annel); |
| 227 | 246 |
| 228 m_agents.registerInDispatcher(m_inspectorBackendDispatcher.get()); | 247 m_agents.registerInDispatcher(m_inspectorBackendDispatcher.get()); |
| 248 | |
| 249 if (!isReusing) | |
| 250 m_inspectorResourceContentLoader = adoptPtr(new InspectorResourceContent Loader(m_page, adoptPtr(new InspectorResourceContentLoaderCallback(this)))); | |
| 251 } | |
| 252 | |
| 253 void InspectorController::resourcesContentLoaded() | |
| 254 { | |
| 255 for (Vector<String>::const_iterator it = m_messages.begin(); it != m_message s.end(); ++it) | |
|
pfeldman
2014/05/20 19:50:49
You want to iterate a copy just in case.
| |
| 256 dispatchMessageFromFrontend(*it); | |
| 257 m_messages.clear(); | |
| 229 } | 258 } |
| 230 | 259 |
| 231 void InspectorController::disconnectFrontend() | 260 void InspectorController::disconnectFrontend() |
| 232 { | 261 { |
| 233 if (!m_inspectorFrontend) | 262 if (!m_inspectorFrontend) |
| 234 return; | 263 return; |
| 264 m_inspectorResourceContentLoader.clear(); | |
| 235 m_inspectorBackendDispatcher->clearFrontend(); | 265 m_inspectorBackendDispatcher->clearFrontend(); |
| 236 m_inspectorBackendDispatcher.clear(); | 266 m_inspectorBackendDispatcher.clear(); |
| 237 | 267 |
| 238 // Destroying agents would change the state, but we don't want that. | 268 // Destroying agents would change the state, but we don't want that. |
| 239 // Pre-disconnect state will be used to restore inspector agents. | 269 // Pre-disconnect state will be used to restore inspector agents. |
| 240 m_state->mute(); | 270 m_state->mute(); |
| 241 | 271 |
| 242 m_agents.clearFrontend(); | 272 m_agents.clearFrontend(); |
| 243 | 273 |
| 244 m_inspectorFrontend.clear(); | 274 m_inspectorFrontend.clear(); |
| 245 | 275 |
| 246 // relese overlay page resources | 276 // relese overlay page resources |
| 247 m_overlay->freePage(); | 277 m_overlay->freePage(); |
| 248 InspectorInstrumentation::frontendDeleted(); | 278 InspectorInstrumentation::frontendDeleted(); |
| 249 InspectorInstrumentation::unregisterInstrumentingAgents(m_instrumentingAgent s.get()); | 279 InspectorInstrumentation::unregisterInstrumentingAgents(m_instrumentingAgent s.get()); |
| 250 } | 280 } |
| 251 | 281 |
| 252 void InspectorController::reconnectFrontend() | 282 void InspectorController::reconnectFrontend() |
| 253 { | 283 { |
| 254 if (!m_inspectorFrontend) | 284 if (!m_inspectorFrontend) |
| 255 return; | 285 return; |
| 256 InspectorFrontendChannel* frontendChannel = m_inspectorFrontend->channel(); | 286 InspectorFrontendChannel* frontendChannel = m_inspectorFrontend->channel(); |
| 257 disconnectFrontend(); | 287 disconnectFrontend(); |
| 258 connectFrontend(frontendChannel); | 288 connectFrontend(frontendChannel); |
| 259 } | 289 } |
| 260 | 290 |
| 261 void InspectorController::reuseFrontend(InspectorFrontendChannel* frontendChanne l, const String& inspectorStateCookie) | 291 void InspectorController::reuseFrontend(InspectorFrontendChannel* frontendChanne l, const String& inspectorStateCookie) |
| 262 { | 292 { |
| 263 ASSERT(!m_inspectorFrontend); | 293 ASSERT(!m_inspectorFrontend); |
| 264 connectFrontend(frontendChannel); | 294 connectFrontend(frontendChannel, true); |
| 265 m_state->loadFromCookie(inspectorStateCookie); | 295 m_state->loadFromCookie(inspectorStateCookie); |
| 266 m_agents.restore(); | 296 m_agents.restore(); |
| 267 } | 297 } |
| 268 | 298 |
| 269 void InspectorController::setProcessId(long processId) | 299 void InspectorController::setProcessId(long processId) |
| 270 { | 300 { |
| 271 IdentifiersFactory::setProcessId(processId); | 301 IdentifiersFactory::setProcessId(processId); |
| 272 } | 302 } |
| 273 | 303 |
| 274 void InspectorController::setLayerTreeId(int id) | 304 void InspectorController::setLayerTreeId(int id) |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 321 } | 351 } |
| 322 | 352 |
| 323 void InspectorController::setInjectedScriptForOrigin(const String& origin, const String& source) | 353 void InspectorController::setInjectedScriptForOrigin(const String& origin, const String& source) |
| 324 { | 354 { |
| 325 if (InspectorInspectorAgent* inspectorAgent = m_instrumentingAgents->inspect orInspectorAgent()) | 355 if (InspectorInspectorAgent* inspectorAgent = m_instrumentingAgents->inspect orInspectorAgent()) |
| 326 inspectorAgent->setInjectedScriptForOrigin(origin, source); | 356 inspectorAgent->setInjectedScriptForOrigin(origin, source); |
| 327 } | 357 } |
| 328 | 358 |
| 329 void InspectorController::dispatchMessageFromFrontend(const String& message) | 359 void InspectorController::dispatchMessageFromFrontend(const String& message) |
| 330 { | 360 { |
| 361 if (m_inspectorResourceContentLoader && !m_inspectorResourceContentLoader->h asFinished()) { | |
| 362 m_messages.append(message); | |
| 363 return; | |
| 364 } | |
| 365 | |
| 331 if (m_inspectorBackendDispatcher) | 366 if (m_inspectorBackendDispatcher) |
| 332 m_inspectorBackendDispatcher->dispatch(message); | 367 m_inspectorBackendDispatcher->dispatch(message); |
| 333 } | 368 } |
| 334 | 369 |
| 335 bool InspectorController::handleGestureEvent(LocalFrame* frame, const PlatformGe stureEvent& event) | 370 bool InspectorController::handleGestureEvent(LocalFrame* frame, const PlatformGe stureEvent& event) |
| 336 { | 371 { |
| 337 // Overlay should not consume events. | 372 // Overlay should not consume events. |
| 338 m_overlay->handleGestureEvent(event); | 373 m_overlay->handleGestureEvent(event); |
| 339 if (InspectorDOMAgent* domAgent = m_instrumentingAgents->inspectorDOMAgent() ) | 374 if (InspectorDOMAgent* domAgent = m_instrumentingAgents->inspectorDOMAgent() ) |
| 340 return domAgent->handleGestureEvent(frame, event); | 375 return domAgent->handleGestureEvent(frame, event); |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 418 domDebuggerAgent->didProcessTask(); | 453 domDebuggerAgent->didProcessTask(); |
| 419 } | 454 } |
| 420 | 455 |
| 421 void InspectorController::flushPendingFrontendMessages() | 456 void InspectorController::flushPendingFrontendMessages() |
| 422 { | 457 { |
| 423 m_agents.flushPendingFrontendMessages(); | 458 m_agents.flushPendingFrontendMessages(); |
| 424 } | 459 } |
| 425 | 460 |
| 426 void InspectorController::didCommitLoadForMainFrame() | 461 void InspectorController::didCommitLoadForMainFrame() |
| 427 { | 462 { |
| 463 m_inspectorResourceContentLoader.clear(); | |
| 428 Vector<InspectorAgent*> agents = m_moduleAgents; | 464 Vector<InspectorAgent*> agents = m_moduleAgents; |
| 429 for (size_t i = 0; i < agents.size(); i++) | 465 for (size_t i = 0; i < agents.size(); i++) |
| 430 agents[i]->didCommitLoadForMainFrame(); | 466 agents[i]->didCommitLoadForMainFrame(); |
| 431 } | 467 } |
| 432 | 468 |
| 433 void InspectorController::didBeginFrame(int frameId) | 469 void InspectorController::didBeginFrame(int frameId) |
| 434 { | 470 { |
| 435 if (InspectorTimelineAgent* timelineAgent = m_instrumentingAgents->inspector TimelineAgent()) | 471 if (InspectorTimelineAgent* timelineAgent = m_instrumentingAgents->inspector TimelineAgent()) |
| 436 timelineAgent->didBeginFrame(frameId); | 472 timelineAgent->didBeginFrame(frameId); |
| 437 if (InspectorCanvasAgent* canvasAgent = m_instrumentingAgents->inspectorCanv asAgent()) | 473 if (InspectorCanvasAgent* canvasAgent = m_instrumentingAgents->inspectorCanv asAgent()) |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 474 m_layerTreeAgent->willAddPageOverlay(layer); | 510 m_layerTreeAgent->willAddPageOverlay(layer); |
| 475 } | 511 } |
| 476 | 512 |
| 477 void InspectorController::didRemovePageOverlay(const GraphicsLayer* layer) | 513 void InspectorController::didRemovePageOverlay(const GraphicsLayer* layer) |
| 478 { | 514 { |
| 479 if (m_layerTreeAgent) | 515 if (m_layerTreeAgent) |
| 480 m_layerTreeAgent->didRemovePageOverlay(layer); | 516 m_layerTreeAgent->didRemovePageOverlay(layer); |
| 481 } | 517 } |
| 482 | 518 |
| 483 } // namespace WebCore | 519 } // namespace WebCore |
| OLD | NEW |