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

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

Issue 17030009: Inspector: wrapped inspector agent instances into factory-like wrappers (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Addressed comments Created 7 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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 77
78 InspectorController::InspectorController(Page* page, InspectorClient* inspectorC lient) 78 InspectorController::InspectorController(Page* page, InspectorClient* inspectorC lient)
79 : m_instrumentingAgents(InstrumentingAgents::create()) 79 : m_instrumentingAgents(InstrumentingAgents::create())
80 , m_injectedScriptManager(InjectedScriptManager::createForPage()) 80 , m_injectedScriptManager(InjectedScriptManager::createForPage())
81 , m_state(adoptPtr(new InspectorCompositeState(inspectorClient))) 81 , m_state(adoptPtr(new InspectorCompositeState(inspectorClient)))
82 , m_overlay(InspectorOverlay::create(page, inspectorClient)) 82 , m_overlay(InspectorOverlay::create(page, inspectorClient))
83 , m_page(page) 83 , m_page(page)
84 , m_inspectorClient(inspectorClient) 84 , m_inspectorClient(inspectorClient)
85 , m_isUnderTest(false) 85 , m_isUnderTest(false)
86 { 86 {
87 m_agents.append(InspectorAgent::create(page, m_injectedScriptManager.get(), m_instrumentingAgents.get(), m_state.get())); 87 m_agentFactories.append(InspectorAgentFactory::create(page, m_injectedScript Manager.get(), m_instrumentingAgents.get(), m_state.get()));
88 88
89 OwnPtr<InspectorPageAgent> pageAgentPtr(InspectorPageAgent::create(m_instrum entingAgents.get(), page, m_state.get(), m_injectedScriptManager.get(), inspecto rClient, m_overlay.get())); 89 OwnPtr<InspectorPageFactory> pageFactoryPtr(InspectorPageFactory::create(m_i nstrumentingAgents.get(), m_state.get(), page, m_injectedScriptManager.get(), m_ overlay.get(), inspectorClient));
90 InspectorPageAgent* pageAgent = pageAgentPtr.get(); 90 InspectorPageFactory* pageFactory = pageFactoryPtr.get();
91 m_agents.append(pageAgentPtr.release()); 91 m_agentFactories.append(pageFactoryPtr.release());
92 92
93 OwnPtr<InspectorDOMAgent> domAgentPtr(InspectorDOMAgent::create(m_instrument ingAgents.get(), pageAgent, m_state.get(), m_injectedScriptManager.get(), m_over lay.get(), inspectorClient)); 93 OwnPtr<InspectorDOMFactory> domFactoryPtr(InspectorDOMFactory::create(m_inst rumentingAgents.get(), m_state.get(), pageFactory, m_injectedScriptManager.get() , m_overlay.get(), inspectorClient));
94 InspectorDOMAgent* domAgent = domAgentPtr.get(); 94 InspectorDOMFactory* domFactory = domFactoryPtr.get();
95 m_agents.append(domAgentPtr.release()); 95 m_agentFactories.append(domFactoryPtr.release());
96 96
97 m_agents.append(InspectorCSSAgent::create(m_instrumentingAgents.get(), m_sta te.get(), domAgent, pageAgent)); 97 m_agentFactories.append(InspectorCSSFactory::create(m_instrumentingAgents.ge t(), m_state.get(), domFactory, pageFactory));
98 98
99 m_agents.append(InspectorDatabaseAgent::create(m_instrumentingAgents.get(), m_state.get())); 99 m_agentFactories.append(InspectorDatabaseFactory::create(m_instrumentingAgen ts.get(), m_state.get()));
100 100
101 m_agents.append(InspectorIndexedDBAgent::create(m_instrumentingAgents.get(), m_state.get(), m_injectedScriptManager.get(), pageAgent)); 101 m_agentFactories.append(InspectorIndexedDBFactory::create(m_instrumentingAge nts.get(), m_state.get(), pageFactory, m_injectedScriptManager.get()));
102 102
103 m_agents.append(InspectorFileSystemAgent::create(m_instrumentingAgents.get() , pageAgent, m_state.get())); 103 m_agentFactories.append(InspectorFileSystemFactory::create(m_instrumentingAg ents.get(), m_state.get(), pageFactory));
104 104
105 m_agents.append(InspectorDOMStorageAgent::create(m_instrumentingAgents.get() , pageAgent, m_state.get())); 105 m_agentFactories.append(InspectorDOMStorageFactory::create(m_instrumentingAg ents.get(), m_state.get(), pageFactory));
106 106
107 OwnPtr<InspectorMemoryAgent> memoryAgentPtr(InspectorMemoryAgent::create(m_i nstrumentingAgents.get(), inspectorClient, m_state.get(), m_page)); 107 OwnPtr<InspectorMemoryFactory> memoryFactoryPtr(InspectorMemoryFactory::crea te(m_instrumentingAgents.get(), inspectorClient, m_state.get(), m_page));
108 m_memoryAgent = memoryAgentPtr.get(); 108 m_memoryFactory = memoryFactoryPtr.get();
109 m_agents.append(memoryAgentPtr.release()); 109 m_agentFactories.append(memoryFactoryPtr.release());
110 110
111 m_agents.append(InspectorTimelineAgent::create(m_instrumentingAgents.get(), pageAgent, m_memoryAgent, domAgent, m_state.get(), InspectorTimelineAgent::PageI nspector, 111 m_agentFactories.append(InspectorTimelineFactory::create(m_instrumentingAgen ts.get(), m_state.get(), pageFactory, m_memoryFactory, domFactory, InspectorTime lineAgent::PageInspector, inspectorClient));
112 inspectorClient)); 112 m_agentFactories.append(InspectorApplicationCacheFactory::create(m_instrumen tingAgents.get(), m_state.get(), pageFactory));
113 m_agents.append(InspectorApplicationCacheAgent::create(m_instrumentingAgents .get(), m_state.get(), pageAgent));
114 113
115 m_agents.append(InspectorResourceAgent::create(m_instrumentingAgents.get(), pageAgent, inspectorClient, m_state.get())); 114 m_agentFactories.append(InspectorResourceFactory::create(m_instrumentingAgen ts.get(), m_state.get(), pageFactory, inspectorClient));
116 115
117 PageScriptDebugServer* pageScriptDebugServer = &PageScriptDebugServer::share d(); 116 PageScriptDebugServer* pageScriptDebugServer = &PageScriptDebugServer::share d();
118 117
119 m_agents.append(PageRuntimeAgent::create(m_instrumentingAgents.get(), m_stat e.get(), m_injectedScriptManager.get(), pageScriptDebugServer, page, pageAgent)) ; 118 m_agentFactories.append(PageRuntimeFactory::create(m_instrumentingAgents.get (), m_state.get(), page, pageFactory, m_injectedScriptManager.get(), pageScriptD ebugServer));
120 119
121 OwnPtr<InspectorConsoleAgent> consoleAgentPtr(PageConsoleAgent::create(m_ins trumentingAgents.get(), m_state.get(), m_injectedScriptManager.get(), domAgent)) ; 120 OwnPtr<PageConsoleFactory> consoleFactoryPtr(PageConsoleFactory::create(m_in strumentingAgents.get(), m_state.get(), m_injectedScriptManager.get(), domFactor y));
122 InspectorConsoleAgent* consoleAgent = consoleAgentPtr.get(); 121 InspectorConsoleFactory* consoleFactory = consoleFactoryPtr.get();
123 m_agents.append(consoleAgentPtr.release()); 122 m_agentFactories.append(consoleFactoryPtr.release());
124 123
125 OwnPtr<InspectorDebuggerAgent> debuggerAgentPtr(PageDebuggerAgent::create(m_ instrumentingAgents.get(), m_state.get(), pageScriptDebugServer, pageAgent, m_in jectedScriptManager.get(), m_overlay.get())); 124 OwnPtr<PageDebuggerFactory> debuggerFactoryPtr(PageDebuggerFactory::create(m _instrumentingAgents.get(), m_state.get(), pageScriptDebugServer, pageFactory, m _injectedScriptManager.get(), m_overlay.get()));
126 InspectorDebuggerAgent* debuggerAgent = debuggerAgentPtr.get(); 125 PageDebuggerFactory* debuggerFactory = debuggerFactoryPtr.get();
127 m_agents.append(debuggerAgentPtr.release()); 126 m_agentFactories.append(debuggerFactoryPtr.release());
128 127
129 m_agents.append(InspectorDOMDebuggerAgent::create(m_instrumentingAgents.get( ), m_state.get(), domAgent, debuggerAgent)); 128 m_agentFactories.append(InspectorDOMDebuggerFactory::create(m_instrumentingA gents.get(), m_state.get(), domFactory, debuggerFactory));
130 129
131 m_agents.append(InspectorProfilerAgent::create(m_instrumentingAgents.get(), consoleAgent, m_state.get(), m_injectedScriptManager.get())); 130 m_agentFactories.append(InspectorProfilerFactory::create(m_instrumentingAgen ts.get(), m_state.get(), consoleFactory, m_injectedScriptManager.get()));
132 131
133 m_agents.append(InspectorHeapProfilerAgent::create(m_instrumentingAgents.get (), m_state.get(), m_injectedScriptManager.get())); 132 m_agentFactories.append(InspectorHeapProfilerFactory::create(m_instrumenting Agents.get(), m_state.get(), m_injectedScriptManager.get()));
134 133
135 134
136 m_agents.append(InspectorWorkerAgent::create(m_instrumentingAgents.get(), m_ state.get())); 135 m_agentFactories.append(InspectorWorkerFactory::create(m_instrumentingAgents .get(), m_state.get()));
137 136
138 m_agents.append(InspectorCanvasAgent::create(m_instrumentingAgents.get(), m_ state.get(), pageAgent, m_injectedScriptManager.get())); 137 m_agentFactories.append(InspectorCanvasFactory::create(m_instrumentingAgents .get(), m_state.get(), pageFactory, m_injectedScriptManager.get()));
139 138
140 m_agents.append(InspectorInputAgent::create(m_instrumentingAgents.get(), m_s tate.get(), page, inspectorClient)); 139 m_agentFactories.append(InspectorInputFactory::create(m_instrumentingAgents. get(), m_state.get(), page, inspectorClient));
141 140
142 m_agents.append(InspectorLayerTreeAgent::create(m_instrumentingAgents.get(), m_state.get())); 141 m_agentFactories.append(InspectorLayerTreeFactory::create(m_instrumentingAge nts.get(), m_state.get()));
143 142
144 ASSERT_ARG(inspectorClient, inspectorClient); 143 ASSERT_ARG(inspectorClient, inspectorClient);
145 m_injectedScriptManager->injectedScriptHost()->init(m_instrumentingAgents.ge t(), pageScriptDebugServer); 144 m_injectedScriptManager->injectedScriptHost()->init(m_instrumentingAgents.ge t(), pageScriptDebugServer);
146 } 145 }
147 146
148 InspectorController::~InspectorController() 147 InspectorController::~InspectorController()
149 { 148 {
150 m_instrumentingAgents->reset(); 149 m_instrumentingAgents->reset();
151 m_agents.discardAgents(); 150 m_agentFactories.discardDependencies();
152 ASSERT(!m_inspectorClient); 151 ASSERT(!m_inspectorClient);
153 } 152 }
154 153
155 PassOwnPtr<InspectorController> InspectorController::create(Page* page, Inspecto rClient* client) 154 PassOwnPtr<InspectorController> InspectorController::create(Page* page, Inspecto rClient* client)
156 { 155 {
157 return adoptPtr(new InspectorController(page, client)); 156 return adoptPtr(new InspectorController(page, client));
158 } 157 }
159 158
160 void InspectorController::inspectedPageDestroyed() 159 void InspectorController::inspectedPageDestroyed()
161 { 160 {
(...skipping 20 matching lines...) Expand all
182 } 181 }
183 182
184 void InspectorController::connectFrontend(InspectorFrontendChannel* frontendChan nel) 183 void InspectorController::connectFrontend(InspectorFrontendChannel* frontendChan nel)
185 { 184 {
186 ASSERT(frontendChannel); 185 ASSERT(frontendChannel);
187 186
188 m_inspectorFrontend = adoptPtr(new InspectorFrontend(frontendChannel)); 187 m_inspectorFrontend = adoptPtr(new InspectorFrontend(frontendChannel));
189 // We can reconnect to existing front-end -> unmute state. 188 // We can reconnect to existing front-end -> unmute state.
190 m_state->unmute(); 189 m_state->unmute();
191 190
192 m_agents.setFrontend(m_inspectorFrontend.get()); 191 m_agentFactories.setFrontend(m_inspectorFrontend.get());
193 192
194 InspectorInstrumentation::registerInstrumentingAgents(m_instrumentingAgents. get()); 193 InspectorInstrumentation::registerInstrumentingAgents(m_instrumentingAgents. get());
195 InspectorInstrumentation::frontendCreated(); 194 InspectorInstrumentation::frontendCreated();
196 195
197 ASSERT(m_inspectorClient); 196 ASSERT(m_inspectorClient);
198 m_inspectorBackendDispatcher = InspectorBackendDispatcher::create(frontendCh annel); 197 m_inspectorBackendDispatcher = InspectorBackendDispatcher::create(frontendCh annel);
199 198
200 m_agents.registerInDispatcher(m_inspectorBackendDispatcher.get()); 199 m_agentFactories.registerInDispatcher(m_inspectorBackendDispatcher.get());
201 } 200 }
202 201
203 void InspectorController::disconnectFrontend() 202 void InspectorController::disconnectFrontend()
204 { 203 {
205 if (!m_inspectorFrontend) 204 if (!m_inspectorFrontend)
206 return; 205 return;
207 m_inspectorBackendDispatcher->clearFrontend(); 206 m_inspectorBackendDispatcher->clearFrontend();
208 m_inspectorBackendDispatcher.clear(); 207 m_inspectorBackendDispatcher.clear();
209 208
210 // Destroying agents would change the state, but we don't want that. 209 // Destroying agents would change the state, but we don't want that.
211 // Pre-disconnect state will be used to restore inspector agents. 210 // Pre-disconnect state will be used to restore inspector agents.
212 m_state->mute(); 211 m_state->mute();
213 212
214 m_agents.clearFrontend(); 213 m_agentFactories.clearFrontend();
215 214
216 m_inspectorFrontend.clear(); 215 m_inspectorFrontend.clear();
217 216
218 // relese overlay page resources 217 // relese overlay page resources
219 m_overlay->freePage(); 218 m_overlay->freePage();
220 InspectorInstrumentation::frontendDeleted(); 219 InspectorInstrumentation::frontendDeleted();
221 InspectorInstrumentation::unregisterInstrumentingAgents(m_instrumentingAgent s.get()); 220 InspectorInstrumentation::unregisterInstrumentingAgents(m_instrumentingAgent s.get());
222 } 221 }
223 222
224 void InspectorController::reconnectFrontend() 223 void InspectorController::reconnectFrontend()
225 { 224 {
226 if (!m_inspectorFrontend) 225 if (!m_inspectorFrontend)
227 return; 226 return;
228 InspectorFrontendChannel* frontendChannel = m_inspectorFrontend->inspector() ->getInspectorFrontendChannel(); 227 InspectorFrontendChannel* frontendChannel = m_inspectorFrontend->inspector() ->getInspectorFrontendChannel();
229 disconnectFrontend(); 228 disconnectFrontend();
230 connectFrontend(frontendChannel); 229 connectFrontend(frontendChannel);
231 } 230 }
232 231
233 void InspectorController::reuseFrontend(InspectorFrontendChannel* frontendChanne l, const String& inspectorStateCookie) 232 void InspectorController::reuseFrontend(InspectorFrontendChannel* frontendChanne l, const String& inspectorStateCookie)
234 { 233 {
235 ASSERT(!m_inspectorFrontend); 234 ASSERT(!m_inspectorFrontend);
236 connectFrontend(frontendChannel); 235 connectFrontend(frontendChannel);
237 m_state->loadFromCookie(inspectorStateCookie); 236 m_state->loadFromCookie(inspectorStateCookie);
238 m_agents.restore(); 237 m_agentFactories.restore();
239 } 238 }
240 239
241 void InspectorController::setProcessId(long processId) 240 void InspectorController::setProcessId(long processId)
242 { 241 {
243 IdentifiersFactory::setProcessId(processId); 242 IdentifiersFactory::setProcessId(processId);
244 } 243 }
245 244
246 void InspectorController::webViewResized(const IntSize& size) 245 void InspectorController::webViewResized(const IntSize& size)
247 { 246 {
248 if (InspectorPageAgent* pageAgent = m_instrumentingAgents->inspectorPageAgen t()) 247 if (InspectorPageAgent* pageAgent = m_instrumentingAgents->inspectorPageAgen t())
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 info.addMember(m_instrumentingAgents, "instrumentingAgents"); 363 info.addMember(m_instrumentingAgents, "instrumentingAgents");
365 info.addMember(m_injectedScriptManager, "injectedScriptManager"); 364 info.addMember(m_injectedScriptManager, "injectedScriptManager");
366 info.addMember(m_state, "state"); 365 info.addMember(m_state, "state");
367 info.addMember(m_overlay, "overlay"); 366 info.addMember(m_overlay, "overlay");
368 367
369 info.addMember(m_inspectorBackendDispatcher, "inspectorBackendDispatcher"); 368 info.addMember(m_inspectorBackendDispatcher, "inspectorBackendDispatcher");
370 info.addMember(m_inspectorFrontendClient, "inspectorFrontendClient"); 369 info.addMember(m_inspectorFrontendClient, "inspectorFrontendClient");
371 info.addMember(m_inspectorFrontend, "inspectorFrontend"); 370 info.addMember(m_inspectorFrontend, "inspectorFrontend");
372 info.addMember(m_page, "page"); 371 info.addMember(m_page, "page");
373 info.addWeakPointer(m_inspectorClient); 372 info.addWeakPointer(m_inspectorClient);
374 info.addMember(m_agents, "agents"); 373 info.addMember(m_agentFactories, "agents");
375 } 374 }
376 375
377 void InspectorController::willProcessTask() 376 void InspectorController::willProcessTask()
378 { 377 {
379 if (InspectorTimelineAgent* timelineAgent = m_instrumentingAgents->inspector TimelineAgent()) 378 if (InspectorTimelineAgent* timelineAgent = m_instrumentingAgents->inspector TimelineAgent())
380 timelineAgent->willProcessTask(); 379 timelineAgent->willProcessTask();
381 if (InspectorProfilerAgent* profilerAgent = m_instrumentingAgents->inspector ProfilerAgent()) 380 if (InspectorProfilerAgent* profilerAgent = m_instrumentingAgents->inspector ProfilerAgent())
382 profilerAgent->willProcessTask(); 381 profilerAgent->willProcessTask();
383 } 382 }
384 383
(...skipping 29 matching lines...) Expand all
414 413
415 void InspectorController::didComposite() 414 void InspectorController::didComposite()
416 { 415 {
417 if (InspectorTimelineAgent* timelineAgent = m_instrumentingAgents->inspector TimelineAgent()) 416 if (InspectorTimelineAgent* timelineAgent = m_instrumentingAgents->inspector TimelineAgent())
418 timelineAgent->didComposite(); 417 timelineAgent->didComposite();
419 } 418 }
420 419
421 HashMap<String, size_t> InspectorController::processMemoryDistribution() const 420 HashMap<String, size_t> InspectorController::processMemoryDistribution() const
422 { 421 {
423 HashMap<String, size_t> memoryInfo; 422 HashMap<String, size_t> memoryInfo;
424 m_memoryAgent->getProcessMemoryDistributionMap(&memoryInfo); 423 m_memoryFactory->agent()->getProcessMemoryDistributionMap(&memoryInfo);
425 return memoryInfo; 424 return memoryInfo;
426 } 425 }
427 426
428 } // namespace WebCore 427 } // 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