Commit 3a41fc88 authored by yurys@chromium.org's avatar yurys@chromium.org

DevTools: correctly close all async records when there are no subsequent top level records

BUG=405502

Review URL: https://codereview.chromium.org/572653003

git-svn-id: svn://svn.chromium.org/blink/trunk@181984 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 49f9b53a
......@@ -356,6 +356,20 @@ WebInspector.TracingTimelineModel.prototype = {
{
var recordStack = [];
var mainThreadEvents = this.mainThreadEvents();
/**
* @param {!WebInspector.TracingTimelineModel.TraceEventRecord} record
*/
function copyChildrenToParent(record)
{
var parent = record.parent;
var parentChildren = parent.children();
var children = record.children();
for (var j = 0; j < children.length; ++j)
children[j].parent = parent;
parentChildren.splice.apply(parentChildren, [parentChildren.indexOf(record), 1].concat(children));
}
for (var i = 0, size = mainThreadEvents.length; i < size; ++i) {
var event = mainThreadEvents[i];
while (recordStack.length) {
......@@ -374,14 +388,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));
copyChildrenToParent(top);
continue;
} else if (top._event.endTime >= event.startTime) {
break;
......@@ -403,6 +412,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.
copyChildrenToParent(top);
}
}
if (recordStack.length)
this._addTopLevelRecord(recordStack[0]);
},
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment