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

Side by Side Diff: Source/core/inspector/InspectorController.cpp

Issue 307943002: Oilpan: Prepare moving InspectorController and InspectorAgents to oilpan. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Separated out all non InspectorAgent and InspectorController classes Created 6 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 #include "core/rendering/RenderLayer.h" 68 #include "core/rendering/RenderLayer.h"
69 #include "platform/PlatformMouseEvent.h" 69 #include "platform/PlatformMouseEvent.h"
70 70
71 namespace WebCore { 71 namespace WebCore {
72 72
73 InspectorController::InspectorController(Page* page, InspectorClient* inspectorC lient) 73 InspectorController::InspectorController(Page* page, InspectorClient* inspectorC lient)
74 : m_instrumentingAgents(InstrumentingAgents::create()) 74 : m_instrumentingAgents(InstrumentingAgents::create())
75 , m_injectedScriptManager(InjectedScriptManager::createForPage()) 75 , m_injectedScriptManager(InjectedScriptManager::createForPage())
76 , m_state(adoptPtr(new InspectorCompositeState(inspectorClient))) 76 , m_state(adoptPtr(new InspectorCompositeState(inspectorClient)))
77 , m_overlay(InspectorOverlay::create(page, inspectorClient)) 77 , m_overlay(InspectorOverlay::create(page, inspectorClient))
78 , m_layerTreeAgent(0) 78 , m_layerTreeAgent(nullptr)
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(adoptPtrWillBeNoop(new InspectorAgentRegistry(m_instrumentingAgen ts.get(), m_state.get())))
82 , m_isUnderTest(false) 82 , m_isUnderTest(false)
83 , m_deferredAgentsInitialized(false) 83 , m_deferredAgentsInitialized(false)
84 { 84 {
85 InjectedScriptManager* injectedScriptManager = m_injectedScriptManager.get() ; 85 InjectedScriptManager* injectedScriptManager = m_injectedScriptManager.get() ;
86 InspectorOverlay* overlay = m_overlay.get(); 86 InspectorOverlay* overlay = m_overlay.get();
87 87
88 m_agents.append(InspectorInspectorAgent::create(m_page, injectedScriptManage r)); 88 m_agents->append(InspectorInspectorAgent::create(m_page, injectedScriptManag er));
tkent 2014/06/10 09:50:55 You may introduce |InspectorAgentRegistry& agents(
keishi 2014/06/10 13:11:12 Done.
89 89
90 OwnPtr<InspectorPageAgent> pageAgentPtr(InspectorPageAgent::create(m_page, i njectedScriptManager, inspectorClient, overlay)); 90 OwnPtrWillBeRawPtr<InspectorPageAgent> pageAgentPtr(InspectorPageAgent::crea te(m_page, injectedScriptManager, inspectorClient, overlay));
91 m_pageAgent = pageAgentPtr.get(); 91 m_pageAgent = pageAgentPtr.get();
92 m_agents.append(pageAgentPtr.release()); 92 m_agents->append(pageAgentPtr.release());
93 93
94 OwnPtr<InspectorDOMAgent> domAgentPtr(InspectorDOMAgent::create(m_pageAgent, injectedScriptManager, overlay)); 94 OwnPtrWillBeRawPtr<InspectorDOMAgent> domAgentPtr(InspectorDOMAgent::create( m_pageAgent, injectedScriptManager, overlay));
95 m_domAgent = domAgentPtr.get(); 95 m_domAgent = domAgentPtr.get();
96 m_agents.append(domAgentPtr.release()); 96 m_agents->append(domAgentPtr.release());
97 97
98 98
99 OwnPtr<InspectorLayerTreeAgent> layerTreeAgentPtr(InspectorLayerTreeAgent::c reate(m_page)); 99 OwnPtrWillBeRawPtr<InspectorLayerTreeAgent> layerTreeAgentPtr(InspectorLayer TreeAgent::create(m_page));
100 m_layerTreeAgent = layerTreeAgentPtr.get(); 100 m_layerTreeAgent = layerTreeAgentPtr.get();
101 m_agents.append(layerTreeAgentPtr.release()); 101 m_agents->append(layerTreeAgentPtr.release());
102 102
103 OwnPtr<InspectorTracingAgent> tracingAgentPtr = InspectorTracingAgent::creat e(inspectorClient); 103 OwnPtrWillBeRawPtr<InspectorTracingAgent> tracingAgentPtr = InspectorTracing Agent::create(inspectorClient);
104 m_tracingAgent = tracingAgentPtr.get(); 104 m_tracingAgent = tracingAgentPtr.get();
105 m_agents.append(tracingAgentPtr.release()); 105 m_agents->append(tracingAgentPtr.release());
106 106
107 OwnPtr<InspectorTimelineAgent> timelineAgentPtr(InspectorTimelineAgent::crea te(m_pageAgent, m_layerTreeAgent, 107 OwnPtrWillBeRawPtr<InspectorTimelineAgent> timelineAgentPtr(InspectorTimelin eAgent::create(m_pageAgent, m_layerTreeAgent,
108 overlay, InspectorTimelineAgent::PageInspector, inspectorClient)); 108 overlay, InspectorTimelineAgent::PageInspector, inspectorClient));
109 m_timelineAgent = timelineAgentPtr.get(); 109 m_timelineAgent = timelineAgentPtr.get();
110 m_agents.append(timelineAgentPtr.release()); 110 m_agents->append(timelineAgentPtr.release());
111 111
112 PageScriptDebugServer* pageScriptDebugServer = &PageScriptDebugServer::share d(); 112 PageScriptDebugServer* pageScriptDebugServer = &PageScriptDebugServer::share d();
113 113
114 m_agents.append(PageRuntimeAgent::create(injectedScriptManager, pageScriptDe bugServer, m_page, m_pageAgent)); 114 m_agents->append(PageRuntimeAgent::create(injectedScriptManager, pageScriptD ebugServer, m_page, m_pageAgent));
115 115
116 m_agents.append(PageConsoleAgent::create(injectedScriptManager, m_domAgent, m_timelineAgent)); 116 m_agents->append(PageConsoleAgent::create(injectedScriptManager, m_domAgent, m_timelineAgent));
117 117
118 m_agents.append(InspectorWorkerAgent::create()); 118 m_agents->append(InspectorWorkerAgent::create());
119 119
120 ASSERT_ARG(inspectorClient, inspectorClient); 120 ASSERT_ARG(inspectorClient, inspectorClient);
121 m_injectedScriptManager->injectedScriptHost()->init(m_instrumentingAgents.ge t(), pageScriptDebugServer); 121 m_injectedScriptManager->injectedScriptHost()->init(m_instrumentingAgents.ge t(), pageScriptDebugServer);
122 } 122 }
123 123
124 InspectorController::~InspectorController() 124 InspectorController::~InspectorController()
125 { 125 {
126 } 126 }
127 127
128 PassOwnPtr<InspectorController> InspectorController::create(Page* page, Inspecto rClient* client) 128 void InspectorController::trace(Visitor* visitor)
129 { 129 {
130 return adoptPtr(new InspectorController(page, client)); 130 visitor->trace(m_domAgent);
131 visitor->trace(m_pageAgent);
132 visitor->trace(m_timelineAgent);
133 visitor->trace(m_layerTreeAgent);
134 visitor->trace(m_tracingAgent);
135 visitor->trace(m_agents);
136 #if ENABLE(OILPAN)
137 visitor->trace(m_moduleAgents);
138 #endif
139 }
140
141 PassOwnPtrWillBeRawPtr<InspectorController> InspectorController::create(Page* pa ge, InspectorClient* client)
142 {
143 return adoptPtrWillBeNoop(new InspectorController(page, client));
131 } 144 }
132 145
133 void InspectorController::setTextAutosizingEnabled(bool enabled) 146 void InspectorController::setTextAutosizingEnabled(bool enabled)
134 { 147 {
135 m_pageAgent->setTextAutosizingEnabled(enabled); 148 m_pageAgent->setTextAutosizingEnabled(enabled);
136 } 149 }
137 150
138 void InspectorController::setDeviceScaleAdjustment(float deviceScaleAdjustment) 151 void InspectorController::setDeviceScaleAdjustment(float deviceScaleAdjustment)
139 { 152 {
140 m_pageAgent->setDeviceScaleAdjustment(deviceScaleAdjustment); 153 m_pageAgent->setDeviceScaleAdjustment(deviceScaleAdjustment);
141 } 154 }
142 155
143 void InspectorController::initializeDeferredAgents() 156 void InspectorController::initializeDeferredAgents()
144 { 157 {
145 if (m_deferredAgentsInitialized) 158 if (m_deferredAgentsInitialized)
146 return; 159 return;
147 m_deferredAgentsInitialized = true; 160 m_deferredAgentsInitialized = true;
148 161
149 InjectedScriptManager* injectedScriptManager = m_injectedScriptManager.get() ; 162 InjectedScriptManager* injectedScriptManager = m_injectedScriptManager.get() ;
150 InspectorOverlay* overlay = m_overlay.get(); 163 InspectorOverlay* overlay = m_overlay.get();
151 164
152 OwnPtr<InspectorResourceAgent> resourceAgentPtr(InspectorResourceAgent::crea te(m_pageAgent)); 165 OwnPtrWillBeRawPtr<InspectorResourceAgent> resourceAgentPtr(InspectorResourc eAgent::create(m_pageAgent));
153 InspectorResourceAgent* resourceAgent = resourceAgentPtr.get(); 166 InspectorResourceAgent* resourceAgent = resourceAgentPtr.get();
154 m_agents.append(resourceAgentPtr.release()); 167 m_agents->append(resourceAgentPtr.release());
155 168
156 m_agents.append(InspectorCSSAgent::create(m_domAgent, m_pageAgent, resourceA gent)); 169 m_agents->append(InspectorCSSAgent::create(m_domAgent, m_pageAgent, resource Agent));
157 170
158 m_agents.append(InspectorDOMStorageAgent::create(m_pageAgent)); 171 m_agents->append(InspectorDOMStorageAgent::create(m_pageAgent));
159 172
160 m_agents.append(InspectorMemoryAgent::create()); 173 m_agents->append(InspectorMemoryAgent::create());
161 174
162 m_agents.append(InspectorApplicationCacheAgent::create(m_pageAgent)); 175 m_agents->append(InspectorApplicationCacheAgent::create(m_pageAgent));
163 176
164 PageScriptDebugServer* pageScriptDebugServer = &PageScriptDebugServer::share d(); 177 PageScriptDebugServer* pageScriptDebugServer = &PageScriptDebugServer::share d();
165 178
166 OwnPtr<InspectorDebuggerAgent> debuggerAgentPtr(PageDebuggerAgent::create(pa geScriptDebugServer, m_pageAgent, injectedScriptManager, overlay)); 179 OwnPtrWillBeRawPtr<InspectorDebuggerAgent> debuggerAgentPtr(PageDebuggerAgen t::create(pageScriptDebugServer, m_pageAgent, injectedScriptManager, overlay));
167 InspectorDebuggerAgent* debuggerAgent = debuggerAgentPtr.get(); 180 InspectorDebuggerAgent* debuggerAgent = debuggerAgentPtr.get();
168 m_agents.append(debuggerAgentPtr.release()); 181 m_agents->append(debuggerAgentPtr.release());
169 182
170 m_agents.append(InspectorDOMDebuggerAgent::create(m_domAgent, debuggerAgent) ); 183 m_agents->append(InspectorDOMDebuggerAgent::create(m_domAgent, debuggerAgent ));
171 184
172 m_agents.append(InspectorProfilerAgent::create(injectedScriptManager, overla y)); 185 m_agents->append(InspectorProfilerAgent::create(injectedScriptManager, overl ay));
173 186
174 m_agents.append(InspectorHeapProfilerAgent::create(injectedScriptManager)); 187 m_agents->append(InspectorHeapProfilerAgent::create(injectedScriptManager));
175 188
176 m_agents.append(InspectorCanvasAgent::create(m_pageAgent, injectedScriptMana ger)); 189 m_agents->append(InspectorCanvasAgent::create(m_pageAgent, injectedScriptMan ager));
177 190
178 m_agents.append(InspectorInputAgent::create(m_page, m_inspectorClient)); 191 m_agents->append(InspectorInputAgent::create(m_page, m_inspectorClient));
179 } 192 }
180 193
181 void InspectorController::willBeDestroyed() 194 void InspectorController::willBeDestroyed()
182 { 195 {
183 disconnectFrontend(); 196 disconnectFrontend();
184 m_injectedScriptManager->disconnect(); 197 m_injectedScriptManager->disconnect();
185 m_inspectorClient = 0; 198 m_inspectorClient = 0;
186 m_page = 0; 199 m_page = 0;
187 m_instrumentingAgents->reset(); 200 m_instrumentingAgents->reset();
188 m_agents.discardAgents(); 201 m_agents->discardAgents();
189 } 202 }
190 203
191 void InspectorController::registerModuleAgent(PassOwnPtr<InspectorAgent> agent) 204 void InspectorController::registerModuleAgent(PassOwnPtrWillBeRawPtr<InspectorAg ent> agent)
192 { 205 {
193 m_moduleAgents.append(agent.get()); 206 m_moduleAgents.append(agent.get());
194 m_agents.append(agent); 207 m_agents->append(agent);
195 } 208 }
196 209
197 void InspectorController::setInspectorFrontendClient(PassOwnPtr<InspectorFronten dClient> inspectorFrontendClient) 210 void InspectorController::setInspectorFrontendClient(PassOwnPtr<InspectorFronten dClient> inspectorFrontendClient)
198 { 211 {
199 m_inspectorFrontendClient = inspectorFrontendClient; 212 m_inspectorFrontendClient = inspectorFrontendClient;
200 } 213 }
201 214
202 void InspectorController::didClearDocumentOfWindowObject(LocalFrame* frame) 215 void InspectorController::didClearDocumentOfWindowObject(LocalFrame* frame)
203 { 216 {
204 // If the page is supposed to serve as InspectorFrontend notify inspector fr ontend 217 // 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 . 218 // client that it's cleared so that the client can expose inspector bindings .
206 if (m_inspectorFrontendClient && frame == m_page->mainFrame()) 219 if (m_inspectorFrontendClient && frame == m_page->mainFrame())
207 m_inspectorFrontendClient->windowObjectCleared(); 220 m_inspectorFrontendClient->windowObjectCleared();
208 } 221 }
209 222
210 void InspectorController::connectFrontend(InspectorFrontendChannel* frontendChan nel) 223 void InspectorController::connectFrontend(InspectorFrontendChannel* frontendChan nel)
211 { 224 {
212 ASSERT(frontendChannel); 225 ASSERT(frontendChannel);
213 226
214 initializeDeferredAgents(); 227 initializeDeferredAgents();
215 228
216 m_inspectorFrontend = adoptPtr(new InspectorFrontend(frontendChannel)); 229 m_inspectorFrontend = adoptPtr(new InspectorFrontend(frontendChannel));
217 // We can reconnect to existing front-end -> unmute state. 230 // We can reconnect to existing front-end -> unmute state.
218 m_state->unmute(); 231 m_state->unmute();
219 232
220 m_agents.setFrontend(m_inspectorFrontend.get()); 233 m_agents->setFrontend(m_inspectorFrontend.get());
221 234
222 InspectorInstrumentation::registerInstrumentingAgents(m_instrumentingAgents. get()); 235 InspectorInstrumentation::registerInstrumentingAgents(m_instrumentingAgents. get());
223 InspectorInstrumentation::frontendCreated(); 236 InspectorInstrumentation::frontendCreated();
224 237
225 ASSERT(m_inspectorClient); 238 ASSERT(m_inspectorClient);
226 m_inspectorBackendDispatcher = InspectorBackendDispatcher::create(frontendCh annel); 239 m_inspectorBackendDispatcher = InspectorBackendDispatcher::create(frontendCh annel);
227 240
228 m_agents.registerInDispatcher(m_inspectorBackendDispatcher.get()); 241 m_agents->registerInDispatcher(m_inspectorBackendDispatcher.get());
229 } 242 }
230 243
231 void InspectorController::disconnectFrontend() 244 void InspectorController::disconnectFrontend()
232 { 245 {
233 if (!m_inspectorFrontend) 246 if (!m_inspectorFrontend)
234 return; 247 return;
235 m_inspectorBackendDispatcher->clearFrontend(); 248 m_inspectorBackendDispatcher->clearFrontend();
236 m_inspectorBackendDispatcher.clear(); 249 m_inspectorBackendDispatcher.clear();
237 250
238 // Destroying agents would change the state, but we don't want that. 251 // Destroying agents would change the state, but we don't want that.
239 // Pre-disconnect state will be used to restore inspector agents. 252 // Pre-disconnect state will be used to restore inspector agents.
240 m_state->mute(); 253 m_state->mute();
241 254
242 m_agents.clearFrontend(); 255 m_agents->clearFrontend();
243 256
244 m_inspectorFrontend.clear(); 257 m_inspectorFrontend.clear();
245 258
246 // relese overlay page resources 259 // relese overlay page resources
247 m_overlay->freePage(); 260 m_overlay->freePage();
248 InspectorInstrumentation::frontendDeleted(); 261 InspectorInstrumentation::frontendDeleted();
249 InspectorInstrumentation::unregisterInstrumentingAgents(m_instrumentingAgent s.get()); 262 InspectorInstrumentation::unregisterInstrumentingAgents(m_instrumentingAgent s.get());
250 } 263 }
251 264
252 void InspectorController::reconnectFrontend() 265 void InspectorController::reconnectFrontend()
253 { 266 {
254 if (!m_inspectorFrontend) 267 if (!m_inspectorFrontend)
255 return; 268 return;
256 InspectorFrontendChannel* frontendChannel = m_inspectorFrontend->channel(); 269 InspectorFrontendChannel* frontendChannel = m_inspectorFrontend->channel();
257 disconnectFrontend(); 270 disconnectFrontend();
258 connectFrontend(frontendChannel); 271 connectFrontend(frontendChannel);
259 } 272 }
260 273
261 void InspectorController::reuseFrontend(InspectorFrontendChannel* frontendChanne l, const String& inspectorStateCookie) 274 void InspectorController::reuseFrontend(InspectorFrontendChannel* frontendChanne l, const String& inspectorStateCookie)
262 { 275 {
263 ASSERT(!m_inspectorFrontend); 276 ASSERT(!m_inspectorFrontend);
264 connectFrontend(frontendChannel); 277 connectFrontend(frontendChannel);
265 m_state->loadFromCookie(inspectorStateCookie); 278 m_state->loadFromCookie(inspectorStateCookie);
266 m_agents.restore(); 279 m_agents->restore();
267 } 280 }
268 281
269 void InspectorController::setProcessId(long processId) 282 void InspectorController::setProcessId(long processId)
270 { 283 {
271 IdentifiersFactory::setProcessId(processId); 284 IdentifiersFactory::setProcessId(processId);
272 } 285 }
273 286
274 void InspectorController::setLayerTreeId(int id) 287 void InspectorController::setLayerTreeId(int id)
275 { 288 {
276 m_timelineAgent->setLayerTreeId(id); 289 m_timelineAgent->setLayerTreeId(id);
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 if (InspectorTimelineAgent* timelineAgent = m_instrumentingAgents->inspector TimelineAgent()) 420 if (InspectorTimelineAgent* timelineAgent = m_instrumentingAgents->inspector TimelineAgent())
408 timelineAgent->didProcessTask(); 421 timelineAgent->didProcessTask();
409 if (InspectorProfilerAgent* profilerAgent = m_instrumentingAgents->inspector ProfilerAgent()) 422 if (InspectorProfilerAgent* profilerAgent = m_instrumentingAgents->inspector ProfilerAgent())
410 profilerAgent->didProcessTask(); 423 profilerAgent->didProcessTask();
411 if (InspectorDOMDebuggerAgent* domDebuggerAgent = m_instrumentingAgents->ins pectorDOMDebuggerAgent()) 424 if (InspectorDOMDebuggerAgent* domDebuggerAgent = m_instrumentingAgents->ins pectorDOMDebuggerAgent())
412 domDebuggerAgent->didProcessTask(); 425 domDebuggerAgent->didProcessTask();
413 } 426 }
414 427
415 void InspectorController::flushPendingFrontendMessages() 428 void InspectorController::flushPendingFrontendMessages()
416 { 429 {
417 m_agents.flushPendingFrontendMessages(); 430 m_agents->flushPendingFrontendMessages();
418 } 431 }
419 432
420 void InspectorController::didCommitLoadForMainFrame() 433 void InspectorController::didCommitLoadForMainFrame()
421 { 434 {
422 Vector<InspectorAgent*> agents = m_moduleAgents; 435 WillBeHeapVector<RawPtrWillBeMember<InspectorAgent> > agents = m_moduleAgent s;
423 for (size_t i = 0; i < agents.size(); i++) 436 for (size_t i = 0; i < agents.size(); i++)
424 agents[i]->didCommitLoadForMainFrame(); 437 agents[i]->didCommitLoadForMainFrame();
425 } 438 }
426 439
427 void InspectorController::didBeginFrame(int frameId) 440 void InspectorController::didBeginFrame(int frameId)
428 { 441 {
429 if (InspectorTimelineAgent* timelineAgent = m_instrumentingAgents->inspector TimelineAgent()) 442 if (InspectorTimelineAgent* timelineAgent = m_instrumentingAgents->inspector TimelineAgent())
430 timelineAgent->didBeginFrame(frameId); 443 timelineAgent->didBeginFrame(frameId);
431 if (InspectorCanvasAgent* canvasAgent = m_instrumentingAgents->inspectorCanv asAgent()) 444 if (InspectorCanvasAgent* canvasAgent = m_instrumentingAgents->inspectorCanv asAgent())
432 canvasAgent->didBeginFrame(); 445 canvasAgent->didBeginFrame();
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
468 m_layerTreeAgent->willAddPageOverlay(layer); 481 m_layerTreeAgent->willAddPageOverlay(layer);
469 } 482 }
470 483
471 void InspectorController::didRemovePageOverlay(const GraphicsLayer* layer) 484 void InspectorController::didRemovePageOverlay(const GraphicsLayer* layer)
472 { 485 {
473 if (m_layerTreeAgent) 486 if (m_layerTreeAgent)
474 m_layerTreeAgent->didRemovePageOverlay(layer); 487 m_layerTreeAgent->didRemovePageOverlay(layer);
475 } 488 }
476 489
477 } // namespace WebCore 490 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698