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

Side by Side Diff: Source/devtools/front_end/timeline/TracingModel.js

Issue 322763002: Timeline: fix trace event nesting computation after r175746 (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: review comments addressed 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2014 The Chromium Authors. All rights reserved. 2 * Copyright 2014 The Chromium Authors. All rights reserved.
3 * Use of this source code is governed by a BSD-style license that can be 3 * Use of this source code is governed by a BSD-style license that can be
4 * found in the LICENSE file. 4 * found in the LICENSE file.
5 */ 5 */
6 6
7 /** 7 /**
8 * @constructor 8 * @constructor
9 * @extends {WebInspector.TargetAwareObject} 9 * @extends {WebInspector.TargetAwareObject}
10 */ 10 */
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 */ 256 */
257 WebInspector.TracingModel.Event = function(payload, level, thread) 257 WebInspector.TracingModel.Event = function(payload, level, thread)
258 { 258 {
259 this.name = payload.name; 259 this.name = payload.name;
260 this.category = payload.cat; 260 this.category = payload.cat;
261 this.startTime = payload.ts / 1000; 261 this.startTime = payload.ts / 1000;
262 this.args = payload.args; 262 this.args = payload.args;
263 this.phase = payload.ph; 263 this.phase = payload.ph;
264 this.level = level; 264 this.level = level;
265 265
266 if (payload.dur)
267 this._setEndTime((payload.ts + payload.dur) / 1000);
268
266 if (payload.id) 269 if (payload.id)
267 this.id = payload.id; 270 this.id = payload.id;
268 271
269 this.thread = thread; 272 this.thread = thread;
270 273
271 /** @type {?string} */ 274 /** @type {?string} */
272 this.warning = null; 275 this.warning = null;
273 /** @type {?WebInspector.TracingModel.Event} */ 276 /** @type {?WebInspector.TracingModel.Event} */
274 this.initiator = null; 277 this.initiator = null;
275 /** @type {?Array.<!ConsoleAgent.CallFrame>} */ 278 /** @type {?Array.<!ConsoleAgent.CallFrame>} */
276 this.stackTrace = null; 279 this.stackTrace = null;
277 /** @type {?Element} */ 280 /** @type {?Element} */
278 this.previewElement = null; 281 this.previewElement = null;
279 /** @type {?string} */ 282 /** @type {?string} */
280 this.imageURL = null; 283 this.imageURL = null;
281 /** @type {number} */ 284 /** @type {number} */
282 this.backendNodeId = 0; 285 this.backendNodeId = 0;
283 286
284 /** @type {number} */ 287 /** @type {number} */
285 this.selfTime = 0; 288 this.selfTime = 0;
286 } 289 }
287 290
288 WebInspector.TracingModel.Event.prototype = { 291 WebInspector.TracingModel.Event.prototype = {
289 /** 292 /**
290 * @param {number} duration 293 * @param {number} endTime
291 */ 294 */
292 _setDuration: function(duration) 295 _setEndTime: function(endTime)
293 { 296 {
294 this.endTime = this.startTime + duration; 297 if (endTime < this.startTime) {
295 this.duration = duration; 298 console.assert(false, "Event out of order: " + this.name);
299 return;
300 }
301 this.endTime = endTime;
302 this.duration = endTime - this.startTime;
296 }, 303 },
297 304
298 /** 305 /**
299 * @param {!WebInspector.TracingModel.EventPayload} payload 306 * @param {!WebInspector.TracingModel.EventPayload} payload
300 */ 307 */
301 _complete: function(payload) 308 _complete: function(payload)
302 { 309 {
303 if (this.name !== payload.name) { 310 if (this.name !== payload.name) {
304 console.assert(false, "Open/close event mismatch: " + this.name + " vs. " + payload.name); 311 console.assert(false, "Open/close event mismatch: " + this.name + " vs. " + payload.name);
305 return; 312 return;
306 } 313 }
307 if (payload.args) { 314 if (payload.args) {
308 for (var name in payload.args) { 315 for (var name in payload.args) {
309 if (name in this.args) 316 if (name in this.args)
310 console.error("Same argument name (" + name + ") is used fo r begin and end phases of " + this.name); 317 console.error("Same argument name (" + name + ") is used fo r begin and end phases of " + this.name);
311 this.args[name] = payload.args[name]; 318 this.args[name] = payload.args[name];
312 } 319 }
313 } 320 }
314 var duration = payload.ts / 1000 - this.startTime; 321 this._setEndTime(payload.ts / 1000);
315 if (duration < 0) {
316 console.assert(false, "Event out of order: " + this.name);
317 return;
318 }
319 this._setDuration(duration);
320 } 322 }
321 } 323 }
322 324
323 /** 325 /**
324 * @param {!WebInspector.TracingModel.Event} a 326 * @param {!WebInspector.TracingModel.Event} a
325 * @param {!WebInspector.TracingModel.Event} b 327 * @param {!WebInspector.TracingModel.Event} b
326 * @return {number} 328 * @return {number}
327 */ 329 */
328 WebInspector.TracingModel.Event.compareStartTime = function (a, b) 330 WebInspector.TracingModel.Event.compareStartTime = function (a, b)
329 { 331 {
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
465 this._maxStackDepth = 0; 467 this._maxStackDepth = 0;
466 } 468 }
467 469
468 WebInspector.TracingModel.Thread.prototype = { 470 WebInspector.TracingModel.Thread.prototype = {
469 /** 471 /**
470 * @param {!WebInspector.TracingModel.EventPayload} payload 472 * @param {!WebInspector.TracingModel.EventPayload} payload
471 * @return {?WebInspector.TracingModel.Event} event 473 * @return {?WebInspector.TracingModel.Event} event
472 */ 474 */
473 addEvent: function(payload) 475 addEvent: function(payload)
474 { 476 {
475 for (var top = this._stack.peekLast(); top && top.endTime && top.endTime <= payload.ts;) { 477 for (var top = this._stack.peekLast(); top && top.endTime && top.endTime <= payload.ts / 1000;) {
476 this._stack.pop(); 478 this._stack.pop();
477 top = this._stack.peekLast(); 479 top = this._stack.peekLast();
478 } 480 }
479 if (payload.ph === WebInspector.TracingModel.Phase.End) { 481 if (payload.ph === WebInspector.TracingModel.Phase.End) {
480 var openEvent = this._stack.pop(); 482 var openEvent = this._stack.pop();
481 // Quietly ignore unbalanced close events, they're legit (we could h ave missed start one). 483 // Quietly ignore unbalanced close events, they're legit (we could h ave missed start one).
482 if (openEvent) 484 if (openEvent)
483 openEvent._complete(payload); 485 openEvent._complete(payload);
484 return null; 486 return null;
485 } 487 }
486 488
487 var event = new WebInspector.TracingModel.Event(payload, this._stack.len gth, this); 489 var event = new WebInspector.TracingModel.Event(payload, this._stack.len gth, this);
488 if (payload.ph === WebInspector.TracingModel.Phase.Begin || payload.ph = == WebInspector.TracingModel.Phase.Complete) { 490 if (payload.ph === WebInspector.TracingModel.Phase.Begin || payload.ph = == WebInspector.TracingModel.Phase.Complete) {
489 if (payload.ph === WebInspector.TracingModel.Phase.Complete)
490 event._setDuration(payload.dur / 1000);
491 this._stack.push(event); 491 this._stack.push(event);
492 if (this._maxStackDepth < this._stack.length) 492 if (this._maxStackDepth < this._stack.length)
493 this._maxStackDepth = this._stack.length; 493 this._maxStackDepth = this._stack.length;
494 } 494 }
495 if (this._events.length && this._events.peekLast().startTime > event.sta rtTime) 495 if (this._events.length && this._events.peekLast().startTime > event.sta rtTime)
496 console.assert(false, "Event is our of order: " + event.name); 496 console.assert(false, "Event is our of order: " + event.name);
497 this._events.push(event); 497 this._events.push(event);
498 return event; 498 return event;
499 }, 499 },
500 500
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
552 dataCollected: function(data) 552 dataCollected: function(data)
553 { 553 {
554 this._tracingModel._eventsCollected(data); 554 this._tracingModel._eventsCollected(data);
555 }, 555 },
556 556
557 tracingComplete: function() 557 tracingComplete: function()
558 { 558 {
559 this._tracingModel._tracingComplete(); 559 this._tracingModel._tracingComplete();
560 } 560 }
561 } 561 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698