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 = { ...@@ -356,6 +356,20 @@ WebInspector.TracingTimelineModel.prototype = {
{ {
var recordStack = []; var recordStack = [];
var mainThreadEvents = this.mainThreadEvents(); 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) { for (var i = 0, size = mainThreadEvents.length; i < size; ++i) {
var event = mainThreadEvents[i]; var event = mainThreadEvents[i];
while (recordStack.length) { while (recordStack.length) {
...@@ -374,14 +388,9 @@ WebInspector.TracingTimelineModel.prototype = { ...@@ -374,14 +388,9 @@ WebInspector.TracingTimelineModel.prototype = {
} }
break; break;
} }
// Delete incomple async record from parent and adopt its children. // Delete incomplete async record from parent and adopt its children.
recordStack.pop(); recordStack.pop();
var nextTop = recordStack.peekLast(); copyChildrenToParent(top);
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));
continue; continue;
} else if (top._event.endTime >= event.startTime) { } else if (top._event.endTime >= event.startTime) {
break; break;
...@@ -403,6 +412,16 @@ WebInspector.TracingTimelineModel.prototype = { ...@@ -403,6 +412,16 @@ WebInspector.TracingTimelineModel.prototype = {
if (event.endTime || (event.phase === WebInspector.TracingModel.Phase.AsyncBegin && parentRecord)) if (event.endTime || (event.phase === WebInspector.TracingModel.Phase.AsyncBegin && parentRecord))
recordStack.push(record); 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) if (recordStack.length)
this._addTopLevelRecord(recordStack[0]); 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