| Index: tracing/tracing/model/object_instance.html
|
| diff --git a/tracing/tracing/model/object_instance.html b/tracing/tracing/model/object_instance.html
|
| index b4f11217c0230fc2cd18f723a097b26954431610..8e9bdcaa7567e36f0ee06631aecdcfe20026aa3d 100644
|
| --- a/tracing/tracing/model/object_instance.html
|
| +++ b/tracing/tracing/model/object_instance.html
|
| @@ -55,17 +55,20 @@ tr.exportTo('tr.model', function() {
|
| },
|
|
|
| addSnapshot: function(ts, args, opt_name, opt_baseTypeName) {
|
| - if (ts < this.creationTs)
|
| + if (ts < this.creationTs) {
|
| throw new Error('Snapshots must be >= instance.creationTs');
|
| - if (ts >= this.deletionTs)
|
| + }
|
| + if (ts >= this.deletionTs) {
|
| throw new Error('Snapshots cannot be added after ' +
|
| 'an objects deletion timestamp.');
|
| + }
|
|
|
| var lastSnapshot;
|
| if (this.snapshots.length > 0) {
|
| lastSnapshot = this.snapshots[this.snapshots.length - 1];
|
| - if (lastSnapshot.ts === ts)
|
| + if (lastSnapshot.ts === ts) {
|
| throw new Error('Snapshots already exists at this time!');
|
| + }
|
| if (ts < lastSnapshot.ts) {
|
| throw new Error(
|
| 'Snapshots must be added in increasing timestamp order');
|
| @@ -75,10 +78,12 @@ tr.exportTo('tr.model', function() {
|
| // Update baseTypeName if needed.
|
| if (opt_name &&
|
| (this.name !== opt_name)) {
|
| - if (!opt_baseTypeName)
|
| + if (!opt_baseTypeName) {
|
| throw new Error('Must provide base type name for name update');
|
| - if (this.baseTypeName !== opt_baseTypeName)
|
| + }
|
| + if (this.baseTypeName !== opt_baseTypeName) {
|
| throw new Error('Cannot update type name: base types dont match');
|
| + }
|
| this.name = opt_name;
|
| }
|
|
|
| @@ -94,10 +99,11 @@ tr.exportTo('tr.model', function() {
|
| var lastSnapshot;
|
| if (this.snapshots.length > 0) {
|
| lastSnapshot = this.snapshots[this.snapshots.length - 1];
|
| - if (lastSnapshot.ts > ts)
|
| + if (lastSnapshot.ts > ts) {
|
| throw new Error(
|
| 'Instance cannot be deleted at ts=' +
|
| ts + '. A snapshot exists that is older.');
|
| + }
|
| }
|
| this.deletionTs = ts;
|
| this.deletionTsWasExplicit = true;
|
| @@ -107,43 +113,50 @@ tr.exportTo('tr.model', function() {
|
| * See ObjectSnapshot constructor notes on object initialization.
|
| */
|
| preInitialize: function() {
|
| - for (var i = 0; i < this.snapshots.length; i++)
|
| + for (var i = 0; i < this.snapshots.length; i++) {
|
| this.snapshots[i].preInitialize();
|
| + }
|
| },
|
|
|
| /**
|
| * See ObjectSnapshot constructor notes on object initialization.
|
| */
|
| initialize: function() {
|
| - for (var i = 0; i < this.snapshots.length; i++)
|
| + for (var i = 0; i < this.snapshots.length; i++) {
|
| this.snapshots[i].initialize();
|
| + }
|
| },
|
|
|
| isAliveAt: function(ts) {
|
| - if (ts < this.creationTs && this.creationTsWasExplicit)
|
| + if (ts < this.creationTs && this.creationTsWasExplicit) {
|
| return false;
|
| - if (ts > this.deletionTs)
|
| + }
|
| + if (ts > this.deletionTs) {
|
| return false;
|
| + }
|
|
|
| return true;
|
| },
|
|
|
| getSnapshotAt: function(ts) {
|
| if (ts < this.creationTs) {
|
| - if (this.creationTsWasExplicit)
|
| + if (this.creationTsWasExplicit) {
|
| throw new Error('ts must be within lifetime of this instance');
|
| + }
|
| return this.snapshots[0];
|
| }
|
| - if (ts > this.deletionTs)
|
| + if (ts > this.deletionTs) {
|
| throw new Error('ts must be within lifetime of this instance');
|
| + }
|
|
|
| var snapshots = this.snapshots;
|
| var i = tr.b.math.findIndexInSortedIntervals(
|
| snapshots,
|
| function(snapshot) { return snapshot.ts; },
|
| function(snapshot, i) {
|
| - if (i === snapshots.length - 1)
|
| + if (i === snapshots.length - 1) {
|
| return snapshots[i].objectInstance.deletionTs;
|
| + }
|
| return snapshots[i + 1].ts - snapshots[i].ts;
|
| },
|
| ts);
|
| @@ -155,24 +168,27 @@ tr.exportTo('tr.model', function() {
|
| // confusing object references showing up in the traces.
|
| return this.snapshots[0];
|
| }
|
| - if (i >= this.snapshots.length)
|
| + if (i >= this.snapshots.length) {
|
| return this.snapshots[this.snapshots.length - 1];
|
| + }
|
| return this.snapshots[i];
|
| },
|
|
|
| updateBounds: function() {
|
| this.bounds.reset();
|
| this.bounds.addValue(this.creationTs);
|
| - if (this.deletionTs !== Number.MAX_VALUE)
|
| + if (this.deletionTs !== Number.MAX_VALUE) {
|
| this.bounds.addValue(this.deletionTs);
|
| - else if (this.snapshots.length > 0)
|
| + } else if (this.snapshots.length > 0) {
|
| this.bounds.addValue(this.snapshots[this.snapshots.length - 1].ts);
|
| + }
|
| },
|
|
|
| shiftTimestampsForward: function(amount) {
|
| this.creationTs += amount;
|
| - if (this.deletionTs !== Number.MAX_VALUE)
|
| + if (this.deletionTs !== Number.MAX_VALUE) {
|
| this.deletionTs += amount;
|
| + }
|
| this.snapshots.forEach(function(snapshot) {
|
| snapshot.ts += amount;
|
| });
|
|
|