OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <!-- | 2 <!-- |
3 Copyright 2015 The Chromium Authors. All rights reserved. | 3 Copyright 2015 The Chromium Authors. All rights reserved. |
4 Use of this source code is governed by a BSD-style license that can be | 4 Use of this source code is governed by a BSD-style license that can be |
5 found in the LICENSE file. | 5 found in the LICENSE file. |
6 --> | 6 --> |
7 | 7 |
8 <link rel='import' href='/tracing/base/base.html'> | 8 <link rel='import' href='/tracing/base/base.html'> |
9 <link rel="import" href="/tracing/importer/empty_importer.html"> | 9 <link rel="import" href="/tracing/importer/empty_importer.html"> |
10 <link rel="import" href="/tracing/importer/importer.html"> | 10 <link rel="import" href="/tracing/importer/importer.html"> |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 * importTraces. | 103 * importTraces. |
104 */ | 104 */ |
105 createImportTracesTask: function(progressMeter, traces) { | 105 createImportTracesTask: function(progressMeter, traces) { |
106 if (this.importing_) | 106 if (this.importing_) |
107 throw new Error('Already importing.'); | 107 throw new Error('Already importing.'); |
108 this.importing_ = true; | 108 this.importing_ = true; |
109 | 109 |
110 // Just some simple setup. It is useful to have a no-op first | 110 // Just some simple setup. It is useful to have a no-op first |
111 // task so that we can set up the lastTask = lastTask.after() | 111 // task so that we can set up the lastTask = lastTask.after() |
112 // pattern that follows. | 112 // pattern that follows. |
113 var importTask = new tr.b.Task(function() { | 113 var importTask = new tr.b.Task(function prepareImport() { |
114 progressMeter.update('I will now import your traces for you...'); | 114 progressMeter.update('I will now import your traces for you...'); |
115 }, this); | 115 }, this); |
116 var lastTask = importTask; | 116 var lastTask = importTask; |
117 | 117 |
118 var importers = []; | 118 var importers = []; |
119 | 119 |
120 lastTask = lastTask.after(function() { | 120 lastTask = lastTask.after(function createImports() { |
121 // Copy the traces array, we may mutate it. | 121 // Copy the traces array, we may mutate it. |
122 traces = traces.slice(0); | 122 traces = traces.slice(0); |
123 progressMeter.update('Creating importers...'); | 123 progressMeter.update('Creating importers...'); |
124 // Figure out which importers to use. | 124 // Figure out which importers to use. |
125 for (var i = 0; i < traces.length; ++i) | 125 for (var i = 0; i < traces.length; ++i) |
126 importers.push(this.createImporter_(traces[i])); | 126 importers.push(this.createImporter_(traces[i])); |
127 | 127 |
128 // Some traces have other traces inside them. Before doing the full | 128 // Some traces have other traces inside them. Before doing the full |
129 // import, ask the importer if it has any subtraces, and if so, create | 129 // import, ask the importer if it has any subtraces, and if so, create |
130 // importers for them, also. | 130 // importers for them, also. |
(...skipping 18 matching lines...) Expand all Loading... |
149 | 149 |
150 // Sort them on priority. This ensures importing happens in a | 150 // Sort them on priority. This ensures importing happens in a |
151 // predictable order, e.g. ftrace_importer before | 151 // predictable order, e.g. ftrace_importer before |
152 // trace_event_importer. | 152 // trace_event_importer. |
153 importers.sort(function(x, y) { | 153 importers.sort(function(x, y) { |
154 return x.importPriority - y.importPriority; | 154 return x.importPriority - y.importPriority; |
155 }); | 155 }); |
156 }, this); | 156 }, this); |
157 | 157 |
158 // Run the import. | 158 // Run the import. |
159 lastTask = lastTask.after(function(task) { | 159 lastTask = lastTask.after(function runImport(task) { |
160 importers.forEach(function(importer, index) { | 160 importers.forEach(function(importer, index) { |
161 task.subTask(function() { | 161 task.subTask(function runImportEventsOnOneImporter() { |
162 progressMeter.update( | 162 progressMeter.update( |
163 'Importing ' + (index + 1) + ' of ' + importers.length); | 163 'Importing ' + (index + 1) + ' of ' + importers.length); |
164 importer.importEvents(); | 164 importer.importEvents(); |
165 }, this); | 165 }, this); |
166 }, this); | 166 }, this); |
167 }, this); | 167 }, this); |
168 | 168 |
169 // Run the cusomizeModelCallback if needed. | 169 // Run the cusomizeModelCallback if needed. |
170 if (this.importOptions_.customizeModelCallback) { | 170 if (this.importOptions_.customizeModelCallback) { |
171 lastTask = lastTask.after(function(task) { | 171 lastTask = lastTask.after(function runCustomizeCallbacks(task) { |
172 this.importOptions_.customizeModelCallback(this.model_); | 172 this.importOptions_.customizeModelCallback(this.model_); |
173 }, this); | 173 }, this); |
174 } | 174 } |
175 | 175 |
176 // Import sample data. | 176 // Import sample data. |
177 lastTask = lastTask.after(function(task) { | 177 lastTask = lastTask.after(function(task) { |
178 importers.forEach(function(importer, index) { | 178 importers.forEach(function importSampleData(importer, index) { |
179 progressMeter.update( | 179 progressMeter.update( |
180 'Importing sample data ' + (index + 1) + '/' + importers.length); | 180 'Importing sample data ' + (index + 1) + '/' + importers.length); |
181 importer.importSampleData(); | 181 importer.importSampleData(); |
182 }, this); | 182 }, this); |
183 }, this); | 183 }, this); |
184 | 184 |
185 // Autoclose open slices and create subSlices. | 185 // Autoclose open slices and create subSlices. |
186 lastTask = lastTask.after(function() { | 186 lastTask = lastTask.after(function runAutoclosers() { |
187 progressMeter.update('Autoclosing open slices...'); | 187 progressMeter.update('Autoclosing open slices...'); |
188 this.model_.autoCloseOpenSlices(); | 188 this.model_.autoCloseOpenSlices(); |
189 this.model_.createSubSlices(); | 189 this.model_.createSubSlices(); |
190 }, this); | 190 }, this); |
191 | 191 |
192 // Finalize import. | 192 // Finalize import. |
193 lastTask = lastTask.after(function(task) { | 193 lastTask = lastTask.after(function finalizeImport(task) { |
194 importers.forEach(function(importer, index) { | 194 importers.forEach(function(importer, index) { |
195 progressMeter.update( | 195 progressMeter.update( |
196 'Finalizing import ' + (index + 1) + '/' + importers.length); | 196 'Finalizing import ' + (index + 1) + '/' + importers.length); |
197 importer.finalizeImport(); | 197 importer.finalizeImport(); |
198 }, this); | 198 }, this); |
199 }, this); | 199 }, this); |
200 | 200 |
201 // Run preinit. | 201 // Run preinit. |
202 lastTask = lastTask.after(function() { | 202 lastTask = lastTask.after(function runPreinits() { |
203 progressMeter.update('Initializing objects (step 1/2)...'); | 203 progressMeter.update('Initializing objects (step 1/2)...'); |
204 this.model_.preInitializeObjects(); | 204 this.model_.preInitializeObjects(); |
205 }, this); | 205 }, this); |
206 | 206 |
207 // Prune empty containers. | 207 // Prune empty containers. |
208 if (this.importOptions_.pruneEmptyContainers) { | 208 if (this.importOptions_.pruneEmptyContainers) { |
209 lastTask = lastTask.after(function() { | 209 lastTask = lastTask.after(function runPruneEmptyContainers() { |
210 progressMeter.update('Pruning empty containers...'); | 210 progressMeter.update('Pruning empty containers...'); |
211 this.model_.pruneEmptyContainers(); | 211 this.model_.pruneEmptyContainers(); |
212 }, this); | 212 }, this); |
213 } | 213 } |
214 | 214 |
215 // Merge kernel and userland slices on each thread. | 215 // Merge kernel and userland slices on each thread. |
216 lastTask = lastTask.after(function() { | 216 lastTask = lastTask.after(function runMergeKernelWithuserland() { |
217 progressMeter.update('Merging kernel with userland...'); | 217 progressMeter.update('Merging kernel with userland...'); |
218 this.model_.mergeKernelWithUserland(); | 218 this.model_.mergeKernelWithUserland(); |
219 }, this); | 219 }, this); |
220 | 220 |
221 // Create auditors | 221 // Create auditors |
222 var auditors = []; | 222 var auditors = []; |
223 lastTask = lastTask.after(function() { | 223 lastTask = lastTask.after(function createAuditorsAndRunAnnotate() { |
224 progressMeter.update('Adding arbitrary data to model...'); | 224 progressMeter.update('Adding arbitrary data to model...'); |
225 auditors = this.importOptions_.auditorConstructors.map( | 225 auditors = this.importOptions_.auditorConstructors.map( |
226 function(auditorConstructor) { | 226 function(auditorConstructor) { |
227 return new auditorConstructor(this.model_); | 227 return new auditorConstructor(this.model_); |
228 }, this); | 228 }, this); |
229 auditors.forEach(function(auditor) { | 229 auditors.forEach(function(auditor) { |
230 auditor.runAnnotate(); | 230 auditor.runAnnotate(); |
231 }); | 231 }); |
232 }, this); | 232 }, this); |
233 | 233 |
234 lastTask = lastTask.after(function() { | 234 lastTask = lastTask.after(function computeWorldBounds() { |
235 progressMeter.update('Computing final world bounds...'); | 235 progressMeter.update('Computing final world bounds...'); |
236 this.model_.computeWorldBounds(this.importOptions_.shiftWorldToZero); | 236 this.model_.computeWorldBounds(this.importOptions_.shiftWorldToZero); |
237 }, this); | 237 }, this); |
238 | 238 |
239 // Build the flow event interval tree. | 239 // Build the flow event interval tree. |
240 lastTask = lastTask.after(function() { | 240 lastTask = lastTask.after(function buildFlowEventIntervalTree() { |
241 progressMeter.update('Building flow event map...'); | 241 progressMeter.update('Building flow event map...'); |
242 this.model_.buildFlowEventIntervalTree(); | 242 this.model_.buildFlowEventIntervalTree(); |
243 }, this); | 243 }, this); |
244 | 244 |
245 // Join refs. | 245 // Join refs. |
246 lastTask = lastTask.after(function() { | 246 lastTask = lastTask.after(function joinRefs() { |
247 progressMeter.update('Joining object refs...'); | 247 progressMeter.update('Joining object refs...'); |
248 for (var i = 0; i < importers.length; i++) | 248 for (var i = 0; i < importers.length; i++) |
249 importers[i].joinRefs(); | 249 importers[i].joinRefs(); |
250 }, this); | 250 }, this); |
251 | 251 |
252 // Delete any undeleted objects. | 252 // Delete any undeleted objects. |
253 lastTask = lastTask.after(function() { | 253 lastTask = lastTask.after(function cleanupUndeletedObjects() { |
254 progressMeter.update('Cleaning up undeleted objects...'); | 254 progressMeter.update('Cleaning up undeleted objects...'); |
255 this.model_.cleanupUndeletedObjects(); | 255 this.model_.cleanupUndeletedObjects(); |
256 }, this); | 256 }, this); |
257 | 257 |
258 // Sort global and process memory dumps. | 258 // Sort global and process memory dumps. |
259 lastTask = lastTask.after(function() { | 259 lastTask = lastTask.after(function sortMemoryDumps() { |
260 progressMeter.update('Sorting memory dumps...'); | 260 progressMeter.update('Sorting memory dumps...'); |
261 this.model_.sortMemoryDumps(); | 261 this.model_.sortMemoryDumps(); |
262 }, this); | 262 }, this); |
263 | 263 |
264 // Calculate memory dump graph attributes. | 264 // Calculate memory dump graph attributes. |
265 lastTask = lastTask.after(function() { | 265 lastTask = lastTask.after(function calculateMemoryGraphAttributes() { |
266 progressMeter.update('Calculating memory dump graph attributes...'); | 266 progressMeter.update('Calculating memory dump graph attributes...'); |
267 this.model_.calculateMemoryGraphAttributes(); | 267 this.model_.calculateMemoryGraphAttributes(); |
268 }, this); | 268 }, this); |
269 | 269 |
270 // Run initializers. | 270 // Run initializers. |
271 lastTask = lastTask.after(function() { | 271 lastTask = lastTask.after(function initializeObjects() { |
272 progressMeter.update('Initializing objects (step 2/2)...'); | 272 progressMeter.update('Initializing objects (step 2/2)...'); |
273 this.model_.initializeObjects(); | 273 this.model_.initializeObjects(); |
274 }, this); | 274 }, this); |
275 | 275 |
276 // Build event indices mapping from an event id to all flow events. | 276 // Build event indices mapping from an event id to all flow events. |
277 lastTask = lastTask.after(function() { | 277 lastTask = lastTask.after(function buildEventIndices() { |
278 progressMeter.update('Building flow event indices...'); | 278 progressMeter.update('Building event indices...'); |
279 this.model_.buildEventIndices(); | 279 this.model_.buildEventIndices(); |
280 }, this); | 280 }, this); |
281 | 281 |
282 // Run audits. | 282 // Run audits. |
283 lastTask = lastTask.after(function() { | 283 lastTask = lastTask.after(function runAudits() { |
284 progressMeter.update('Running auditors...'); | 284 progressMeter.update('Running auditors...'); |
285 auditors.forEach(function(auditor) { | 285 auditors.forEach(function(auditor) { |
286 auditor.runAudit(); | 286 auditor.runAudit(); |
287 }); | 287 }); |
288 }, this); | 288 }, this); |
289 | 289 |
290 lastTask = lastTask.after(function() { | 290 lastTask = lastTask.after(function sortInteractionRecords() { |
291 progressMeter.update('Updating interaction records...'); | 291 progressMeter.update('Updating interaction records...'); |
292 this.model_.sortInteractionRecords(); | 292 this.model_.sortInteractionRecords(); |
293 }, this); | 293 }, this); |
294 | 294 |
295 lastTask = lastTask.after(function() { | 295 lastTask = lastTask.after(function sortAlerts() { |
296 progressMeter.update('Updating alerts...'); | 296 progressMeter.update('Updating alerts...'); |
297 this.model_.sortAlerts(); | 297 this.model_.sortAlerts(); |
298 }, this); | 298 }, this); |
299 | 299 |
300 lastTask = lastTask.after(function() { | 300 lastTask = lastTask.after(function lastUpdateBounds() { |
301 progressMeter.update('Update bounds...'); | 301 progressMeter.update('Update bounds...'); |
302 this.model_.updateBounds(); | 302 this.model_.updateBounds(); |
303 }, this); | 303 }, this); |
304 | 304 |
305 // Cleanup. | 305 // Cleanup. |
306 lastTask.after(function() { | 306 lastTask.after(function() { |
307 this.importing_ = false; | 307 this.importing_ = false; |
308 }, this); | 308 }, this); |
309 return importTask; | 309 return importTask; |
310 }, | 310 }, |
(...skipping 18 matching lines...) Expand all Loading... |
329 return false; | 329 return false; |
330 } | 330 } |
331 }; | 331 }; |
332 | 332 |
333 return { | 333 return { |
334 ImportOptions: ImportOptions, | 334 ImportOptions: ImportOptions, |
335 Import: Import | 335 Import: Import |
336 }; | 336 }; |
337 }); | 337 }); |
338 </script> | 338 </script> |
OLD | NEW |