Chromium Code Reviews| 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 { | |
| 95 return this._inspectedTargetMainThreadEvents; | |
| 96 }, | |
| 97 | |
| 98 /** | |
| 99 * @return {!Array.<!WebInspector.TracingModel.Event>} | |
| 100 */ | |
| 101 frameLifecycleEvents: function() | |
| 102 { | 81 { |
| 103 /** | 82 /** |
| 104 * @param {!WebInspector.TracingModel.Event} a | 83 * @param {!WebInspector.TracingModel.Event} a |
| 105 * @param {!WebInspector.TracingModel.Event} b | 84 * @param {!WebInspector.TracingModel.Event} b |
| 106 */ | 85 */ |
| 107 function compareStartTime(a, b) | 86 function compareStartTime(a, b) |
| 108 { | 87 { |
| 109 return a.startTime - b.startTime; | 88 return a.startTime - b.startTime; |
| 110 } | 89 } |
| 111 return this._frameLifecycleEvents.sort(compareStartTime); | 90 |
| 91 if (this._needToSortInspectedTargetEvents) { | |
|
yurys
2014/05/27 15:41:32
Can we just sort them once after all events have b
| |
| 92 this._inspectedTargetEvents.sort(compareStartTime); | |
| 93 this._needToSortInspectedTargetEvents = false; | |
| 94 } | |
| 95 return this._inspectedTargetEvents; | |
| 112 }, | 96 }, |
| 113 | 97 |
| 114 /** | 98 /** |
| 115 * @param {string} categoryFilter | 99 * @param {string} categoryFilter |
| 116 * @param {string} options | 100 * @param {string} options |
| 117 * @param {function(?string)=} callback | 101 * @param {function(?string)=} callback |
| 118 */ | 102 */ |
| 119 start: function(categoryFilter, options, callback) | 103 start: function(categoryFilter, options, callback) |
| 120 { | 104 { |
| 121 this.reset(); | 105 this.reset(); |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 190 this._pendingStopCallback = null; | 174 this._pendingStopCallback = null; |
| 191 }, | 175 }, |
| 192 | 176 |
| 193 reset: function() | 177 reset: function() |
| 194 { | 178 { |
| 195 this._processById = {}; | 179 this._processById = {}; |
| 196 this._minimumRecordTime = null; | 180 this._minimumRecordTime = null; |
| 197 this._maximumRecordTime = null; | 181 this._maximumRecordTime = null; |
| 198 this._sessionId = null; | 182 this._sessionId = null; |
| 199 this._inspectedTargetProcessId = null; | 183 this._inspectedTargetProcessId = null; |
| 200 this._inspectedTargetMainThread = null; | 184 this._inspectedTargetEvents = []; |
| 201 this._inspectedTargetMainThreadEvents = []; | |
| 202 this._inspectedTargetLayerTreeHostId = 0; | |
| 203 this._frameLifecycleEvents = []; | |
| 204 }, | 185 }, |
| 205 | 186 |
| 206 /** | 187 /** |
| 207 * @param {!WebInspector.TracingModel.EventPayload} payload | 188 * @param {!WebInspector.TracingModel.EventPayload} payload |
| 208 */ | 189 */ |
| 209 _addEvent: function(payload) | 190 _addEvent: function(payload) |
| 210 { | 191 { |
| 211 var process = this._processById[payload.pid]; | 192 var process = this._processById[payload.pid]; |
| 212 if (!process) { | 193 if (!process) { |
| 213 process = new WebInspector.TracingModel.Process(payload.pid); | 194 process = new WebInspector.TracingModel.Process(payload.pid); |
| 214 this._processById[payload.pid] = process; | 195 this._processById[payload.pid] = process; |
| 215 } | 196 } |
| 216 if (payload.ph === WebInspector.TracingModel.Phase.SnapshotObject) { | 197 if (payload.ph === WebInspector.TracingModel.Phase.SnapshotObject) { |
| 217 process.addObject(payload); | 198 process.addObject(payload); |
| 218 if (payload.pid === this._inspectedTargetProcessId && payload.name = == "cc::LayerTreeHostImpl" && parseInt(payload.id, 0) === this._inspectedTargetL ayerTreeId) | 199 if (payload.pid === this._inspectedTargetProcessId) |
| 219 this._frameLifecycleEvents.push(new WebInspector.TracingModel.Ev ent(payload, 0)); | 200 this._inspectedTargetEvents.push(new WebInspector.TracingModel.E vent(payload, 0)); |
| 220 return; | 201 return; |
| 221 } | 202 } |
| 222 var thread = process.threadById(payload.tid); | 203 var thread = process.threadById(payload.tid); |
| 223 if (payload.ph !== WebInspector.TracingModel.Phase.Metadata) { | 204 if (payload.ph !== WebInspector.TracingModel.Phase.Metadata) { |
| 224 var timestamp = payload.ts; | 205 var timestamp = payload.ts; |
| 225 // We do allow records for unrelated threads to arrive out-of-order, | 206 // 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. | 207 // so there's a chance we're getting records from the past. |
| 227 if (timestamp && (!this._minimumRecordTime || timestamp < this._mini mumRecordTime)) | 208 if (timestamp && (!this._minimumRecordTime || timestamp < this._mini mumRecordTime)) |
| 228 this._minimumRecordTime = timestamp; | 209 this._minimumRecordTime = timestamp; |
| 229 if (!this._maximumRecordTime || timestamp > this._maximumRecordTime) | 210 if (!this._maximumRecordTime || timestamp > this._maximumRecordTime) |
| 230 this._maximumRecordTime = timestamp; | 211 this._maximumRecordTime = timestamp; |
| 231 if (payload.cat === WebInspector.TracingModel.DevToolsMetadataEventC ategory) | 212 if (payload.cat === WebInspector.TracingModel.DevToolsMetadataEventC ategory) |
| 232 this._processDevToolsMetadataEvent(payload); | 213 this._processDevToolsMetadataEvent(payload); |
| 233 var event = thread.addEvent(payload); | 214 var event = thread.addEvent(payload); |
| 234 if (!event) | 215 if (event && payload.pid === this._inspectedTargetProcessId) { |
| 235 return; | 216 this._needToSortInspectedTargetEvents = this._needToSortInspecte dTargetEvents || (this._inspectedTargetEvents.length && this._inspectedTargetEve nts.peekLast().startTime > event.startTime); |
| 236 if (thread === this._inspectedTargetMainThread) | 217 this._inspectedTargetEvents.push(event); |
| 237 this._inspectedTargetMainThreadEvents.push(event); | 218 } |
| 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; | 219 return; |
| 241 } | 220 } |
| 242 switch (payload.name) { | 221 switch (payload.name) { |
| 243 case WebInspector.TracingModel.MetadataEvent.ProcessSortIndex: | 222 case WebInspector.TracingModel.MetadataEvent.ProcessSortIndex: |
| 244 process._setSortIndex(payload.args["sort_index"]); | 223 process._setSortIndex(payload.args["sort_index"]); |
| 245 break; | 224 break; |
| 246 case WebInspector.TracingModel.MetadataEvent.ProcessName: | 225 case WebInspector.TracingModel.MetadataEvent.ProcessName: |
| 247 process._setName(payload.args["name"]); | 226 process._setName(payload.args["name"]); |
| 248 break; | 227 break; |
| 249 case WebInspector.TracingModel.MetadataEvent.ThreadSortIndex: | 228 case WebInspector.TracingModel.MetadataEvent.ThreadSortIndex: |
| 250 thread._setSortIndex(payload.args["sort_index"]); | 229 thread._setSortIndex(payload.args["sort_index"]); |
| 251 break; | 230 break; |
| 252 case WebInspector.TracingModel.MetadataEvent.ThreadName: | 231 case WebInspector.TracingModel.MetadataEvent.ThreadName: |
| 253 thread._setName(payload.args["name"]); | 232 thread._setName(payload.args["name"]); |
| 254 break; | 233 break; |
| 255 } | 234 } |
| 256 }, | 235 }, |
| 257 | 236 |
| 258 /** | 237 /** |
| 259 * @param {!WebInspector.TracingModel.EventPayload} payload | 238 * @param {!WebInspector.TracingModel.EventPayload} payload |
| 260 */ | 239 */ |
| 261 _processDevToolsMetadataEvent: function(payload) | 240 _processDevToolsMetadataEvent: function(payload) |
| 262 { | 241 { |
| 263 if (payload.args["sessionId"] !== this._sessionId) | 242 if (payload.args["sessionId"] !== this._sessionId || payload.name !== We bInspector.TracingModel.DevToolsMetadataEvent.TracingStartedInPage) |
| 264 return; | 243 return; |
| 265 if (payload.name === WebInspector.TracingModel.DevToolsMetadataEvent.Tra cingStartedInPage) { | 244 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 }, | 245 }, |
| 274 | 246 |
| 275 /** | 247 /** |
| 276 * @return {?number} | 248 * @return {?number} |
| 277 */ | 249 */ |
| 278 minimumRecordTime: function() | 250 minimumRecordTime: function() |
| 279 { | 251 { |
| 280 return this._minimumRecordTime; | 252 return this._minimumRecordTime; |
| 281 }, | 253 }, |
| 282 | 254 |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 306 */ | 278 */ |
| 307 WebInspector.TracingModel.Event = function(payload, level) | 279 WebInspector.TracingModel.Event = function(payload, level) |
| 308 { | 280 { |
| 309 this.name = payload.name; | 281 this.name = payload.name; |
| 310 this.category = payload.cat; | 282 this.category = payload.cat; |
| 311 this.startTime = payload.ts; | 283 this.startTime = payload.ts; |
| 312 this.args = payload.args; | 284 this.args = payload.args; |
| 313 this.phase = payload.ph; | 285 this.phase = payload.ph; |
| 314 this.level = level; | 286 this.level = level; |
| 315 | 287 |
| 288 this.thread = payload.tid; | |
|
yurys
2014/05/27 15:41:32
thread -> tid? or we could store a reference to th
| |
| 289 if (payload.id) | |
| 290 this.id = payload.id; | |
| 291 | |
| 316 /** @type {?string} */ | 292 /** @type {?string} */ |
| 317 this.warning = null; | 293 this.warning = null; |
| 318 /** @type {?WebInspector.TracingModel.Event} */ | 294 /** @type {?WebInspector.TracingModel.Event} */ |
| 319 this.initiator = null; | 295 this.initiator = null; |
| 320 /** @type {?Array.<!ConsoleAgent.CallFrame>} */ | 296 /** @type {?Array.<!ConsoleAgent.CallFrame>} */ |
| 321 this.stackTrace = null; | 297 this.stackTrace = null; |
| 322 /** @type {?Element} */ | 298 /** @type {?Element} */ |
| 323 this.previewElement = null; | 299 this.previewElement = null; |
| 324 /** @type {number} */ | 300 /** @type {number} */ |
| 325 this.selfTime = 0; | 301 this.selfTime = 0; |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 572 dataCollected: function(data) | 548 dataCollected: function(data) |
| 573 { | 549 { |
| 574 this._tracingModel._eventsCollected(data); | 550 this._tracingModel._eventsCollected(data); |
| 575 }, | 551 }, |
| 576 | 552 |
| 577 tracingComplete: function() | 553 tracingComplete: function() |
| 578 { | 554 { |
| 579 this._tracingModel._tracingComplete(); | 555 this._tracingModel._tracingComplete(); |
| 580 } | 556 } |
| 581 } | 557 } |
| OLD | NEW |