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

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

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

Powered by Google App Engine
This is Rietveld 408576698