OLD | NEW |
---|---|
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 Loading... | |
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.endTime = (payload.ts + payload.dur) / 1000; | |
268 this.duration = payload.dur / 1000; | |
yurys
2014/06/09 11:38:47
I'd probably write it as this.duration = this.endT
| |
269 } | |
270 | |
266 if (payload.id) | 271 if (payload.id) |
267 this.id = payload.id; | 272 this.id = payload.id; |
268 | 273 |
269 this.thread = thread; | 274 this.thread = thread; |
270 | 275 |
271 /** @type {?string} */ | 276 /** @type {?string} */ |
272 this.warning = null; | 277 this.warning = null; |
273 /** @type {?WebInspector.TracingModel.Event} */ | 278 /** @type {?WebInspector.TracingModel.Event} */ |
274 this.initiator = null; | 279 this.initiator = null; |
275 /** @type {?Array.<!ConsoleAgent.CallFrame>} */ | 280 /** @type {?Array.<!ConsoleAgent.CallFrame>} */ |
276 this.stackTrace = null; | 281 this.stackTrace = null; |
277 /** @type {?Element} */ | 282 /** @type {?Element} */ |
278 this.previewElement = null; | 283 this.previewElement = null; |
279 /** @type {?string} */ | 284 /** @type {?string} */ |
280 this.imageURL = null; | 285 this.imageURL = null; |
281 /** @type {number} */ | 286 /** @type {number} */ |
282 this.backendNodeId = 0; | 287 this.backendNodeId = 0; |
283 | 288 |
284 /** @type {number} */ | 289 /** @type {number} */ |
285 this.selfTime = 0; | 290 this.selfTime = 0; |
286 } | 291 } |
287 | 292 |
288 WebInspector.TracingModel.Event.prototype = { | 293 WebInspector.TracingModel.Event.prototype = { |
289 /** | 294 /** |
290 * @param {number} duration | |
291 */ | |
292 _setDuration: function(duration) | |
293 { | |
294 this.endTime = this.startTime + duration; | |
295 this.duration = duration; | |
296 }, | |
297 | |
298 /** | |
299 * @param {!WebInspector.TracingModel.EventPayload} payload | 295 * @param {!WebInspector.TracingModel.EventPayload} payload |
300 */ | 296 */ |
301 _complete: function(payload) | 297 _complete: function(payload) |
302 { | 298 { |
303 if (this.name !== payload.name) { | 299 if (this.name !== payload.name) { |
304 console.assert(false, "Open/close event mismatch: " + this.name + " vs. " + payload.name); | 300 console.assert(false, "Open/close event mismatch: " + this.name + " vs. " + payload.name); |
305 return; | 301 return; |
306 } | 302 } |
307 if (payload.args) { | 303 if (payload.args) { |
308 for (var name in payload.args) { | 304 for (var name in payload.args) { |
309 if (name in this.args) | 305 if (name in this.args) |
310 console.error("Same argument name (" + name + ") is used fo r begin and end phases of " + this.name); | 306 console.error("Same argument name (" + name + ") is used fo r begin and end phases of " + this.name); |
311 this.args[name] = payload.args[name]; | 307 this.args[name] = payload.args[name]; |
312 } | 308 } |
313 } | 309 } |
314 var duration = payload.ts / 1000 - this.startTime; | 310 var timestamp = payload.ts / 1000; |
315 if (duration < 0) { | 311 if (timestamp < this.startTime) { |
316 console.assert(false, "Event out of order: " + this.name); | 312 console.assert(false, "Event out of order: " + this.name); |
317 return; | 313 return; |
318 } | 314 } |
319 this._setDuration(duration); | 315 this.endTime = timestamp; |
316 this.duration = this.endTime - this.startTime; | |
320 } | 317 } |
321 } | 318 } |
322 | 319 |
323 /** | 320 /** |
324 * @param {!WebInspector.TracingModel.Event} a | 321 * @param {!WebInspector.TracingModel.Event} a |
325 * @param {!WebInspector.TracingModel.Event} b | 322 * @param {!WebInspector.TracingModel.Event} b |
326 * @return {number} | 323 * @return {number} |
327 */ | 324 */ |
328 WebInspector.TracingModel.Event.compareStartTime = function (a, b) | 325 WebInspector.TracingModel.Event.compareStartTime = function (a, b) |
329 { | 326 { |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
465 this._maxStackDepth = 0; | 462 this._maxStackDepth = 0; |
466 } | 463 } |
467 | 464 |
468 WebInspector.TracingModel.Thread.prototype = { | 465 WebInspector.TracingModel.Thread.prototype = { |
469 /** | 466 /** |
470 * @param {!WebInspector.TracingModel.EventPayload} payload | 467 * @param {!WebInspector.TracingModel.EventPayload} payload |
471 * @return {?WebInspector.TracingModel.Event} event | 468 * @return {?WebInspector.TracingModel.Event} event |
472 */ | 469 */ |
473 addEvent: function(payload) | 470 addEvent: function(payload) |
474 { | 471 { |
475 for (var top = this._stack.peekLast(); top && top.endTime && top.endTime <= payload.ts;) { | 472 for (var top = this._stack.peekLast(); top && top.endTime && top.endTime <= payload.ts / 1000;) { |
476 this._stack.pop(); | 473 this._stack.pop(); |
477 top = this._stack.peekLast(); | 474 top = this._stack.peekLast(); |
478 } | 475 } |
479 if (payload.ph === WebInspector.TracingModel.Phase.End) { | 476 if (payload.ph === WebInspector.TracingModel.Phase.End) { |
480 var openEvent = this._stack.pop(); | 477 var openEvent = this._stack.pop(); |
481 // Quietly ignore unbalanced close events, they're legit (we could h ave missed start one). | 478 // Quietly ignore unbalanced close events, they're legit (we could h ave missed start one). |
482 if (openEvent) | 479 if (openEvent) |
483 openEvent._complete(payload); | 480 openEvent._complete(payload); |
484 return null; | 481 return null; |
485 } | 482 } |
486 | 483 |
487 var event = new WebInspector.TracingModel.Event(payload, this._stack.len gth, this); | 484 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) { | 485 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); | 486 this._stack.push(event); |
492 if (this._maxStackDepth < this._stack.length) | 487 if (this._maxStackDepth < this._stack.length) |
493 this._maxStackDepth = this._stack.length; | 488 this._maxStackDepth = this._stack.length; |
494 } | 489 } |
495 if (this._events.length && this._events.peekLast().startTime > event.sta rtTime) | 490 if (this._events.length && this._events.peekLast().startTime > event.sta rtTime) |
496 console.assert(false, "Event is our of order: " + event.name); | 491 console.assert(false, "Event is our of order: " + event.name); |
497 this._events.push(event); | 492 this._events.push(event); |
498 return event; | 493 return event; |
499 }, | 494 }, |
500 | 495 |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
552 dataCollected: function(data) | 547 dataCollected: function(data) |
553 { | 548 { |
554 this._tracingModel._eventsCollected(data); | 549 this._tracingModel._eventsCollected(data); |
555 }, | 550 }, |
556 | 551 |
557 tracingComplete: function() | 552 tracingComplete: function() |
558 { | 553 { |
559 this._tracingModel._tracingComplete(); | 554 this._tracingModel._tracingComplete(); |
560 } | 555 } |
561 } | 556 } |
OLD | NEW |