Chromium Code Reviews| Index: Source/devtools/front_end/timeline/TracingTimelineModel.js |
| diff --git a/Source/devtools/front_end/timeline/TracingTimelineModel.js b/Source/devtools/front_end/timeline/TracingTimelineModel.js |
| index 99a364ef56a6492e321705182a8981d034b54304..e46b3cdd69db291bc50d412f1dc6db9f182be250 100644 |
| --- a/Source/devtools/front_end/timeline/TracingTimelineModel.js |
| +++ b/Source/devtools/front_end/timeline/TracingTimelineModel.js |
| @@ -356,6 +356,19 @@ WebInspector.TracingTimelineModel.prototype = { |
| { |
| var recordStack = []; |
| var mainThreadEvents = this.mainThreadEvents(); |
| + |
| + /** |
| + * @param {!WebInspector.TracingTimelineModel.TraceEventRecord} top |
| + */ |
| + function copyChildrenToNextTop(top) { |
|
caseq
2014/09/15 14:07:41
{ => next line
yurys
2014/09/15 14:36:45
Done.
|
| + 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.
|
| + var parentChildren = nextTop.children(); |
| + var children = top.children(); |
| + for (var j = 0; j < children.length; ++j) |
| + children[j].parent = nextTop; |
| + parentChildren.splice.apply(parentChildren, [parentChildren.indexOf(top), 1].concat(children)); |
| + } |
| + |
| for (var i = 0, size = mainThreadEvents.length; i < size; ++i) { |
| var event = mainThreadEvents[i]; |
| while (recordStack.length) { |
| @@ -374,14 +387,9 @@ WebInspector.TracingTimelineModel.prototype = { |
| } |
| break; |
| } |
| - // Delete incomple async record from parent and adopt its children. |
| + // Delete incomplete async record from parent and adopt its children. |
| recordStack.pop(); |
| - var nextTop = recordStack.peekLast(); |
| - var parentChildren = nextTop.children(); |
| - var children = top.children(); |
| - for (var j = 0; j < children.length; ++j) |
| - children[j].parent = nextTop; |
| - parentChildren.splice.apply(parentChildren, [parentChildren.indexOf(top), 1].concat(children)); |
| + copyChildrenToNextTop(top); |
| continue; |
| } else if (top._event.endTime >= event.startTime) { |
| break; |
| @@ -403,6 +411,16 @@ WebInspector.TracingTimelineModel.prototype = { |
| if (event.endTime || (event.phase === WebInspector.TracingModel.Phase.AsyncBegin && parentRecord)) |
| recordStack.push(record); |
| } |
| + |
| + // Close all remaining incomplete async events. |
| + while (recordStack.length > 1) { |
| + var top = recordStack.pop(); |
| + if (!top._event.endTime) { |
| + // Delete incomplete async record from parent and adopt its children. |
| + copyChildrenToNextTop(top); |
| + } |
| + } |
| + |
| if (recordStack.length) |
| this._addTopLevelRecord(recordStack[0]); |
| }, |