| 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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 ThreadSortIndex: "thread_sort_index", | 64 ThreadSortIndex: "thread_sort_index", |
| 65 ThreadName: "thread_name" | 65 ThreadName: "thread_name" |
| 66 } | 66 } |
| 67 | 67 |
| 68 WebInspector.TracingModel.DevToolsMetadataEventCategory = "disabled-by-default-d
evtools.timeline"; | 68 WebInspector.TracingModel.DevToolsMetadataEventCategory = "disabled-by-default-d
evtools.timeline"; |
| 69 | 69 |
| 70 WebInspector.TracingModel.FrameLifecycleEventCategory = "cc,devtools"; | 70 WebInspector.TracingModel.FrameLifecycleEventCategory = "cc,devtools"; |
| 71 | 71 |
| 72 WebInspector.TracingModel.DevToolsMetadataEvent = { | 72 WebInspector.TracingModel.DevToolsMetadataEvent = { |
| 73 TracingStartedInPage: "TracingStartedInPage", | 73 TracingStartedInPage: "TracingStartedInPage", |
| 74 SetLayerTreeId: "SetLayerTreeId" | |
| 75 }; | |
| 76 | |
| 77 WebInspector.TracingModel.TraceEventName = { | |
| 78 ActivateLayerTree: "ActivateLayerTree", | |
| 79 BeginFrame: "BeginFrame", | |
| 80 BeginMainThreadFrame: "BeginMainThreadFrame", | |
| 81 CompositeLayers: "CompositeLayers", | |
| 82 DrawFrame: "DrawFrame", | |
| 83 PaintSetup: "PaintSetup", | |
| 84 RasterTask: "RasterTask", | |
| 85 RequestMainThreadFrame: "RequestMainThreadFrame", | |
| 86 LayerTreeHostImplSnapshot: "cc::LayerTreeHostImpl" | |
| 87 }; | 74 }; |
| 88 | 75 |
| 89 WebInspector.TracingModel.prototype = { | 76 WebInspector.TracingModel.prototype = { |
| 90 /** | 77 /** |
| 91 * @return {!Array.<!WebInspector.TracingModel.Event>} | 78 * @return {!Array.<!WebInspector.TracingModel.Event>} |
| 92 */ | 79 */ |
| 93 inspectedTargetMainThreadEvents: function() | 80 inspectedTargetEvents: function() |
| 94 { | 81 { |
| 95 return this._inspectedTargetMainThreadEvents; | 82 return this._inspectedTargetEvents; |
| 96 }, | 83 }, |
| 97 | 84 |
| 98 /** | 85 /** |
| 99 * @return {!Array.<!WebInspector.TracingModel.Event>} | |
| 100 */ | |
| 101 frameLifecycleEvents: function() | |
| 102 { | |
| 103 /** | |
| 104 * @param {!WebInspector.TracingModel.Event} a | |
| 105 * @param {!WebInspector.TracingModel.Event} b | |
| 106 */ | |
| 107 function compareStartTime(a, b) | |
| 108 { | |
| 109 return a.startTime - b.startTime; | |
| 110 } | |
| 111 return this._frameLifecycleEvents.sort(compareStartTime); | |
| 112 }, | |
| 113 | |
| 114 /** | |
| 115 * @param {string} categoryFilter | 86 * @param {string} categoryFilter |
| 116 * @param {string} options | 87 * @param {string} options |
| 117 * @param {function(?string)=} callback | 88 * @param {function(?string)=} callback |
| 118 */ | 89 */ |
| 119 start: function(categoryFilter, options, callback) | 90 start: function(categoryFilter, options, callback) |
| 120 { | 91 { |
| 121 this.reset(); | 92 this.reset(); |
| 122 var bufferUsageReportingIntervalMs = 500; | 93 var bufferUsageReportingIntervalMs = 500; |
| 123 /** | 94 /** |
| 124 * @param {?string} error | 95 * @param {?string} error |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 */ | 148 */ |
| 178 _eventsCollected: function(events) | 149 _eventsCollected: function(events) |
| 179 { | 150 { |
| 180 for (var i = 0; i < events.length; ++i) | 151 for (var i = 0; i < events.length; ++i) |
| 181 this._addEvent(events[i]); | 152 this._addEvent(events[i]); |
| 182 }, | 153 }, |
| 183 | 154 |
| 184 _tracingComplete: function() | 155 _tracingComplete: function() |
| 185 { | 156 { |
| 186 this._active = false; | 157 this._active = false; |
| 158 |
| 159 /** |
| 160 * @param {!WebInspector.TracingModel.Event} a |
| 161 * @param {!WebInspector.TracingModel.Event} b |
| 162 */ |
| 163 function compareStartTime(a, b) |
| 164 { |
| 165 return a.startTime - b.startTime; |
| 166 } |
| 167 |
| 168 this._inspectedTargetEvents.sort(compareStartTime); |
| 187 if (!this._pendingStopCallback) | 169 if (!this._pendingStopCallback) |
| 188 return; | 170 return; |
| 189 this._pendingStopCallback(); | 171 this._pendingStopCallback(); |
| 190 this._pendingStopCallback = null; | 172 this._pendingStopCallback = null; |
| 191 }, | 173 }, |
| 192 | 174 |
| 193 reset: function() | 175 reset: function() |
| 194 { | 176 { |
| 195 this._processById = {}; | 177 this._processById = {}; |
| 196 this._minimumRecordTime = null; | 178 this._minimumRecordTime = null; |
| 197 this._maximumRecordTime = null; | 179 this._maximumRecordTime = null; |
| 198 this._sessionId = null; | 180 this._sessionId = null; |
| 199 this._inspectedTargetProcessId = null; | 181 this._inspectedTargetProcessId = null; |
| 200 this._inspectedTargetMainThread = null; | 182 this._inspectedTargetEvents = []; |
| 201 this._inspectedTargetMainThreadEvents = []; | |
| 202 this._inspectedTargetLayerTreeHostId = 0; | |
| 203 this._frameLifecycleEvents = []; | |
| 204 }, | 183 }, |
| 205 | 184 |
| 206 /** | 185 /** |
| 207 * @param {!WebInspector.TracingModel.EventPayload} payload | 186 * @param {!WebInspector.TracingModel.EventPayload} payload |
| 208 */ | 187 */ |
| 209 _addEvent: function(payload) | 188 _addEvent: function(payload) |
| 210 { | 189 { |
| 211 var process = this._processById[payload.pid]; | 190 var process = this._processById[payload.pid]; |
| 212 if (!process) { | 191 if (!process) { |
| 213 process = new WebInspector.TracingModel.Process(payload.pid); | 192 process = new WebInspector.TracingModel.Process(payload.pid); |
| 214 this._processById[payload.pid] = process; | 193 this._processById[payload.pid] = process; |
| 215 } | 194 } |
| 195 var thread = process.threadById(payload.tid); |
| 216 if (payload.ph === WebInspector.TracingModel.Phase.SnapshotObject) { | 196 if (payload.ph === WebInspector.TracingModel.Phase.SnapshotObject) { |
| 217 process.addObject(payload); | 197 var event = new WebInspector.TracingModel.Event(payload, 0, thread); |
| 218 if (payload.pid === this._inspectedTargetProcessId && payload.name =
== "cc::LayerTreeHostImpl" && parseInt(payload.id, 0) === this._inspectedTargetL
ayerTreeId) | 198 process.addObject(event); |
| 219 this._frameLifecycleEvents.push(new WebInspector.TracingModel.Ev
ent(payload, 0)); | 199 if (payload.pid === this._inspectedTargetProcessId) |
| 200 this._inspectedTargetEvents.push(event); |
| 220 return; | 201 return; |
| 221 } | 202 } |
| 222 var thread = process.threadById(payload.tid); | |
| 223 if (payload.ph !== WebInspector.TracingModel.Phase.Metadata) { | 203 if (payload.ph !== WebInspector.TracingModel.Phase.Metadata) { |
| 224 var timestamp = payload.ts; | 204 var timestamp = payload.ts; |
| 225 // We do allow records for unrelated threads to arrive out-of-order, | 205 // We do allow records for unrelated threads to arrive out-of-order, |
| 226 // so there's a chance we're getting records from the past. | 206 // so there's a chance we're getting records from the past. |
| 227 if (timestamp && (!this._minimumRecordTime || timestamp < this._mini
mumRecordTime)) | 207 if (timestamp && (!this._minimumRecordTime || timestamp < this._mini
mumRecordTime)) |
| 228 this._minimumRecordTime = timestamp; | 208 this._minimumRecordTime = timestamp; |
| 229 if (!this._maximumRecordTime || timestamp > this._maximumRecordTime) | 209 if (!this._maximumRecordTime || timestamp > this._maximumRecordTime) |
| 230 this._maximumRecordTime = timestamp; | 210 this._maximumRecordTime = timestamp; |
| 231 if (payload.cat === WebInspector.TracingModel.DevToolsMetadataEventC
ategory) | 211 if (payload.cat === WebInspector.TracingModel.DevToolsMetadataEventC
ategory) |
| 232 this._processDevToolsMetadataEvent(payload); | 212 this._processDevToolsMetadataEvent(payload); |
| 233 var event = thread.addEvent(payload); | 213 var event = thread.addEvent(payload); |
| 234 if (!event) | 214 if (event && payload.pid === this._inspectedTargetProcessId) |
| 235 return; | 215 this._inspectedTargetEvents.push(event); |
| 236 if (thread === this._inspectedTargetMainThread) | |
| 237 this._inspectedTargetMainThreadEvents.push(event); | |
| 238 if (payload.cat === WebInspector.TracingModel.FrameLifecycleEventCat
egory && payload.pid === this._inspectedTargetProcessId && payload.args && paylo
ad.args["layerTreeId"] === this._inspectedTargetLayerTreeId) | |
| 239 this._frameLifecycleEvents.push(event); | |
| 240 return; | 216 return; |
| 241 } | 217 } |
| 242 switch (payload.name) { | 218 switch (payload.name) { |
| 243 case WebInspector.TracingModel.MetadataEvent.ProcessSortIndex: | 219 case WebInspector.TracingModel.MetadataEvent.ProcessSortIndex: |
| 244 process._setSortIndex(payload.args["sort_index"]); | 220 process._setSortIndex(payload.args["sort_index"]); |
| 245 break; | 221 break; |
| 246 case WebInspector.TracingModel.MetadataEvent.ProcessName: | 222 case WebInspector.TracingModel.MetadataEvent.ProcessName: |
| 247 process._setName(payload.args["name"]); | 223 process._setName(payload.args["name"]); |
| 248 break; | 224 break; |
| 249 case WebInspector.TracingModel.MetadataEvent.ThreadSortIndex: | 225 case WebInspector.TracingModel.MetadataEvent.ThreadSortIndex: |
| 250 thread._setSortIndex(payload.args["sort_index"]); | 226 thread._setSortIndex(payload.args["sort_index"]); |
| 251 break; | 227 break; |
| 252 case WebInspector.TracingModel.MetadataEvent.ThreadName: | 228 case WebInspector.TracingModel.MetadataEvent.ThreadName: |
| 253 thread._setName(payload.args["name"]); | 229 thread._setName(payload.args["name"]); |
| 254 break; | 230 break; |
| 255 } | 231 } |
| 256 }, | 232 }, |
| 257 | 233 |
| 258 /** | 234 /** |
| 259 * @param {!WebInspector.TracingModel.EventPayload} payload | 235 * @param {!WebInspector.TracingModel.EventPayload} payload |
| 260 */ | 236 */ |
| 261 _processDevToolsMetadataEvent: function(payload) | 237 _processDevToolsMetadataEvent: function(payload) |
| 262 { | 238 { |
| 263 if (payload.args["sessionId"] !== this._sessionId) | 239 if (payload.args["sessionId"] !== this._sessionId || payload.name !== We
bInspector.TracingModel.DevToolsMetadataEvent.TracingStartedInPage) |
| 264 return; | 240 return; |
| 265 if (payload.name === WebInspector.TracingModel.DevToolsMetadataEvent.Tra
cingStartedInPage) { | 241 this._inspectedTargetProcessId = payload.pid; |
| 266 var thread = this._processById[payload.pid].threadById(payload.tid) | |
| 267 this._inspectedTargetProcessId = payload.pid; | |
| 268 this._inspectedTargetMainThread = thread; | |
| 269 this._inspectedTargetMainThreadEvents = this._inspectedTargetMainThr
eadEvents.concat(thread.events()); | |
| 270 } else if (payload.name === WebInspector.TracingModel.DevToolsMetadataEv
ent.SetLayerTreeId) { | |
| 271 this._inspectedTargetLayerTreeId = payload.args["layerTreeId"]; | |
| 272 } | |
| 273 }, | 242 }, |
| 274 | 243 |
| 275 /** | 244 /** |
| 276 * @return {?number} | 245 * @return {?number} |
| 277 */ | 246 */ |
| 278 minimumRecordTime: function() | 247 minimumRecordTime: function() |
| 279 { | 248 { |
| 280 return this._minimumRecordTime; | 249 return this._minimumRecordTime; |
| 281 }, | 250 }, |
| 282 | 251 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 296 return WebInspector.TracingModel.NamedObject._sort(Object.values(this._p
rocessById)); | 265 return WebInspector.TracingModel.NamedObject._sort(Object.values(this._p
rocessById)); |
| 297 }, | 266 }, |
| 298 | 267 |
| 299 __proto__: WebInspector.TargetAwareObject.prototype | 268 __proto__: WebInspector.TargetAwareObject.prototype |
| 300 } | 269 } |
| 301 | 270 |
| 302 /** | 271 /** |
| 303 * @constructor | 272 * @constructor |
| 304 * @param {!WebInspector.TracingModel.EventPayload} payload | 273 * @param {!WebInspector.TracingModel.EventPayload} payload |
| 305 * @param {number} level | 274 * @param {number} level |
| 275 * @param {?WebInspector.TracingModel.Thread} thread |
| 306 */ | 276 */ |
| 307 WebInspector.TracingModel.Event = function(payload, level) | 277 WebInspector.TracingModel.Event = function(payload, level, thread) |
| 308 { | 278 { |
| 309 this.name = payload.name; | 279 this.name = payload.name; |
| 310 this.category = payload.cat; | 280 this.category = payload.cat; |
| 311 this.startTime = payload.ts; | 281 this.startTime = payload.ts; |
| 312 this.args = payload.args; | 282 this.args = payload.args; |
| 313 this.phase = payload.ph; | 283 this.phase = payload.ph; |
| 314 this.level = level; | 284 this.level = level; |
| 315 | 285 |
| 286 if (payload.id) |
| 287 this.id = payload.id; |
| 288 |
| 289 this.thread = thread; |
| 290 |
| 316 /** @type {?string} */ | 291 /** @type {?string} */ |
| 317 this.warning = null; | 292 this.warning = null; |
| 318 /** @type {?WebInspector.TracingModel.Event} */ | 293 /** @type {?WebInspector.TracingModel.Event} */ |
| 319 this.initiator = null; | 294 this.initiator = null; |
| 320 /** @type {?Array.<!ConsoleAgent.CallFrame>} */ | 295 /** @type {?Array.<!ConsoleAgent.CallFrame>} */ |
| 321 this.stackTrace = null; | 296 this.stackTrace = null; |
| 322 /** @type {?Element} */ | 297 /** @type {?Element} */ |
| 323 this.previewElement = null; | 298 this.previewElement = null; |
| 324 /** @type {number} */ | 299 /** @type {number} */ |
| 325 this.selfTime = 0; | 300 this.selfTime = 0; |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 432 { | 407 { |
| 433 var thread = this._threads[id]; | 408 var thread = this._threads[id]; |
| 434 if (!thread) { | 409 if (!thread) { |
| 435 thread = new WebInspector.TracingModel.Thread(id); | 410 thread = new WebInspector.TracingModel.Thread(id); |
| 436 this._threads[id] = thread; | 411 this._threads[id] = thread; |
| 437 } | 412 } |
| 438 return thread; | 413 return thread; |
| 439 }, | 414 }, |
| 440 | 415 |
| 441 /** | 416 /** |
| 442 * @param {!WebInspector.TracingModel.EventPayload} event | 417 * @param {!WebInspector.TracingModel.Event} event |
| 443 */ | 418 */ |
| 444 addObject: function(event) | 419 addObject: function(event) |
| 445 { | 420 { |
| 446 this.objectsByName(event.name).push(new WebInspector.TracingModel.Event(
event, 0)); | 421 this.objectsByName(event.name).push(event); |
| 447 }, | 422 }, |
| 448 | 423 |
| 449 /** | 424 /** |
| 450 * @param {string} name | 425 * @param {string} name |
| 451 * @return {!Array.<!WebInspector.TracingModel.Event>} | 426 * @return {!Array.<!WebInspector.TracingModel.Event>} |
| 452 */ | 427 */ |
| 453 objectsByName: function(name) | 428 objectsByName: function(name) |
| 454 { | 429 { |
| 455 var objects = this._objects[name]; | 430 var objects = this._objects[name]; |
| 456 if (!objects) { | 431 if (!objects) { |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 505 top = this._stack.peekLast(); | 480 top = this._stack.peekLast(); |
| 506 } | 481 } |
| 507 if (payload.ph === WebInspector.TracingModel.Phase.End) { | 482 if (payload.ph === WebInspector.TracingModel.Phase.End) { |
| 508 var openEvent = this._stack.pop(); | 483 var openEvent = this._stack.pop(); |
| 509 // Quietly ignore unbalanced close events, they're legit (we could h
ave missed start one). | 484 // Quietly ignore unbalanced close events, they're legit (we could h
ave missed start one). |
| 510 if (openEvent) | 485 if (openEvent) |
| 511 openEvent._complete(payload); | 486 openEvent._complete(payload); |
| 512 return null; | 487 return null; |
| 513 } | 488 } |
| 514 | 489 |
| 515 var event = new WebInspector.TracingModel.Event(payload, this._stack.len
gth); | 490 var event = new WebInspector.TracingModel.Event(payload, this._stack.len
gth, this); |
| 516 if (payload.ph === WebInspector.TracingModel.Phase.Begin || payload.ph =
== WebInspector.TracingModel.Phase.Complete) { | 491 if (payload.ph === WebInspector.TracingModel.Phase.Begin || payload.ph =
== WebInspector.TracingModel.Phase.Complete) { |
| 517 if (payload.ph === WebInspector.TracingModel.Phase.Complete) | 492 if (payload.ph === WebInspector.TracingModel.Phase.Complete) |
| 518 event._setDuration(payload.dur); | 493 event._setDuration(payload.dur); |
| 519 this._stack.push(event); | 494 this._stack.push(event); |
| 520 if (this._maxStackDepth < this._stack.length) | 495 if (this._maxStackDepth < this._stack.length) |
| 521 this._maxStackDepth = this._stack.length; | 496 this._maxStackDepth = this._stack.length; |
| 522 } | 497 } |
| 523 if (this._events.length && this._events.peekLast().startTime > event.sta
rtTime) | 498 if (this._events.length && this._events.peekLast().startTime > event.sta
rtTime) |
| 524 console.assert(false, "Event is our of order: " + event.name); | 499 console.assert(false, "Event is our of order: " + event.name); |
| 525 this._events.push(event); | 500 this._events.push(event); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 572 dataCollected: function(data) | 547 dataCollected: function(data) |
| 573 { | 548 { |
| 574 this._tracingModel._eventsCollected(data); | 549 this._tracingModel._eventsCollected(data); |
| 575 }, | 550 }, |
| 576 | 551 |
| 577 tracingComplete: function() | 552 tracingComplete: function() |
| 578 { | 553 { |
| 579 this._tracingModel._tracingComplete(); | 554 this._tracingModel._tracingComplete(); |
| 580 } | 555 } |
| 581 } | 556 } |
| OLD | NEW |