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} record |
| 362 */ |
| 363 function copyChildrenToParent(record) |
| 364 { |
| 365 var parent = record.parent; |
| 366 var parentChildren = parent.children(); |
| 367 var children = record.children(); |
| 368 for (var j = 0; j < children.length; ++j) |
| 369 children[j].parent = parent; |
| 370 parentChildren.splice.apply(parentChildren, [parentChildren.indexOf(
record), 1].concat(children)); |
| 371 } |
| 372 |
359 for (var i = 0, size = mainThreadEvents.length; i < size; ++i) { | 373 for (var i = 0, size = mainThreadEvents.length; i < size; ++i) { |
360 var event = mainThreadEvents[i]; | 374 var event = mainThreadEvents[i]; |
361 while (recordStack.length) { | 375 while (recordStack.length) { |
362 var top = recordStack.peekLast(); | 376 var top = recordStack.peekLast(); |
363 // When we've got a not-yet-complete async event at the top of t
he stack, | 377 // 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 | 378 // 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 | 379 // before end of top-level event (presumably, a "Program"), pret
end the |
366 // async event never happened. | 380 // async event never happened. |
367 if (!top._event.endTime) { | 381 if (!top._event.endTime) { |
368 if (event.phase !== WebInspector.TracingModel.Phase.AsyncEnd
&& recordStack[0]._event.endTime >= event.startTime) | 382 if (event.phase !== WebInspector.TracingModel.Phase.AsyncEnd
&& recordStack[0]._event.endTime >= event.startTime) |
369 break; | 383 break; |
370 if (event.phase === WebInspector.TracingModel.Phase.AsyncEnd
) { | 384 if (event.phase === WebInspector.TracingModel.Phase.AsyncEnd
) { |
371 if (top._event.name === event.name) { | 385 if (top._event.name === event.name) { |
372 top.setEndTime(event.startTime); | 386 top.setEndTime(event.startTime); |
373 recordStack.pop(); | 387 recordStack.pop(); |
374 } | 388 } |
375 break; | 389 break; |
376 } | 390 } |
377 // Delete incomple async record from parent and adopt its ch
ildren. | 391 // Delete incomplete async record from parent and adopt its
children. |
378 recordStack.pop(); | 392 recordStack.pop(); |
379 var nextTop = recordStack.peekLast(); | 393 copyChildrenToParent(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; | 394 continue; |
386 } else if (top._event.endTime >= event.startTime) { | 395 } else if (top._event.endTime >= event.startTime) { |
387 break; | 396 break; |
388 } | 397 } |
389 recordStack.pop(); | 398 recordStack.pop(); |
390 if (!recordStack.length) | 399 if (!recordStack.length) |
391 this._addTopLevelRecord(top); | 400 this._addTopLevelRecord(top); |
392 } | 401 } |
393 if (event.phase === WebInspector.TracingModel.Phase.AsyncEnd) | 402 if (event.phase === WebInspector.TracingModel.Phase.AsyncEnd) |
394 continue; | 403 continue; |
395 var record = new WebInspector.TracingTimelineModel.TraceEventRecord(
this, event); | 404 var record = new WebInspector.TracingTimelineModel.TraceEventRecord(
this, event); |
396 if (WebInspector.TracingTimelineUIUtils.isMarkerEvent(event)) | 405 if (WebInspector.TracingTimelineUIUtils.isMarkerEvent(event)) |
397 this._eventDividerRecords.push(record); | 406 this._eventDividerRecords.push(record); |
398 if (!this._recordFilter.accept(record)) | 407 if (!this._recordFilter.accept(record)) |
399 continue; | 408 continue; |
400 var parentRecord = recordStack.peekLast(); | 409 var parentRecord = recordStack.peekLast(); |
401 if (parentRecord) | 410 if (parentRecord) |
402 parentRecord._addChild(record); | 411 parentRecord._addChild(record); |
403 if (event.endTime || (event.phase === WebInspector.TracingModel.Phas
e.AsyncBegin && parentRecord)) | 412 if (event.endTime || (event.phase === WebInspector.TracingModel.Phas
e.AsyncBegin && parentRecord)) |
404 recordStack.push(record); | 413 recordStack.push(record); |
405 } | 414 } |
| 415 |
| 416 // Close all remaining incomplete async events. |
| 417 while (recordStack.length > 1) { |
| 418 var top = recordStack.pop(); |
| 419 if (!top._event.endTime) { |
| 420 // Delete incomplete async record from parent and adopt its chil
dren. |
| 421 copyChildrenToParent(top); |
| 422 } |
| 423 } |
| 424 |
406 if (recordStack.length) | 425 if (recordStack.length) |
407 this._addTopLevelRecord(recordStack[0]); | 426 this._addTopLevelRecord(recordStack[0]); |
408 }, | 427 }, |
409 | 428 |
410 /** | 429 /** |
411 * @param {!WebInspector.TracingTimelineModel.TraceEventRecord} record | 430 * @param {!WebInspector.TracingTimelineModel.TraceEventRecord} record |
412 */ | 431 */ |
413 _addTopLevelRecord: function(record) | 432 _addTopLevelRecord: function(record) |
414 { | 433 { |
415 this._updateBoundaries(record); | 434 this._updateBoundaries(record); |
(...skipping 645 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1061 }, | 1080 }, |
1062 | 1081 |
1063 _didWriteNextChunk: function(stream) | 1082 _didWriteNextChunk: function(stream) |
1064 { | 1083 { |
1065 if (this._recordIndex === this._payloads.length) | 1084 if (this._recordIndex === this._payloads.length) |
1066 stream.close(); | 1085 stream.close(); |
1067 else | 1086 else |
1068 this._writeNextChunk(stream); | 1087 this._writeNextChunk(stream); |
1069 } | 1088 } |
1070 } | 1089 } |
OLD | NEW |