Commit 7d60ac92 authored by yurys@chromium.org's avatar yurys@chromium.org

Don't create TimelineModel.RecordImpl in TimelinePresentationModel.js

TimelinePresentationModel.Record now has three implementations: one for root record, one for coealesced record and one for representing actual TimelineModel.Record. This allows it to work fine with Timeline based on trace events.

BUG=361045
R=caseq@chromium.org

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

git-svn-id: svn://svn.chromium.org/blink/trunk@176205 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent e09741d1
...@@ -207,7 +207,7 @@ InspectorTest.dumpTimelineRecord = function(record, detailsCallback, level, filt ...@@ -207,7 +207,7 @@ InspectorTest.dumpTimelineRecord = function(record, detailsCallback, level, filt
// Dump just the record name, indenting output on separate lines for subrecords // Dump just the record name, indenting output on separate lines for subrecords
InspectorTest.dumpPresentationRecord = function(presentationRecord, detailsCallback, level, filterTypes) InspectorTest.dumpPresentationRecord = function(presentationRecord, detailsCallback, level, filterTypes)
{ {
var record = presentationRecord.record(); var record = !presentationRecord.presentationParent() ? null : presentationRecord.record();
if (typeof level !== "number") if (typeof level !== "number")
level = 0; level = 0;
var prefix = ""; var prefix = "";
...@@ -218,13 +218,14 @@ InspectorTest.dumpPresentationRecord = function(presentationRecord, detailsCallb ...@@ -218,13 +218,14 @@ InspectorTest.dumpPresentationRecord = function(presentationRecord, detailsCallb
prefix = prefix + "> "; prefix = prefix + "> ";
if (presentationRecord.coalesced()) { if (presentationRecord.coalesced()) {
suffix = " x " + presentationRecord.presentationChildren().length; suffix = " x " + presentationRecord.presentationChildren().length;
} else if (record.type() === WebInspector.TimelineModel.RecordType.TimeStamp } else if (record && (record.type() === WebInspector.TimelineModel.RecordType.TimeStamp
|| record.type() === WebInspector.TimelineModel.RecordType.ConsoleTime) { || record.type() === WebInspector.TimelineModel.RecordType.ConsoleTime)) {
suffix = " : " + record.data().message; suffix = " : " + record.data().message;
} }
if (detailsCallback) if (detailsCallback)
suffix += " " + detailsCallback(record); suffix += " " + detailsCallback(presentationRecord);
InspectorTest.addResult(prefix + InspectorTest._timelineAgentTypeToString(record.type()) + suffix); var typeString = record ? InspectorTest._timelineAgentTypeToString(record.type()) : "Root";
InspectorTest.addResult(prefix + typeString + suffix);
var numChildren = presentationRecord.presentationChildren() ? presentationRecord.presentationChildren().length : 0; var numChildren = presentationRecord.presentationChildren() ? presentationRecord.presentationChildren().length : 0;
for (var i = 0; i < numChildren; ++i) { for (var i = 0; i < numChildren; ++i) {
......
...@@ -7,11 +7,11 @@ ...@@ -7,11 +7,11 @@
function initialize_TimelineCoalescing() function initialize_TimelineCoalescing()
{ {
InspectorTest.dumpStats = function(record) InspectorTest.dumpStats = function(presentationRecord)
{ {
if (record.type() === "Root") if (!presentationRecord.presentationParent())
return ""; return "";
var aggregatedStats = record.aggregatedStats(); var aggregatedStats = presentationRecord.presentationAggregatedStats();
var timeByCategory = ""; var timeByCategory = "";
for (category in aggregatedStats) { for (category in aggregatedStats) {
...@@ -19,8 +19,8 @@ InspectorTest.dumpStats = function(record) ...@@ -19,8 +19,8 @@ InspectorTest.dumpStats = function(record)
timeByCategory += ", "; timeByCategory += ", ";
timeByCategory += category + ": " + aggregatedStats[category].toFixed(5); timeByCategory += category + ": " + aggregatedStats[category].toFixed(5);
} }
var duration = (record.endTime() - record.startTime()).toFixed(5); var duration = (presentationRecord.endTime() - presentationRecord.startTime()).toFixed(5);
var durationTillLastChild = (record.endTime() - record.startTime()).toFixed(5); var durationTillLastChild = (presentationRecord.endTime() - presentationRecord.startTime()).toFixed(5);
return "duration: " + duration + ":" + durationTillLastChild + (timeByCategory ? " (" + timeByCategory + ")" : ""); return "duration: " + duration + ":" + durationTillLastChild + (timeByCategory ? " (" + timeByCategory + ")" : "");
} }
......
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
* @constructor * @constructor
* @implements {WebInspector.FlameChartDataProvider} * @implements {WebInspector.FlameChartDataProvider}
* @implements {WebInspector.TimelineFlameChart.SelectionProvider} * @implements {WebInspector.TimelineFlameChart.SelectionProvider}
* @param {!WebInspector.TimelineModel} model * @param {!WebInspector.TimelineModelImpl} model
* @param {!WebInspector.TimelineFrameModelBase} frameModel * @param {!WebInspector.TimelineFrameModelBase} frameModel
*/ */
WebInspector.TimelineFlameChartDataProvider = function(model, frameModel) WebInspector.TimelineFlameChartDataProvider = function(model, frameModel)
...@@ -816,7 +816,7 @@ WebInspector.TimelineFlameChart = function(delegate, model, tracingModel, frameM ...@@ -816,7 +816,7 @@ WebInspector.TimelineFlameChart = function(delegate, model, tracingModel, frameM
this._model = model; this._model = model;
this._dataProvider = tracingModel this._dataProvider = tracingModel
? new WebInspector.TracingBasedTimelineFlameChartDataProvider(tracingModel, frameModel, model.target()) ? new WebInspector.TracingBasedTimelineFlameChartDataProvider(tracingModel, frameModel, model.target())
: new WebInspector.TimelineFlameChartDataProvider(model, frameModel); : new WebInspector.TimelineFlameChartDataProvider(/** @type {!WebInspector.TimelineModelImpl} */(model), frameModel);
this._mainView = new WebInspector.FlameChart(this._dataProvider, this, true); this._mainView = new WebInspector.FlameChart(this._dataProvider, this, true);
this._mainView.show(this.element); this._mainView.show(this.element);
this._model.addEventListener(WebInspector.TimelineModel.Events.RecordingStarted, this._onRecordingStarted, this); this._model.addEventListener(WebInspector.TimelineModel.Events.RecordingStarted, this._onRecordingStarted, this);
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
WebInspector.TimelineJSProfileProcessor = { }; WebInspector.TimelineJSProfileProcessor = { };
/** /**
* @param {!WebInspector.TimelineModel} timelineModel * @param {!WebInspector.TimelineModelImpl} timelineModel
* @param {!ProfilerAgent.CPUProfile} jsProfile * @param {!ProfilerAgent.CPUProfile} jsProfile
*/ */
WebInspector.TimelineJSProfileProcessor.mergeJSProfileIntoTimeline = function(timelineModel, jsProfile) WebInspector.TimelineJSProfileProcessor.mergeJSProfileIntoTimeline = function(timelineModel, jsProfile)
......
...@@ -164,7 +164,6 @@ WebInspector.TimelineModelImpl.prototype = { ...@@ -164,7 +164,6 @@ WebInspector.TimelineModelImpl.prototype = {
* @param {!TimelineAgent.TimelineEvent} payload * @param {!TimelineAgent.TimelineEvent} payload
* @param {?WebInspector.TimelineModel.Record} parentRecord * @param {?WebInspector.TimelineModel.Record} parentRecord
* @return {!WebInspector.TimelineModel.Record} * @return {!WebInspector.TimelineModel.Record}
* @this {!WebInspector.TimelineModel}
*/ */
_innerAddRecord: function(payload, parentRecord) _innerAddRecord: function(payload, parentRecord)
{ {
...@@ -292,7 +291,7 @@ WebInspector.TimelineModelImpl.InterRecordBindings.prototype = { ...@@ -292,7 +291,7 @@ WebInspector.TimelineModelImpl.InterRecordBindings.prototype = {
/** /**
* @constructor * @constructor
* @implements {WebInspector.TimelineModel.Record} * @implements {WebInspector.TimelineModel.Record}
* @param {!WebInspector.TimelineModel} model * @param {!WebInspector.TimelineModelImpl} model
* @param {!TimelineAgent.TimelineEvent} timelineEvent * @param {!TimelineAgent.TimelineEvent} timelineEvent
* @param {?WebInspector.TimelineModel.Record} parentRecord * @param {?WebInspector.TimelineModel.Record} parentRecord
*/ */
......
...@@ -129,8 +129,8 @@ WebInspector.TimelineView.prototype = { ...@@ -129,8 +129,8 @@ WebInspector.TimelineView.prototype = {
for (var i = 0; i < eventDividerRecords.length; ++i) { for (var i = 0; i < eventDividerRecords.length; ++i) {
var record = eventDividerRecords[i]; var record = eventDividerRecords[i];
var positions = this._calculator.computeBarGraphWindowPosition(record); var position = this._calculator.computePosition(record.startTime());
var dividerPosition = Math.round(positions.left); var dividerPosition = Math.round(position);
if (dividerPosition < 0 || dividerPosition >= clientWidth || dividers[dividerPosition]) if (dividerPosition < 0 || dividerPosition >= clientWidth || dividers[dividerPosition])
continue; continue;
var divider = WebInspector.TimelineUIUtils.createEventDivider(record.type(), WebInspector.TimelineUIUtils.recordTitle(record, this._model)); var divider = WebInspector.TimelineUIUtils.createEventDivider(record.type(), WebInspector.TimelineUIUtils.recordTitle(record, this._model));
...@@ -531,8 +531,8 @@ WebInspector.TimelineView.prototype = { ...@@ -531,8 +531,8 @@ WebInspector.TimelineView.prototype = {
this._automaticallySizeWindow = false; this._automaticallySizeWindow = false;
this._clearSelection(); this._clearSelection();
// If we're at the top, always use real timeline start as a left window bound so that expansion arrow padding logic works. // If we're at the top, always use real timeline start as a left window bound so that expansion arrow padding logic works.
var windowStartTime = startIndex ? recordsInWindow[startIndex].record().startTime() : this._model.minimumRecordTime(); var windowStartTime = startIndex ? recordsInWindow[startIndex].startTime() : this._model.minimumRecordTime();
var windowEndTime = recordsInWindow[Math.max(0, lastVisibleLine - 1)].record().endTime(); var windowEndTime = recordsInWindow[Math.max(0, lastVisibleLine - 1)].endTime();
this._delegate.requestWindowTimes(windowStartTime, windowEndTime); this._delegate.requestWindowTimes(windowStartTime, windowEndTime);
recordsInWindow = this._presentationModel.filteredRecords(); recordsInWindow = this._presentationModel.filteredRecords();
endIndex = Math.min(recordsInWindow.length, lastVisibleLine); endIndex = Math.min(recordsInWindow.length, lastVisibleLine);
...@@ -566,7 +566,7 @@ WebInspector.TimelineView.prototype = { ...@@ -566,7 +566,7 @@ WebInspector.TimelineView.prototype = {
var lastChildIndex = i + record.visibleChildrenCount(); var lastChildIndex = i + record.visibleChildrenCount();
if (lastChildIndex >= startIndex && lastChildIndex < endIndex) { if (lastChildIndex >= startIndex && lastChildIndex < endIndex) {
var expandElement = new WebInspector.TimelineExpandableElement(this._expandElements); var expandElement = new WebInspector.TimelineExpandableElement(this._expandElements);
var positions = this._calculator.computeBarGraphWindowPosition(record.record()); var positions = this._calculator.computeBarGraphWindowPosition(record);
expandElement._update(record, i, positions.left - this._expandOffset, positions.width); expandElement._update(record, i, positions.left - this._expandOffset, positions.width);
} }
} else { } else {
...@@ -824,7 +824,10 @@ WebInspector.TimelineView.prototype = { ...@@ -824,7 +824,10 @@ WebInspector.TimelineView.prototype = {
{ {
if (!rowElement || !rowElement.row) if (!rowElement || !rowElement.row)
return false; return false;
var record = rowElement.row._record.record(); var presentationRecord = rowElement.row._record;
if (presentationRecord.collapsed())
return false;
var record = presentationRecord.record();
if (this._highlightedQuadRecord === record) if (this._highlightedQuadRecord === record)
return true; return true;
this._highlightedQuadRecord = record; this._highlightedQuadRecord = record;
...@@ -920,7 +923,7 @@ WebInspector.TimelineCalculator.prototype = { ...@@ -920,7 +923,7 @@ WebInspector.TimelineCalculator.prototype = {
}, },
/** /**
* @param {!WebInspector.TimelineModel.Record} record * @param {!WebInspector.TimelinePresentationModel.Record} record
* @return {!{start: number, end: number, cpuWidth: number}} * @return {!{start: number, end: number, cpuWidth: number}}
*/ */
computeBarGraphPercentages: function(record) computeBarGraphPercentages: function(record)
...@@ -932,7 +935,7 @@ WebInspector.TimelineCalculator.prototype = { ...@@ -932,7 +935,7 @@ WebInspector.TimelineCalculator.prototype = {
}, },
/** /**
* @param {!WebInspector.TimelineModel.Record} record * @param {!WebInspector.TimelinePresentationModel.Record} record
* @return {!{left: number, width: number, cpuWidth: number}} * @return {!{left: number, width: number, cpuWidth: number}}
*/ */
computeBarGraphWindowPosition: function(record) computeBarGraphWindowPosition: function(record)
...@@ -1193,7 +1196,7 @@ WebInspector.TimelineRecordGraphRow.prototype = { ...@@ -1193,7 +1196,7 @@ WebInspector.TimelineRecordGraphRow.prototype = {
if (record.thread()) if (record.thread())
this.element.classList.add("background"); this.element.classList.add("background");
var barPosition = calculator.computeBarGraphWindowPosition(record); var barPosition = calculator.computeBarGraphWindowPosition(presentationRecord);
this._barElement.style.left = barPosition.left + "px"; this._barElement.style.left = barPosition.left + "px";
this._barElement.style.width = barPosition.width + "px"; this._barElement.style.width = barPosition.width + "px";
this._barCpuElement.style.left = barPosition.left + "px"; this._barCpuElement.style.left = barPosition.left + "px";
......
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