OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 /** | 5 /** |
6 * @constructor | 6 * @constructor |
7 * @param {!WebInspector.TracingManager} tracingManager | 7 * @param {!WebInspector.TracingManager} tracingManager |
8 * @param {!WebInspector.TracingModel} tracingModel | 8 * @param {!WebInspector.TracingModel} tracingModel |
9 * @param {!WebInspector.TimelineModel.Filter} recordFilter | 9 * @param {!WebInspector.TimelineModel.Filter} recordFilter |
10 * @extends {WebInspector.TimelineModel} | 10 * @extends {WebInspector.TimelineModel} |
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
349 this._mainThreadEvents = []; | 349 this._mainThreadEvents = []; |
350 this._mainThreadAsyncEvents = []; | 350 this._mainThreadAsyncEvents = []; |
351 this._inspectedTargetEvents = []; | 351 this._inspectedTargetEvents = []; |
352 WebInspector.TimelineModel.prototype.reset.call(this); | 352 WebInspector.TimelineModel.prototype.reset.call(this); |
353 }, | 353 }, |
354 | 354 |
355 _buildTimelineRecords: function() | 355 _buildTimelineRecords: function() |
356 { | 356 { |
357 var recordStack = []; | 357 var recordStack = []; |
358 var mainThreadEvents = this.mainThreadEvents(); | 358 var mainThreadEvents = this.mainThreadEvents(); |
359 | |
360 /** | |
361 * @param {!WebInspector.TracingTimelineModel.TraceEventRecord} top | |
362 */ | |
363 function copyChildrenToNextTop(top) { | |
caseq
2014/09/15 14:07:41
{ => next line
yurys
2014/09/15 14:36:45
Done.
| |
364 var nextTop = recordStack.peekLast(); | |
caseq
2014/09/15 14:07:41
I'd rather pass this one explicitly to reduce surp
yurys
2014/09/15 14:36:45
Done.
| |
365 var parentChildren = nextTop.children(); | |
366 var children = top.children(); | |
367 for (var j = 0; j < children.length; ++j) | |
368 children[j].parent = nextTop; | |
369 parentChildren.splice.apply(parentChildren, [parentChildren.indexOf( top), 1].concat(children)); | |
370 } | |
371 | |
359 for (var i = 0, size = mainThreadEvents.length; i < size; ++i) { | 372 for (var i = 0, size = mainThreadEvents.length; i < size; ++i) { |
360 var event = mainThreadEvents[i]; | 373 var event = mainThreadEvents[i]; |
361 while (recordStack.length) { | 374 while (recordStack.length) { |
362 var top = recordStack.peekLast(); | 375 var top = recordStack.peekLast(); |
363 // When we've got a not-yet-complete async event at the top of t he stack, | 376 // When we've got a not-yet-complete async event at the top of t he stack, |
364 // see if we can close it by a matching end event. If this doesn 't happen | 377 // see if we can close it by a matching end event. If this doesn 't happen |
365 // before end of top-level event (presumably, a "Program"), pret end the | 378 // before end of top-level event (presumably, a "Program"), pret end the |
366 // async event never happened. | 379 // async event never happened. |
367 if (!top._event.endTime) { | 380 if (!top._event.endTime) { |
368 if (event.phase !== WebInspector.TracingModel.Phase.AsyncEnd && recordStack[0]._event.endTime >= event.startTime) | 381 if (event.phase !== WebInspector.TracingModel.Phase.AsyncEnd && recordStack[0]._event.endTime >= event.startTime) |
369 break; | 382 break; |
370 if (event.phase === WebInspector.TracingModel.Phase.AsyncEnd ) { | 383 if (event.phase === WebInspector.TracingModel.Phase.AsyncEnd ) { |
371 if (top._event.name === event.name) { | 384 if (top._event.name === event.name) { |
372 top.setEndTime(event.startTime); | 385 top.setEndTime(event.startTime); |
373 recordStack.pop(); | 386 recordStack.pop(); |
374 } | 387 } |
375 break; | 388 break; |
376 } | 389 } |
377 // Delete incomple async record from parent and adopt its ch ildren. | 390 // Delete incomplete async record from parent and adopt its children. |
378 recordStack.pop(); | 391 recordStack.pop(); |
379 var nextTop = recordStack.peekLast(); | 392 copyChildrenToNextTop(top); |
380 var parentChildren = nextTop.children(); | |
381 var children = top.children(); | |
382 for (var j = 0; j < children.length; ++j) | |
383 children[j].parent = nextTop; | |
384 parentChildren.splice.apply(parentChildren, [parentChildren. indexOf(top), 1].concat(children)); | |
385 continue; | 393 continue; |
386 } else if (top._event.endTime >= event.startTime) { | 394 } else if (top._event.endTime >= event.startTime) { |
387 break; | 395 break; |
388 } | 396 } |
389 recordStack.pop(); | 397 recordStack.pop(); |
390 if (!recordStack.length) | 398 if (!recordStack.length) |
391 this._addTopLevelRecord(top); | 399 this._addTopLevelRecord(top); |
392 } | 400 } |
393 if (event.phase === WebInspector.TracingModel.Phase.AsyncEnd) | 401 if (event.phase === WebInspector.TracingModel.Phase.AsyncEnd) |
394 continue; | 402 continue; |
395 var record = new WebInspector.TracingTimelineModel.TraceEventRecord( this, event); | 403 var record = new WebInspector.TracingTimelineModel.TraceEventRecord( this, event); |
396 if (WebInspector.TracingTimelineUIUtils.isMarkerEvent(event)) | 404 if (WebInspector.TracingTimelineUIUtils.isMarkerEvent(event)) |
397 this._eventDividerRecords.push(record); | 405 this._eventDividerRecords.push(record); |
398 if (!this._recordFilter.accept(record)) | 406 if (!this._recordFilter.accept(record)) |
399 continue; | 407 continue; |
400 var parentRecord = recordStack.peekLast(); | 408 var parentRecord = recordStack.peekLast(); |
401 if (parentRecord) | 409 if (parentRecord) |
402 parentRecord._addChild(record); | 410 parentRecord._addChild(record); |
403 if (event.endTime || (event.phase === WebInspector.TracingModel.Phas e.AsyncBegin && parentRecord)) | 411 if (event.endTime || (event.phase === WebInspector.TracingModel.Phas e.AsyncBegin && parentRecord)) |
404 recordStack.push(record); | 412 recordStack.push(record); |
405 } | 413 } |
414 | |
415 // Close all remaining incomplete async events. | |
416 while (recordStack.length > 1) { | |
417 var top = recordStack.pop(); | |
418 if (!top._event.endTime) { | |
419 // Delete incomplete async record from parent and adopt its chil dren. | |
420 copyChildrenToNextTop(top); | |
421 } | |
422 } | |
423 | |
406 if (recordStack.length) | 424 if (recordStack.length) |
407 this._addTopLevelRecord(recordStack[0]); | 425 this._addTopLevelRecord(recordStack[0]); |
408 }, | 426 }, |
409 | 427 |
410 /** | 428 /** |
411 * @param {!WebInspector.TracingTimelineModel.TraceEventRecord} record | 429 * @param {!WebInspector.TracingTimelineModel.TraceEventRecord} record |
412 */ | 430 */ |
413 _addTopLevelRecord: function(record) | 431 _addTopLevelRecord: function(record) |
414 { | 432 { |
415 this._updateBoundaries(record); | 433 this._updateBoundaries(record); |
(...skipping 645 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1061 }, | 1079 }, |
1062 | 1080 |
1063 _didWriteNextChunk: function(stream) | 1081 _didWriteNextChunk: function(stream) |
1064 { | 1082 { |
1065 if (this._recordIndex === this._payloads.length) | 1083 if (this._recordIndex === this._payloads.length) |
1066 stream.close(); | 1084 stream.close(); |
1067 else | 1085 else |
1068 this._writeNextChunk(stream); | 1086 this._writeNextChunk(stream); |
1069 } | 1087 } |
1070 } | 1088 } |
OLD | NEW |