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

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: Fixed 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(m_instrumentingAgents.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 agents().append(InspectorInspectorAgent::create(m_page, injectedScriptManage r));
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 agents().append(pageAgentPtr.release());
yurys 2014/06/18 14:23:37 What's the point in having agents() compared to us
keishi 2014/06/18 14:47:09 I'm not sure. tkent@ could you explain? https://co
tkent 2014/06/18 23:21:29 m_agents is always non-null, and we prefer using r
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 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 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 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 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 agents().append(PageRuntimeAgent::create(injectedScriptManager, pageScriptDe bugServer, m_page, m_pageAgent));
115 115
116 m_agents.append(PageConsoleAgent::create(injectedScriptManager, m_domAgent, m_timelineAgent)); 116 agents().append(PageConsoleAgent::create(injectedScriptManager, m_domAgent, m_timelineAgent));
117 117
118 m_agents.append(InspectorWorkerAgent::create()); 118 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_instrumentingAgents);
131 visitor->trace(m_domAgent);
132 visitor->trace(m_pageAgent);
133 visitor->trace(m_timelineAgent);
134 visitor->trace(m_layerTreeAgent);
135 visitor->trace(m_tracingAgent);
136 visitor->trace(m_page);
137 m_agents.trace(visitor);
138 #if ENABLE(OILPAN)
139 visitor->trace(m_moduleAgents);
140 #endif
141 }
142
143 PassOwnPtrWillBeRawPtr<InspectorController> InspectorController::create(Page* pa ge, InspectorClient* client)
144 {
145 return adoptPtrWillBeNoop(new InspectorController(page, client));
131 } 146 }
132 147
133 void InspectorController::setTextAutosizingEnabled(bool enabled) 148 void InspectorController::setTextAutosizingEnabled(bool enabled)
134 { 149 {
135 m_pageAgent->setTextAutosizingEnabled(enabled); 150 m_pageAgent->setTextAutosizingEnabled(enabled);
136 } 151 }
137 152
138 void InspectorController::setDeviceScaleAdjustment(float deviceScaleAdjustment) 153 void InspectorController::setDeviceScaleAdjustment(float deviceScaleAdjustment)
139 { 154 {
140 m_pageAgent->setDeviceScaleAdjustment(deviceScaleAdjustment); 155 m_pageAgent->setDeviceScaleAdjustment(deviceScaleAdjustment);
141 } 156 }
142 157
143 void InspectorController::initializeDeferredAgents() 158 void InspectorController::initializeDeferredAgents()
144 { 159 {
145 if (m_deferredAgentsInitialized) 160 if (m_deferredAgentsInitialized)
146 return; 161 return;
147 m_deferredAgentsInitialized = true; 162 m_deferredAgentsInitialized = true;
148 163
149 InjectedScriptManager* injectedScriptManager = m_injectedScriptManager.get() ; 164 InjectedScriptManager* injectedScriptManager = m_injectedScriptManager.get() ;
150 InspectorOverlay* overlay = m_overlay.get(); 165 InspectorOverlay* overlay = m_overlay.get();
151 166
152 OwnPtr<InspectorResourceAgent> resourceAgentPtr(InspectorResourceAgent::crea te(m_pageAgent)); 167 OwnPtrWillBeRawPtr<InspectorResourceAgent> resourceAgentPtr(InspectorResourc eAgent::create(m_pageAgent));
153 InspectorResourceAgent* resourceAgent = resourceAgentPtr.get(); 168 InspectorResourceAgent* resourceAgent = resourceAgentPtr.get();
154 m_agents.append(resourceAgentPtr.release()); 169 agents().append(resourceAgentPtr.release());
155 170
156 m_agents.append(InspectorCSSAgent::create(m_domAgent, m_pageAgent, resourceA gent)); 171 agents().append(InspectorCSSAgent::create(m_domAgent, m_pageAgent, resourceA gent));
157 172
158 m_agents.append(InspectorDOMStorageAgent::create(m_pageAgent)); 173 agents().append(InspectorDOMStorageAgent::create(m_pageAgent));
159 174
160 m_agents.append(InspectorMemoryAgent::create()); 175 agents().append(InspectorMemoryAgent::create());
161 176
162 m_agents.append(InspectorApplicationCacheAgent::create(m_pageAgent)); 177 agents().append(InspectorApplicationCacheAgent::create(m_pageAgent));
163 178
164 PageScriptDebugServer* pageScriptDebugServer = &PageScriptDebugServer::share d(); 179 PageScriptDebugServer* pageScriptDebugServer = &PageScriptDebugServer::share d();
165 180
166 OwnPtr<InspectorDebuggerAgent> debuggerAgentPtr(PageDebuggerAgent::create(pa geScriptDebugServer, m_pageAgent, injectedScriptManager, overlay)); 181 OwnPtrWillBeRawPtr<InspectorDebuggerAgent> debuggerAgentPtr(PageDebuggerAgen t::create(pageScriptDebugServer, m_pageAgent, injectedScriptManager, overlay));
167 InspectorDebuggerAgent* debuggerAgent = debuggerAgentPtr.get(); 182 InspectorDebuggerAgent* debuggerAgent = debuggerAgentPtr.get();
168 m_agents.append(debuggerAgentPtr.release()); 183 agents().append(debuggerAgentPtr.release());
169 184
170 m_agents.append(InspectorDOMDebuggerAgent::create(m_domAgent, debuggerAgent) ); 185 agents().append(InspectorDOMDebuggerAgent::create(m_domAgent, debuggerAgent) );
171 186
172 m_agents.append(InspectorProfilerAgent::create(injectedScriptManager, overla y)); 187 agents().append(InspectorProfilerAgent::create(injectedScriptManager, overla y));
173 188
174 m_agents.append(InspectorHeapProfilerAgent::create(injectedScriptManager)); 189 agents().append(InspectorHeapProfilerAgent::create(injectedScriptManager));
175 190
176 m_agents.append(InspectorCanvasAgent::create(m_pageAgent, injectedScriptMana ger)); 191 agents().append(InspectorCanvasAgent::create(m_pageAgent, injectedScriptMana ger));
177 192
178 m_agents.append(InspectorInputAgent::create(m_page, m_inspectorClient)); 193 agents().append(InspectorInputAgent::create(m_page, m_inspectorClient));
179 } 194 }
180 195
181 void InspectorController::willBeDestroyed() 196 void InspectorController::willBeDestroyed()
182 { 197 {
183 disconnectFrontend(); 198 disconnectFrontend();
184 m_injectedScriptManager->disconnect(); 199 m_injectedScriptManager->disconnect();
185 m_inspectorClient = 0; 200 m_inspectorClient = 0;
186 m_page = 0; 201 m_page = nullptr;
187 m_instrumentingAgents->reset(); 202 m_instrumentingAgents->reset();
188 m_agents.discardAgents(); 203 agents().discardAgents();
189 } 204 }
190 205
191 void InspectorController::registerModuleAgent(PassOwnPtr<InspectorAgent> agent) 206 void InspectorController::registerModuleAgent(PassOwnPtrWillBeRawPtr<InspectorAg ent> agent)
192 { 207 {
193 m_moduleAgents.append(agent.get()); 208 m_moduleAgents.append(agent.get());
194 m_agents.append(agent); 209 agents().append(agent);
195 } 210 }
196 211
197 void InspectorController::setInspectorFrontendClient(PassOwnPtr<InspectorFronten dClient> inspectorFrontendClient) 212 void InspectorController::setInspectorFrontendClient(PassOwnPtr<InspectorFronten dClient> inspectorFrontendClient)
198 { 213 {
199 m_inspectorFrontendClient = inspectorFrontendClient; 214 m_inspectorFrontendClient = inspectorFrontendClient;
200 } 215 }
201 216
202 void InspectorController::didClearDocumentOfWindowObject(LocalFrame* frame) 217 void InspectorController::didClearDocumentOfWindowObject(LocalFrame* frame)
203 { 218 {
204 // If the page is supposed to serve as InspectorFrontend notify inspector fr ontend 219 // 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 . 220 // client that it's cleared so that the client can expose inspector bindings .
206 if (m_inspectorFrontendClient && frame == m_page->mainFrame()) 221 if (m_inspectorFrontendClient && frame == m_page->mainFrame())
207 m_inspectorFrontendClient->windowObjectCleared(); 222 m_inspectorFrontendClient->windowObjectCleared();
208 } 223 }
209 224
210 void InspectorController::connectFrontend(InspectorFrontendChannel* frontendChan nel) 225 void InspectorController::connectFrontend(InspectorFrontendChannel* frontendChan nel)
211 { 226 {
212 ASSERT(frontendChannel); 227 ASSERT(frontendChannel);
213 228
214 initializeDeferredAgents(); 229 initializeDeferredAgents();
215 230
216 m_inspectorFrontend = adoptPtr(new InspectorFrontend(frontendChannel)); 231 m_inspectorFrontend = adoptPtr(new InspectorFrontend(frontendChannel));
217 // We can reconnect to existing front-end -> unmute state. 232 // We can reconnect to existing front-end -> unmute state.
218 m_state->unmute(); 233 m_state->unmute();
219 234
220 m_agents.setFrontend(m_inspectorFrontend.get()); 235 agents().setFrontend(m_inspectorFrontend.get());
221 236
222 InspectorInstrumentation::registerInstrumentingAgents(m_instrumentingAgents. get()); 237 InspectorInstrumentation::registerInstrumentingAgents(m_instrumentingAgents. get());
223 InspectorInstrumentation::frontendCreated(); 238 InspectorInstrumentation::frontendCreated();
224 239
225 ASSERT(m_inspectorClient); 240 ASSERT(m_inspectorClient);
226 m_inspectorBackendDispatcher = InspectorBackendDispatcher::create(frontendCh annel); 241 m_inspectorBackendDispatcher = InspectorBackendDispatcher::create(frontendCh annel);
227 242
228 m_agents.registerInDispatcher(m_inspectorBackendDispatcher.get()); 243 agents().registerInDispatcher(m_inspectorBackendDispatcher.get());
229 } 244 }
230 245
231 void InspectorController::disconnectFrontend() 246 void InspectorController::disconnectFrontend()
232 { 247 {
233 if (!m_inspectorFrontend) 248 if (!m_inspectorFrontend)
234 return; 249 return;
235 m_inspectorBackendDispatcher->clearFrontend(); 250 m_inspectorBackendDispatcher->clearFrontend();
236 m_inspectorBackendDispatcher.clear(); 251 m_inspectorBackendDispatcher.clear();
237 252
238 // Destroying agents would change the state, but we don't want that. 253 // Destroying agents would change the state, but we don't want that.
239 // Pre-disconnect state will be used to restore inspector agents. 254 // Pre-disconnect state will be used to restore inspector agents.
240 m_state->mute(); 255 m_state->mute();
241 256
242 m_agents.clearFrontend(); 257 agents().clearFrontend();
243 258
244 m_inspectorFrontend.clear(); 259 m_inspectorFrontend.clear();
245 260
246 // relese overlay page resources 261 // relese overlay page resources
247 m_overlay->freePage(); 262 m_overlay->freePage();
248 InspectorInstrumentation::frontendDeleted(); 263 InspectorInstrumentation::frontendDeleted();
249 InspectorInstrumentation::unregisterInstrumentingAgents(m_instrumentingAgent s.get()); 264 InspectorInstrumentation::unregisterInstrumentingAgents(m_instrumentingAgent s.get());
250 } 265 }
251 266
252 void InspectorController::reconnectFrontend() 267 void InspectorController::reconnectFrontend()
253 { 268 {
254 if (!m_inspectorFrontend) 269 if (!m_inspectorFrontend)
255 return; 270 return;
256 InspectorFrontendChannel* frontendChannel = m_inspectorFrontend->channel(); 271 InspectorFrontendChannel* frontendChannel = m_inspectorFrontend->channel();
257 disconnectFrontend(); 272 disconnectFrontend();
258 connectFrontend(frontendChannel); 273 connectFrontend(frontendChannel);
259 } 274 }
260 275
261 void InspectorController::reuseFrontend(InspectorFrontendChannel* frontendChanne l, const String& inspectorStateCookie) 276 void InspectorController::reuseFrontend(InspectorFrontendChannel* frontendChanne l, const String& inspectorStateCookie)
262 { 277 {
263 ASSERT(!m_inspectorFrontend); 278 ASSERT(!m_inspectorFrontend);
264 connectFrontend(frontendChannel); 279 connectFrontend(frontendChannel);
265 m_state->loadFromCookie(inspectorStateCookie); 280 m_state->loadFromCookie(inspectorStateCookie);
266 m_agents.restore(); 281 agents().restore();
267 } 282 }
268 283
269 void InspectorController::setProcessId(long processId) 284 void InspectorController::setProcessId(long processId)
270 { 285 {
271 IdentifiersFactory::setProcessId(processId); 286 IdentifiersFactory::setProcessId(processId);
272 } 287 }
273 288
274 void InspectorController::setLayerTreeId(int id) 289 void InspectorController::setLayerTreeId(int id)
275 { 290 {
276 m_timelineAgent->setLayerTreeId(id); 291 m_timelineAgent->setLayerTreeId(id);
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 if (InspectorTimelineAgent* timelineAgent = m_instrumentingAgents->inspector TimelineAgent()) 422 if (InspectorTimelineAgent* timelineAgent = m_instrumentingAgents->inspector TimelineAgent())
408 timelineAgent->didProcessTask(); 423 timelineAgent->didProcessTask();
409 if (InspectorProfilerAgent* profilerAgent = m_instrumentingAgents->inspector ProfilerAgent()) 424 if (InspectorProfilerAgent* profilerAgent = m_instrumentingAgents->inspector ProfilerAgent())
410 profilerAgent->didProcessTask(); 425 profilerAgent->didProcessTask();
411 if (InspectorDOMDebuggerAgent* domDebuggerAgent = m_instrumentingAgents->ins pectorDOMDebuggerAgent()) 426 if (InspectorDOMDebuggerAgent* domDebuggerAgent = m_instrumentingAgents->ins pectorDOMDebuggerAgent())
412 domDebuggerAgent->didProcessTask(); 427 domDebuggerAgent->didProcessTask();
413 } 428 }
414 429
415 void InspectorController::flushPendingFrontendMessages() 430 void InspectorController::flushPendingFrontendMessages()
416 { 431 {
417 m_agents.flushPendingFrontendMessages(); 432 agents().flushPendingFrontendMessages();
418 } 433 }
419 434
420 void InspectorController::didCommitLoadForMainFrame() 435 void InspectorController::didCommitLoadForMainFrame()
421 { 436 {
422 Vector<InspectorAgent*> agents = m_moduleAgents; 437 WillBeHeapVector<RawPtrWillBeMember<InspectorAgent> > agents = m_moduleAgent s;
423 for (size_t i = 0; i < agents.size(); i++) 438 for (size_t i = 0; i < agents.size(); i++)
424 agents[i]->didCommitLoadForMainFrame(); 439 agents[i]->didCommitLoadForMainFrame();
425 } 440 }
426 441
427 void InspectorController::didBeginFrame(int frameId) 442 void InspectorController::didBeginFrame(int frameId)
428 { 443 {
429 if (InspectorTimelineAgent* timelineAgent = m_instrumentingAgents->inspector TimelineAgent()) 444 if (InspectorTimelineAgent* timelineAgent = m_instrumentingAgents->inspector TimelineAgent())
430 timelineAgent->didBeginFrame(frameId); 445 timelineAgent->didBeginFrame(frameId);
431 if (InspectorCanvasAgent* canvasAgent = m_instrumentingAgents->inspectorCanv asAgent()) 446 if (InspectorCanvasAgent* canvasAgent = m_instrumentingAgents->inspectorCanv asAgent())
432 canvasAgent->didBeginFrame(); 447 canvasAgent->didBeginFrame();
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
468 m_layerTreeAgent->willAddPageOverlay(layer); 483 m_layerTreeAgent->willAddPageOverlay(layer);
469 } 484 }
470 485
471 void InspectorController::didRemovePageOverlay(const GraphicsLayer* layer) 486 void InspectorController::didRemovePageOverlay(const GraphicsLayer* layer)
472 { 487 {
473 if (m_layerTreeAgent) 488 if (m_layerTreeAgent)
474 m_layerTreeAgent->didRemovePageOverlay(layer); 489 m_layerTreeAgent->didRemovePageOverlay(layer);
475 } 490 }
476 491
477 } // namespace WebCore 492 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698