Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(11)

Unified Diff: Source/devtools/front_end/timeline/TimelinePresentationModel.js

Issue 337023004: Don't create TimelineModel.RecordImpl in TimelinePresentationModel.js (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/devtools/front_end/timeline/TimelinePresentationModel.js
diff --git a/Source/devtools/front_end/timeline/TimelinePresentationModel.js b/Source/devtools/front_end/timeline/TimelinePresentationModel.js
index 46b5e70d1c007bc4bdac5bcfec942eb77d26fad1..6c63c3b329355afb11e52b14af72d4b669dc9b63 100644
--- a/Source/devtools/front_end/timeline/TimelinePresentationModel.js
+++ b/Source/devtools/front_end/timeline/TimelinePresentationModel.js
@@ -83,9 +83,7 @@ WebInspector.TimelinePresentationModel.prototype = {
reset: function()
{
this._recordToPresentationRecord.clear();
- var rootPayload = { type: WebInspector.TimelineModel.RecordType.Root };
- var rootRecord = new WebInspector.TimelineModel.RecordImpl(this._model, /** @type {!TimelineAgent.TimelineEvent} */ (rootPayload), null);
- this._rootRecord = new WebInspector.TimelinePresentationModel.Record(rootRecord, null);
+ this._rootRecord = new WebInspector.TimelinePresentationModel.RootRecord();
/** @type {!Object.<string, !WebInspector.TimelinePresentationModel.Record>} */
this._coalescingBuckets = {};
},
@@ -120,7 +118,7 @@ WebInspector.TimelinePresentationModel.prototype = {
if (coalescedRecord)
parentRecord = coalescedRecord;
- var formattedRecord = new WebInspector.TimelinePresentationModel.Record(record, parentRecord);
+ var formattedRecord = new WebInspector.TimelinePresentationModel.ActualRecord(record, parentRecord);
this._recordToPresentationRecord.put(record, formattedRecord);
formattedRecord._collapsed = parentRecord === this._rootRecord;
@@ -130,7 +128,7 @@ WebInspector.TimelinePresentationModel.prototype = {
for (var i = 0; record.children() && i < record.children().length; ++i)
this._innerAddRecord(formattedRecord, record.children()[i]);
- if (parentRecord._coalesced)
+ if (parentRecord.coalesced())
this._updateCoalescingParent(formattedRecord);
},
@@ -145,7 +143,7 @@ WebInspector.TimelinePresentationModel.prototype = {
const coalescingThresholdMillis = 5;
var lastRecord = bucket ? this._coalescingBuckets[bucket] : newParent._presentationChildren.peekLast();
- if (lastRecord && lastRecord._coalesced)
+ if (lastRecord && lastRecord.coalesced())
lastRecord = lastRecord._presentationChildren.peekLast();
var startTime = record.startTime();
var endTime = record.endTime();
@@ -159,7 +157,7 @@ WebInspector.TimelinePresentationModel.prototype = {
return null;
if (endTime + coalescingThresholdMillis < lastRecord.record().startTime())
return null;
- if (lastRecord.presentationParent()._coalesced)
+ if (lastRecord.presentationParent().coalesced())
return lastRecord.presentationParent();
return this._replaceWithCoalescedRecord(lastRecord);
},
@@ -171,21 +169,9 @@ WebInspector.TimelinePresentationModel.prototype = {
_replaceWithCoalescedRecord: function(presentationRecord)
{
var record = presentationRecord.record();
- var rawRecord = {
- type: record.type(),
- startTime: record.startTime(),
- data: { }
- };
- if (record.thread())
- rawRecord.thread = "aggregated";
- if (record.type() === WebInspector.TimelineModel.RecordType.TimeStamp)
- rawRecord.data["message"] = record.data().message;
-
- var modelRecord = new WebInspector.TimelineModel.RecordImpl(this._model, /** @type {!TimelineAgent.TimelineEvent} */ (rawRecord), null);
- var coalescedRecord = new WebInspector.TimelinePresentationModel.Record(modelRecord, null);
var parent = presentationRecord._presentationParent;
+ var coalescedRecord = new WebInspector.TimelinePresentationModel.CoalescedRecord(record);
- coalescedRecord._coalesced = true;
coalescedRecord._collapsed = true;
coalescedRecord._presentationChildren.push(presentationRecord);
presentationRecord._presentationParent = coalescedRecord;
@@ -194,7 +180,7 @@ WebInspector.TimelinePresentationModel.prototype = {
coalescedRecord._presentationParent = parent;
parent._presentationChildren[parent._presentationChildren.indexOf(presentationRecord)] = coalescedRecord;
- WebInspector.TimelineUIUtils.aggregateTimeByCategory(modelRecord.aggregatedStats(), record.aggregatedStats());
+ WebInspector.TimelineUIUtils.aggregateTimeByCategory(coalescedRecord.presentationAggregatedStats(), presentationRecord.presentationAggregatedStats());
return coalescedRecord;
},
@@ -204,11 +190,11 @@ WebInspector.TimelinePresentationModel.prototype = {
*/
_updateCoalescingParent: function(presentationRecord)
{
- var record = presentationRecord.record();
- var parentRecord = presentationRecord._presentationParent.record();
- WebInspector.TimelineUIUtils.aggregateTimeByCategory(parentRecord.aggregatedStats(), record.aggregatedStats());
+ var record = presentationRecord;
caseq 2014/06/16 12:26:33 nit: remove this and inline presentationRecord in
yurys 2014/06/16 12:32:37 Done.
+ var parentRecord = presentationRecord._presentationParent;
+ WebInspector.TimelineUIUtils.aggregateTimeByCategory(parentRecord.presentationAggregatedStats(), record.presentationAggregatedStats());
if (parentRecord.endTime() < record.endTime())
- parentRecord.setEndTime(record.endTime());
+ parentRecord._endTime = record.endTime();
},
/**
@@ -257,9 +243,8 @@ WebInspector.TimelinePresentationModel.prototype = {
if (records && entry.index < records.length) {
var record = records[entry.index];
++entry.index;
- var rawRecord = record.record();
- if (rawRecord.startTime() < this._windowEndTime && rawRecord.endTime() > this._windowStartTime) {
- if (this._model.isVisible(rawRecord)) {
+ if (record.startTime() < this._windowEndTime && record.endTime() > this._windowStartTime) {
+ if (this._model.isVisible(record.record())) {
record._presentationParent._expandable = true;
if (this._textFilter)
revealRecordsInStack();
@@ -294,12 +279,10 @@ WebInspector.TimelinePresentationModel.prototype = {
/**
* @constructor
- * @param {!WebInspector.TimelineModel.Record} record
* @param {?WebInspector.TimelinePresentationModel.Record} parentRecord
*/
-WebInspector.TimelinePresentationModel.Record = function(record, parentRecord)
+WebInspector.TimelinePresentationModel.Record = function(parentRecord)
{
- this._record = record;
/**
* @type {!Array.<!WebInspector.TimelinePresentationModel.Record>}
*/
@@ -309,20 +292,47 @@ WebInspector.TimelinePresentationModel.Record = function(record, parentRecord)
this._presentationParent = parentRecord;
parentRecord._presentationChildren.push(this);
}
-
- if (this.hasWarnings()) {
- for (var parent = this._presentationParent; parent && !parent._childHasWarnings; parent = parent._presentationParent)
- parent._childHasWarnings = true;
- }
}
WebInspector.TimelinePresentationModel.Record.prototype = {
/**
+ * @return {number}
+ */
+ startTime: function()
+ {
+ throw new Error("Not implemented.");
+ },
+
+ /**
+ * @return {number}
+ */
+ endTime: function()
+ {
+ throw new Error("Not implemented.");
+ },
+
+ /**
+ * @return {number}
+ */
+ selfTime: function()
+ {
+ throw new Error("Not implemented.");
+ },
+
+ /**
* @return {!WebInspector.TimelineModel.Record}
*/
record: function()
{
- return this._record;
+ throw new Error("Not implemented.");
+ },
+
+ /**
+ * @return {!Object.<string, number>}
+ */
+ presentationAggregatedStats: function()
+ {
+ throw new Error("Not implemented.");
},
/**
@@ -338,7 +348,7 @@ WebInspector.TimelinePresentationModel.Record.prototype = {
*/
coalesced: function()
{
- return this._coalesced;
+ return false;
},
/**
@@ -387,7 +397,7 @@ WebInspector.TimelinePresentationModel.Record.prototype = {
*/
hasWarnings: function()
{
- return !!this._record.warnings();
+ return false;
},
/**
@@ -428,5 +438,225 @@ WebInspector.TimelinePresentationModel.Record.prototype = {
setGraphRow: function(graphRow)
{
this._graphRow = graphRow;
+ },
+
+ /**
+ * @return {string}
+ */
+ toString: function()
+ {
+ return "Record";
+ },
+
+ /**
+ * @param {string} prefix
+ * @return {string}
+ */
+ dump: function(prefix)
caseq 2014/06/16 12:26:33 How is this used?
yurys 2014/06/16 12:32:37 I used it for debugging. Removed.
+ {
+ prefix = prefix || " ";
+ var result = prefix + this.toString();
+ result += "\n";
+ prefix += " ";
+ for (var i = 0; i < this.presentationChildren().length; i++) {
+ result += this.presentationChildren()[i].dump(prefix);
+ }
+ return result;
+ }
+}
+
+/**
+ * @constructor
+ * @extends {WebInspector.TimelinePresentationModel.Record}
+ * @param {!WebInspector.TimelineModel.Record} record
+ * @param {?WebInspector.TimelinePresentationModel.Record} parentRecord
+ */
+WebInspector.TimelinePresentationModel.ActualRecord = function(record, parentRecord)
+{
+ WebInspector.TimelinePresentationModel.Record.call(this, parentRecord);
+ this._record = record;
+
+ if (this.hasWarnings()) {
+ for (var parent = this._presentationParent; parent && !parent._childHasWarnings; parent = parent._presentationParent)
+ parent._childHasWarnings = true;
}
}
+
+WebInspector.TimelinePresentationModel.ActualRecord.prototype = {
+ /**
+ * @return {number}
+ */
+ startTime: function()
+ {
+ return this._record.startTime();
+ },
+
+ /**
+ * @return {number}
+ */
+ endTime: function()
+ {
+ return this._record.endTime();
+ },
+
+ /**
+ * @return {number}
+ */
+ selfTime: function()
+ {
+ return this._record.selfTime();
+ },
+
+ /**
+ * @return {!WebInspector.TimelineModel.Record}
+ */
+ record: function()
+ {
+ return this._record;
+ },
+
+ /**
+ * @return {!Object.<string, number>}
+ */
+ presentationAggregatedStats: function()
+ {
+ return this._record.aggregatedStats();
+ },
+
+ /**
+ * @return {boolean}
+ */
+ hasWarnings: function()
+ {
+ return !!this._record.warnings();
+ },
+
+ /**
+ * @return {string}
+ */
+ toString: function()
caseq 2014/06/16 12:26:33 is thus used?
yurys 2014/06/16 12:32:37 Not anymore. Removed.
+ {
+ return "ActualRecord: " + this._record.type();
+ },
+
+ __proto__: WebInspector.TimelinePresentationModel.Record.prototype
+}
+
+/**
+ * @constructor
+ * @extends {WebInspector.TimelinePresentationModel.Record}
+ * @param {!WebInspector.TimelineModel.Record} record
+ */
+WebInspector.TimelinePresentationModel.CoalescedRecord = function(record)
+{
+ WebInspector.TimelinePresentationModel.Record.call(this, null);
+ this._startTime = record.startTime();
+ this._endTime = record.endTime();
+ this._aggregatedStats = {};
+}
+
+WebInspector.TimelinePresentationModel.CoalescedRecord.prototype = {
+ /**
+ * @return {number}
+ */
+ startTime: function()
+ {
+ return this._startTime;
+ },
+
+ /**
+ * @return {number}
+ */
+ endTime: function()
+ {
+ return this._endTime;
+ },
+
+ /**
+ * @return {number}
+ */
+ selfTime: function()
+ {
+ return 0;
+ },
+
+ /**
+ * @return {!WebInspector.TimelineModel.Record}
+ */
+ record: function()
+ {
+ return this._presentationChildren[0].record();
+ },
+
+ /**
+ * @return {!Object.<string, number>}
+ */
+ presentationAggregatedStats: function()
+ {
+ return this._aggregatedStats;
+ },
+
+ /**
+ * @return {boolean}
+ */
+ coalesced: function()
+ {
+ return true;
+ },
+
+ /**
+ * @return {boolean}
+ */
+ hasWarnings: function()
+ {
+ return false;
+ },
+
+ /**
+ * @return {string}
+ */
+ toString: function()
+ {
+ return "CoalescedRecord";
+ },
+
+ __proto__: WebInspector.TimelinePresentationModel.Record.prototype
+}
+
+/**
+ * @constructor
+ * @extends {WebInspector.TimelinePresentationModel.Record}
+ */
+WebInspector.TimelinePresentationModel.RootRecord = function()
+{
+ WebInspector.TimelinePresentationModel.Record.call(this, null);
+ this._aggregatedStats = {};
+}
+
+WebInspector.TimelinePresentationModel.RootRecord.prototype = {
+ /**
+ * @return {!Object.<string, number>}
+ */
+ presentationAggregatedStats: function()
+ {
+ return this._aggregatedStats;
+ },
+
+ /**
+ * @return {boolean}
+ */
+ hasWarnings: function()
+ {
+ return false;
+ },
+
+ /**
+ * @return {string}
+ */
+ toString: function()
+ {
+ return "RootRecord";
+ },
+
+ __proto__: WebInspector.TimelinePresentationModel.Record.prototype
+}
« no previous file with comments | « Source/devtools/front_end/timeline/TimelineModelImpl.js ('k') | Source/devtools/front_end/timeline/TimelineView.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698