| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 } | 223 } |
| 224 | 224 |
| 225 WebInspector.TracingTimelineFrameModel._mainFrameMarkers = [ | 225 WebInspector.TracingTimelineFrameModel._mainFrameMarkers = [ |
| 226 WebInspector.TimelineModel.RecordType.ScheduleStyleRecalculation, | 226 WebInspector.TimelineModel.RecordType.ScheduleStyleRecalculation, |
| 227 WebInspector.TimelineModel.RecordType.InvalidateLayout, | 227 WebInspector.TimelineModel.RecordType.InvalidateLayout, |
| 228 WebInspector.TimelineModel.RecordType.BeginMainThreadFrame, | 228 WebInspector.TimelineModel.RecordType.BeginMainThreadFrame, |
| 229 WebInspector.TimelineModel.RecordType.ScrollLayer | 229 WebInspector.TimelineModel.RecordType.ScrollLayer |
| 230 ]; | 230 ]; |
| 231 | 231 |
| 232 WebInspector.TracingTimelineFrameModel.prototype = { | 232 WebInspector.TracingTimelineFrameModel.prototype = { |
| 233 reset: function() |
| 234 { |
| 235 WebInspector.TimelineFrameModelBase.prototype.reset.call(this); |
| 236 this._target = null; |
| 237 this._sessionId = null; |
| 238 }, |
| 239 |
| 233 /** | 240 /** |
| 241 * @param {?WebInspector.Target} target |
| 234 * @param {!Array.<!WebInspector.TracingModel.Event>} events | 242 * @param {!Array.<!WebInspector.TracingModel.Event>} events |
| 235 * @param {string} sessionId | 243 * @param {string} sessionId |
| 236 */ | 244 */ |
| 237 addTraceEvents: function(events, sessionId) | 245 addTraceEvents: function(target, events, sessionId) |
| 238 { | 246 { |
| 247 this._target = target; |
| 239 this._sessionId = sessionId; | 248 this._sessionId = sessionId; |
| 240 if (!events.length) | 249 if (!events.length) |
| 241 return; | 250 return; |
| 242 if (events[0].startTime < this._minimumRecordTime) | 251 if (events[0].startTime < this._minimumRecordTime) |
| 243 this._minimumRecordTime = events[0].startTime; | 252 this._minimumRecordTime = events[0].startTime; |
| 244 for (var i = 0; i < events.length; ++i) | 253 for (var i = 0; i < events.length; ++i) |
| 245 this._addTraceEvent(events[i]); | 254 this._addTraceEvent(events[i]); |
| 246 }, | 255 }, |
| 247 | 256 |
| 248 /** | 257 /** |
| 249 * @param {!WebInspector.TracingModel.Event} event | 258 * @param {!WebInspector.TracingModel.Event} event |
| 250 */ | 259 */ |
| 251 _addTraceEvent: function(event) | 260 _addTraceEvent: function(event) |
| 252 { | 261 { |
| 253 var eventNames = WebInspector.TimelineModel.RecordType; | 262 var eventNames = WebInspector.TimelineModel.RecordType; |
| 254 | 263 |
| 255 if (event.name === eventNames.SetLayerTreeId) { | 264 if (event.name === eventNames.SetLayerTreeId) { |
| 256 if (this._sessionId === event.args["sessionId"]) | 265 if (this._sessionId === event.args["sessionId"]) |
| 257 this._layerTreeId = event.args["layerTreeId"]; | 266 this._layerTreeId = event.args["layerTreeId"]; |
| 258 return; | 267 } else if (event.name === eventNames.TracingStartedInPage) { |
| 268 this._mainThread = event.thread; |
| 269 } else if (event.phase === WebInspector.TracingModel.Phase.SnapshotObjec
t && event.name === eventNames.LayerTreeHostImplSnapshot && parseInt(event.id, 0
) === this._layerTreeId) { |
| 270 var snapshot = /** @type {!WebInspector.TracingModel.ObjectSnapshot}
*/ (event); |
| 271 this.handleLayerTreeSnapshot(new WebInspector.DeferredTracingLayerTr
ee(snapshot, this._target)); |
| 272 } else if (event.thread === this._mainThread) { |
| 273 this._addMainThreadTraceEvent(event); |
| 274 } else { |
| 275 this._addBackgroundTraceEvent(event); |
| 259 } | 276 } |
| 260 if (event.name === eventNames.TracingStartedInPage) { | |
| 261 this._mainThread = event.thread; | |
| 262 return; | |
| 263 } | |
| 264 if (event.thread === this._mainThread) | |
| 265 this._addMainThreadTraceEvent(event); | |
| 266 else | |
| 267 this._addBackgroundTraceEvent(event); | |
| 268 }, | 277 }, |
| 269 | 278 |
| 270 /** | 279 /** |
| 271 * @param {!WebInspector.TracingModel.Event} event | 280 * @param {!WebInspector.TracingModel.Event} event |
| 272 */ | 281 */ |
| 273 _addBackgroundTraceEvent: function(event) | 282 _addBackgroundTraceEvent: function(event) |
| 274 { | 283 { |
| 275 var eventNames = WebInspector.TimelineModel.RecordType; | 284 var eventNames = WebInspector.TimelineModel.RecordType; |
| 276 if (event.phase === WebInspector.TracingModel.Phase.SnapshotObject && ev
ent.name === eventNames.LayerTreeHostImplSnapshot && parseInt(event.id, 0) === t
his._layerTreeId) { | |
| 277 var snapshot = /** @type {!WebInspector.TracingModel.ObjectSnapshot}
*/ (event); | |
| 278 this.handleLayerTreeSnapshot(new WebInspector.DeferredTracingLayerTr
ee(snapshot)); | |
| 279 return; | |
| 280 } | |
| 281 if (this._lastFrame && event.selfTime) | 285 if (this._lastFrame && event.selfTime) |
| 282 this._lastFrame._addTimeForCategory(WebInspector.TimelineUIUtils.eve
ntStyle(event).category.name, event.selfTime); | 286 this._lastFrame._addTimeForCategory(WebInspector.TimelineUIUtils.eve
ntStyle(event).category.name, event.selfTime); |
| 283 | 287 |
| 284 if (event.args["layerTreeId"] !== this._layerTreeId) | 288 if (event.args["layerTreeId"] !== this._layerTreeId) |
| 285 return; | 289 return; |
| 286 | 290 |
| 287 var timestamp = event.startTime; | 291 var timestamp = event.startTime; |
| 288 if (event.name === eventNames.BeginFrame) | 292 if (event.name === eventNames.BeginFrame) |
| 289 this.handleBeginFrame(timestamp); | 293 this.handleBeginFrame(timestamp); |
| 290 else if (event.name === eventNames.DrawFrame) | 294 else if (event.name === eventNames.DrawFrame) |
| (...skipping 23 matching lines...) Expand all Loading... |
| 314 | 318 |
| 315 var categoryName = WebInspector.TimelineUIUtils.eventStyle(event).ca
tegory.name; | 319 var categoryName = WebInspector.TimelineUIUtils.eventStyle(event).ca
tegory.name; |
| 316 this._lastFrame._addTimeForCategory(categoryName, selfTime); | 320 this._lastFrame._addTimeForCategory(categoryName, selfTime); |
| 317 return; | 321 return; |
| 318 } | 322 } |
| 319 | 323 |
| 320 if (!this._framePendingCommit && WebInspector.TracingTimelineFrameModel.
_mainFrameMarkers.indexOf(event.name) >= 0) | 324 if (!this._framePendingCommit && WebInspector.TracingTimelineFrameModel.
_mainFrameMarkers.indexOf(event.name) >= 0) |
| 321 this._framePendingCommit = new WebInspector.PendingFrame(); | 325 this._framePendingCommit = new WebInspector.PendingFrame(); |
| 322 if (!this._framePendingCommit) | 326 if (!this._framePendingCommit) |
| 323 return; | 327 return; |
| 324 if (event.name === eventNames.Paint && event.args["data"]["layerId"] &&
event.picture) | 328 if (event.name === eventNames.Paint && event.args["data"]["layerId"] &&
event.picture && this._target) |
| 325 this._framePendingCommit.paints.push(new WebInspector.LayerPaintEven
t(event)); | 329 this._framePendingCommit.paints.push(new WebInspector.LayerPaintEven
t(event, this._target)); |
| 326 | 330 |
| 327 if (selfTime) { | 331 if (selfTime) { |
| 328 var categoryName = WebInspector.TimelineUIUtils.eventStyle(event).ca
tegory.name; | 332 var categoryName = WebInspector.TimelineUIUtils.eventStyle(event).ca
tegory.name; |
| 329 this._framePendingCommit.timeByCategory[categoryName] = (this._frame
PendingCommit.timeByCategory[categoryName] || 0) + selfTime; | 333 this._framePendingCommit.timeByCategory[categoryName] = (this._frame
PendingCommit.timeByCategory[categoryName] || 0) + selfTime; |
| 330 } | 334 } |
| 331 if (event.name === eventNames.CompositeLayers && event.args["layerTreeId
"] === this._layerTreeId) | 335 if (event.name === eventNames.CompositeLayers && event.args["layerTreeId
"] === this._layerTreeId) |
| 332 this.handleCompositeLayers(); | 336 this.handleCompositeLayers(); |
| 333 }, | 337 }, |
| 334 | 338 |
| 335 __proto__: WebInspector.TimelineFrameModelBase.prototype | 339 __proto__: WebInspector.TimelineFrameModelBase.prototype |
| 336 } | 340 } |
| 337 | 341 |
| 338 /** | 342 /** |
| 339 * @constructor | 343 * @constructor |
| 340 * @extends {WebInspector.DeferredLayerTree} | 344 * @extends {WebInspector.DeferredLayerTree} |
| 341 * @param {!WebInspector.TracingModel.ObjectSnapshot} snapshot | 345 * @param {!WebInspector.TracingModel.ObjectSnapshot} snapshot |
| 346 * @param {?WebInspector.Target} target |
| 342 */ | 347 */ |
| 343 WebInspector.DeferredTracingLayerTree = function(snapshot) | 348 WebInspector.DeferredTracingLayerTree = function(snapshot, target) |
| 344 { | 349 { |
| 345 WebInspector.DeferredLayerTree.call(this, snapshot.thread.target()); | 350 WebInspector.DeferredLayerTree.call(this, target); |
| 346 this._snapshot = snapshot; | 351 this._snapshot = snapshot; |
| 347 } | 352 } |
| 348 | 353 |
| 349 WebInspector.DeferredTracingLayerTree.prototype = { | 354 WebInspector.DeferredTracingLayerTree.prototype = { |
| 350 /** | 355 /** |
| 351 * @param {function(!WebInspector.LayerTreeBase)} callback | 356 * @param {function(!WebInspector.LayerTreeBase)} callback |
| 352 */ | 357 */ |
| 353 resolve: function(callback) | 358 resolve: function(callback) |
| 354 { | 359 { |
| 355 this._snapshot.requestObject(onGotObject.bind(this)); | 360 this._snapshot.requestObject(onGotObject.bind(this)); |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 420 WebInspector.TimelineFrame = function(startTime, startTimeOffset) | 425 WebInspector.TimelineFrame = function(startTime, startTimeOffset) |
| 421 { | 426 { |
| 422 this.startTime = startTime; | 427 this.startTime = startTime; |
| 423 this.startTimeOffset = startTimeOffset; | 428 this.startTimeOffset = startTimeOffset; |
| 424 this.endTime = this.startTime; | 429 this.endTime = this.startTime; |
| 425 this.duration = 0; | 430 this.duration = 0; |
| 426 this.timeByCategory = {}; | 431 this.timeByCategory = {}; |
| 427 this.cpuTime = 0; | 432 this.cpuTime = 0; |
| 428 /** @type {?WebInspector.DeferredLayerTree} */ | 433 /** @type {?WebInspector.DeferredLayerTree} */ |
| 429 this.layerTree = null; | 434 this.layerTree = null; |
| 430 this.paintTiles = null; | |
| 431 } | 435 } |
| 432 | 436 |
| 433 WebInspector.TimelineFrame.prototype = { | 437 WebInspector.TimelineFrame.prototype = { |
| 434 /** | 438 /** |
| 435 * @param {number} endTime | 439 * @param {number} endTime |
| 436 */ | 440 */ |
| 437 _setEndTime: function(endTime) | 441 _setEndTime: function(endTime) |
| 438 { | 442 { |
| 439 this.endTime = endTime; | 443 this.endTime = endTime; |
| 440 this.duration = this.endTime - this.startTime; | 444 this.duration = this.endTime - this.startTime; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 464 _addTimeForCategory: function(category, time) | 468 _addTimeForCategory: function(category, time) |
| 465 { | 469 { |
| 466 this.timeByCategory[category] = (this.timeByCategory[category] || 0) + t
ime; | 470 this.timeByCategory[category] = (this.timeByCategory[category] || 0) + t
ime; |
| 467 this.cpuTime += time; | 471 this.cpuTime += time; |
| 468 }, | 472 }, |
| 469 } | 473 } |
| 470 | 474 |
| 471 /** | 475 /** |
| 472 * @constructor | 476 * @constructor |
| 473 * @param {!WebInspector.TracingModel.Event} event | 477 * @param {!WebInspector.TracingModel.Event} event |
| 478 * @param {?WebInspector.Target} target |
| 474 */ | 479 */ |
| 475 WebInspector.LayerPaintEvent = function(event) | 480 WebInspector.LayerPaintEvent = function(event, target) |
| 476 { | 481 { |
| 477 this._event = event; | 482 this._event = event; |
| 483 this._target = target; |
| 478 } | 484 } |
| 479 | 485 |
| 480 WebInspector.LayerPaintEvent.prototype = { | 486 WebInspector.LayerPaintEvent.prototype = { |
| 481 /** | 487 /** |
| 482 * @return {string} | 488 * @return {string} |
| 483 */ | 489 */ |
| 484 layerId: function() | 490 layerId: function() |
| 485 { | 491 { |
| 486 return this._event.args["data"]["layerId"]; | 492 return this._event.args["data"]["layerId"]; |
| 487 }, | 493 }, |
| 488 | 494 |
| 489 /** | 495 /** |
| 490 * @return {!WebInspector.TracingModel.Event} | 496 * @return {!WebInspector.TracingModel.Event} |
| 491 */ | 497 */ |
| 492 event: function() | 498 event: function() |
| 493 { | 499 { |
| 494 return this._event; | 500 return this._event; |
| 495 }, | 501 }, |
| 496 | 502 |
| 497 /** | 503 /** |
| 498 * @param {function(?Array.<number>, ?WebInspector.PaintProfilerSnapshot)} c
allback | 504 * @param {function(?Array.<number>, ?WebInspector.PaintProfilerSnapshot)} c
allback |
| 499 */ | 505 */ |
| 500 loadPicture: function(callback) | 506 loadPicture: function(callback) |
| 501 { | 507 { |
| 502 var target = this._event.thread.target(); | 508 this._event.picture.requestObject(onGotObject.bind(this)); |
| 503 this._event.picture.requestObject(onGotObject); | |
| 504 /** | 509 /** |
| 505 * @param {?Object} result | 510 * @param {?Object} result |
| 511 * @this {WebInspector.LayerPaintEvent} |
| 506 */ | 512 */ |
| 507 function onGotObject(result) | 513 function onGotObject(result) |
| 508 { | 514 { |
| 509 if (!result || !result["skp64"] || !target) { | 515 if (!result || !result["skp64"] || !this._target) { |
| 510 callback(null, null); | 516 callback(null, null); |
| 511 return; | 517 return; |
| 512 } | 518 } |
| 513 var rect = result["params"] && result["params"]["layer_rect"]; | 519 var rect = result["params"] && result["params"]["layer_rect"]; |
| 514 WebInspector.PaintProfilerSnapshot.load(target, result["skp64"], cal
lback.bind(null, rect)); | 520 WebInspector.PaintProfilerSnapshot.load(this._target, result["skp64"
], callback.bind(null, rect)); |
| 515 } | 521 } |
| 516 } | 522 } |
| 517 }; | 523 }; |
| 518 | 524 |
| 519 /** | 525 /** |
| 520 * @constructor | 526 * @constructor |
| 521 */ | 527 */ |
| 522 WebInspector.PendingFrame = function() | 528 WebInspector.PendingFrame = function() |
| 523 { | 529 { |
| 524 /** @type {!Object.<string, number>} */ | 530 /** @type {!Object.<string, number>} */ |
| 525 this.timeByCategory = {}; | 531 this.timeByCategory = {}; |
| 526 /** @type {!Array.<!WebInspector.LayerPaintEvent>} */ | 532 /** @type {!Array.<!WebInspector.LayerPaintEvent>} */ |
| 527 this.paints = []; | 533 this.paints = []; |
| 528 } | 534 } |
| OLD | NEW |