Chromium Code Reviews| 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 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 208 var result = this._findRecordRecursively(types, record.children()[i] ); | 208 var result = this._findRecordRecursively(types, record.children()[i] ); |
| 209 if (result) | 209 if (result) |
| 210 return result; | 210 return result; |
| 211 } | 211 } |
| 212 return null; | 212 return null; |
| 213 } | 213 } |
| 214 } | 214 } |
| 215 | 215 |
| 216 /** | 216 /** |
| 217 * @constructor | 217 * @constructor |
| 218 * @param {?WebInspector.Target} target | |
| 218 * @extends {WebInspector.TimelineFrameModelBase} | 219 * @extends {WebInspector.TimelineFrameModelBase} |
| 219 */ | 220 */ |
| 220 WebInspector.TracingTimelineFrameModel = function() | 221 WebInspector.TracingTimelineFrameModel = function(target) |
| 221 { | 222 { |
| 222 WebInspector.TimelineFrameModelBase.call(this); | 223 WebInspector.TimelineFrameModelBase.call(this); |
| 224 this._target = target; | |
| 223 } | 225 } |
| 224 | 226 |
| 225 WebInspector.TracingTimelineFrameModel._mainFrameMarkers = [ | 227 WebInspector.TracingTimelineFrameModel._mainFrameMarkers = [ |
| 226 WebInspector.TimelineModel.RecordType.ScheduleStyleRecalculation, | 228 WebInspector.TimelineModel.RecordType.ScheduleStyleRecalculation, |
| 227 WebInspector.TimelineModel.RecordType.InvalidateLayout, | 229 WebInspector.TimelineModel.RecordType.InvalidateLayout, |
| 228 WebInspector.TimelineModel.RecordType.BeginMainThreadFrame, | 230 WebInspector.TimelineModel.RecordType.BeginMainThreadFrame, |
| 229 WebInspector.TimelineModel.RecordType.ScrollLayer | 231 WebInspector.TimelineModel.RecordType.ScrollLayer |
| 230 ]; | 232 ]; |
| 231 | 233 |
| 232 WebInspector.TracingTimelineFrameModel.prototype = { | 234 WebInspector.TracingTimelineFrameModel.prototype = { |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 248 /** | 250 /** |
| 249 * @param {!WebInspector.TracingModel.Event} event | 251 * @param {!WebInspector.TracingModel.Event} event |
| 250 */ | 252 */ |
| 251 _addTraceEvent: function(event) | 253 _addTraceEvent: function(event) |
| 252 { | 254 { |
| 253 var eventNames = WebInspector.TimelineModel.RecordType; | 255 var eventNames = WebInspector.TimelineModel.RecordType; |
| 254 | 256 |
| 255 if (event.name === eventNames.SetLayerTreeId) { | 257 if (event.name === eventNames.SetLayerTreeId) { |
| 256 if (this._sessionId === event.args["sessionId"]) | 258 if (this._sessionId === event.args["sessionId"]) |
| 257 this._layerTreeId = event.args["layerTreeId"]; | 259 this._layerTreeId = event.args["layerTreeId"]; |
| 258 return; | 260 } else if (event.name === eventNames.TracingStartedInPage) { |
| 261 this._mainThread = event.thread; | |
| 262 } else if (event.phase === WebInspector.TracingModel.Phase.SnapshotObjec t && event.name === eventNames.LayerTreeHostImplSnapshot && parseInt(event.id, 0 ) === this._layerTreeId) { | |
| 263 var snapshot = /** @type {!WebInspector.TracingModel.ObjectSnapshot} */ (event); | |
| 264 this.handleLayerTreeSnapshot(new WebInspector.DeferredTracingLayerTr ee(snapshot, this._target)); | |
| 265 } else if (event.thread === this._mainThread) { | |
| 266 this._addMainThreadTraceEvent(event); | |
| 259 } | 267 } |
| 260 if (event.name === eventNames.TracingStartedInPage) { | 268 else { |
|
alph
2014/11/13 11:11:40
should be on the previous line
| |
| 261 this._mainThread = event.thread; | 269 this._addBackgroundTraceEvent(event); |
| 262 return; | |
| 263 } | 270 } |
| 264 if (event.thread === this._mainThread) | |
| 265 this._addMainThreadTraceEvent(event); | |
| 266 else | |
| 267 this._addBackgroundTraceEvent(event); | |
| 268 }, | 271 }, |
| 269 | 272 |
| 270 /** | 273 /** |
| 271 * @param {!WebInspector.TracingModel.Event} event | 274 * @param {!WebInspector.TracingModel.Event} event |
| 272 */ | 275 */ |
| 273 _addBackgroundTraceEvent: function(event) | 276 _addBackgroundTraceEvent: function(event) |
| 274 { | 277 { |
| 275 var eventNames = WebInspector.TimelineModel.RecordType; | 278 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) | 279 if (this._lastFrame && event.selfTime) |
| 282 this._lastFrame._addTimeForCategory(WebInspector.TimelineUIUtils.eve ntStyle(event).category.name, event.selfTime); | 280 this._lastFrame._addTimeForCategory(WebInspector.TimelineUIUtils.eve ntStyle(event).category.name, event.selfTime); |
| 283 | 281 |
| 284 if (event.args["layerTreeId"] !== this._layerTreeId) | 282 if (event.args["layerTreeId"] !== this._layerTreeId) |
| 285 return; | 283 return; |
| 286 | 284 |
| 287 var timestamp = event.startTime; | 285 var timestamp = event.startTime; |
| 288 if (event.name === eventNames.BeginFrame) | 286 if (event.name === eventNames.BeginFrame) |
| 289 this.handleBeginFrame(timestamp); | 287 this.handleBeginFrame(timestamp); |
| 290 else if (event.name === eventNames.DrawFrame) | 288 else if (event.name === eventNames.DrawFrame) |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 314 | 312 |
| 315 var categoryName = WebInspector.TimelineUIUtils.eventStyle(event).ca tegory.name; | 313 var categoryName = WebInspector.TimelineUIUtils.eventStyle(event).ca tegory.name; |
| 316 this._lastFrame._addTimeForCategory(categoryName, selfTime); | 314 this._lastFrame._addTimeForCategory(categoryName, selfTime); |
| 317 return; | 315 return; |
| 318 } | 316 } |
| 319 | 317 |
| 320 if (!this._framePendingCommit && WebInspector.TracingTimelineFrameModel. _mainFrameMarkers.indexOf(event.name) >= 0) | 318 if (!this._framePendingCommit && WebInspector.TracingTimelineFrameModel. _mainFrameMarkers.indexOf(event.name) >= 0) |
| 321 this._framePendingCommit = new WebInspector.PendingFrame(); | 319 this._framePendingCommit = new WebInspector.PendingFrame(); |
| 322 if (!this._framePendingCommit) | 320 if (!this._framePendingCommit) |
| 323 return; | 321 return; |
| 324 if (event.name === eventNames.Paint && event.args["data"]["layerId"] && event.picture) | 322 if (event.name === eventNames.Paint && event.args["data"]["layerId"] && event.picture && this._target) |
| 325 this._framePendingCommit.paints.push(new WebInspector.LayerPaintEven t(event)); | 323 this._framePendingCommit.paints.push(new WebInspector.LayerPaintEven t(event, this._target)); |
| 326 | 324 |
| 327 if (selfTime) { | 325 if (selfTime) { |
| 328 var categoryName = WebInspector.TimelineUIUtils.eventStyle(event).ca tegory.name; | 326 var categoryName = WebInspector.TimelineUIUtils.eventStyle(event).ca tegory.name; |
| 329 this._framePendingCommit.timeByCategory[categoryName] = (this._frame PendingCommit.timeByCategory[categoryName] || 0) + selfTime; | 327 this._framePendingCommit.timeByCategory[categoryName] = (this._frame PendingCommit.timeByCategory[categoryName] || 0) + selfTime; |
| 330 } | 328 } |
| 331 if (event.name === eventNames.CompositeLayers && event.args["layerTreeId "] === this._layerTreeId) | 329 if (event.name === eventNames.CompositeLayers && event.args["layerTreeId "] === this._layerTreeId) |
| 332 this.handleCompositeLayers(); | 330 this.handleCompositeLayers(); |
| 333 }, | 331 }, |
| 334 | 332 |
| 335 __proto__: WebInspector.TimelineFrameModelBase.prototype | 333 __proto__: WebInspector.TimelineFrameModelBase.prototype |
| 336 } | 334 } |
| 337 | 335 |
| 338 /** | 336 /** |
| 339 * @constructor | 337 * @constructor |
| 340 * @extends {WebInspector.DeferredLayerTree} | 338 * @extends {WebInspector.DeferredLayerTree} |
| 341 * @param {!WebInspector.TracingModel.ObjectSnapshot} snapshot | 339 * @param {!WebInspector.TracingModel.ObjectSnapshot} snapshot |
| 340 * @param {?WebInspector.Target} target | |
| 342 */ | 341 */ |
| 343 WebInspector.DeferredTracingLayerTree = function(snapshot) | 342 WebInspector.DeferredTracingLayerTree = function(snapshot, target) |
| 344 { | 343 { |
| 345 WebInspector.DeferredLayerTree.call(this, snapshot.thread.target()); | 344 WebInspector.DeferredLayerTree.call(this, target); |
| 346 this._snapshot = snapshot; | 345 this._snapshot = snapshot; |
| 347 } | 346 } |
| 348 | 347 |
| 349 WebInspector.DeferredTracingLayerTree.prototype = { | 348 WebInspector.DeferredTracingLayerTree.prototype = { |
| 350 /** | 349 /** |
| 351 * @param {function(!WebInspector.LayerTreeBase)} callback | 350 * @param {function(!WebInspector.LayerTreeBase)} callback |
| 352 */ | 351 */ |
| 353 resolve: function(callback) | 352 resolve: function(callback) |
| 354 { | 353 { |
| 355 this._snapshot.requestObject(onGotObject.bind(this)); | 354 this._snapshot.requestObject(onGotObject.bind(this)); |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 464 _addTimeForCategory: function(category, time) | 463 _addTimeForCategory: function(category, time) |
| 465 { | 464 { |
| 466 this.timeByCategory[category] = (this.timeByCategory[category] || 0) + t ime; | 465 this.timeByCategory[category] = (this.timeByCategory[category] || 0) + t ime; |
| 467 this.cpuTime += time; | 466 this.cpuTime += time; |
| 468 }, | 467 }, |
| 469 } | 468 } |
| 470 | 469 |
| 471 /** | 470 /** |
| 472 * @constructor | 471 * @constructor |
| 473 * @param {!WebInspector.TracingModel.Event} event | 472 * @param {!WebInspector.TracingModel.Event} event |
| 473 * @param {!WebInspector.Target} target | |
| 474 */ | 474 */ |
| 475 WebInspector.LayerPaintEvent = function(event) | 475 WebInspector.LayerPaintEvent = function(event, target) |
| 476 { | 476 { |
| 477 this._event = event; | 477 this._event = event; |
| 478 this._target = target; | |
| 478 } | 479 } |
| 479 | 480 |
| 480 WebInspector.LayerPaintEvent.prototype = { | 481 WebInspector.LayerPaintEvent.prototype = { |
| 481 /** | 482 /** |
| 482 * @return {string} | 483 * @return {string} |
| 483 */ | 484 */ |
| 484 layerId: function() | 485 layerId: function() |
| 485 { | 486 { |
| 486 return this._event.args["data"]["layerId"]; | 487 return this._event.args["data"]["layerId"]; |
| 487 }, | 488 }, |
| 488 | 489 |
| 489 /** | 490 /** |
| 490 * @return {!WebInspector.TracingModel.Event} | 491 * @return {!WebInspector.TracingModel.Event} |
| 491 */ | 492 */ |
| 492 event: function() | 493 event: function() |
| 493 { | 494 { |
| 494 return this._event; | 495 return this._event; |
| 495 }, | 496 }, |
| 496 | 497 |
| 497 /** | 498 /** |
| 498 * @param {function(?Array.<number>, ?WebInspector.PaintProfilerSnapshot)} c allback | 499 * @param {function(?Array.<number>, ?WebInspector.PaintProfilerSnapshot)} c allback |
| 499 */ | 500 */ |
| 500 loadPicture: function(callback) | 501 loadPicture: function(callback) |
| 501 { | 502 { |
| 502 var target = this._event.thread.target(); | 503 this._event.picture.requestObject(onGotObject.bind(this)); |
| 503 this._event.picture.requestObject(onGotObject); | |
| 504 /** | 504 /** |
| 505 * @param {?Object} result | 505 * @param {?Object} result |
| 506 * @this {WebInspector.LayerPaintEvent} | |
| 506 */ | 507 */ |
| 507 function onGotObject(result) | 508 function onGotObject(result) |
| 508 { | 509 { |
| 509 if (!result || !result["skp64"] || !target) { | 510 if (!result || !result["skp64"]) { |
| 510 callback(null, null); | 511 callback(null, null); |
| 511 return; | 512 return; |
| 512 } | 513 } |
| 513 var rect = result["params"] && result["params"]["layer_rect"]; | 514 var rect = result["params"] && result["params"]["layer_rect"]; |
| 514 WebInspector.PaintProfilerSnapshot.load(target, result["skp64"], cal lback.bind(null, rect)); | 515 WebInspector.PaintProfilerSnapshot.load(this._target, result["skp64" ], callback.bind(null, rect)); |
| 515 } | 516 } |
| 516 } | 517 } |
| 517 }; | 518 }; |
| 518 | 519 |
| 519 /** | 520 /** |
| 520 * @constructor | 521 * @constructor |
| 521 */ | 522 */ |
| 522 WebInspector.PendingFrame = function() | 523 WebInspector.PendingFrame = function() |
| 523 { | 524 { |
| 524 /** @type {!Object.<string, number>} */ | 525 /** @type {!Object.<string, number>} */ |
| 525 this.timeByCategory = {}; | 526 this.timeByCategory = {}; |
| 526 /** @type {!Array.<!WebInspector.LayerPaintEvent>} */ | 527 /** @type {!Array.<!WebInspector.LayerPaintEvent>} */ |
| 527 this.paints = []; | 528 this.paints = []; |
| 528 } | 529 } |
| OLD | NEW |