| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 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 13 matching lines...) Expand all Loading... |
| 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 /** | 31 /** |
| 32 * @unrestricted | 32 * @unrestricted |
| 33 */ | 33 */ |
| 34 WebInspector.TimelineModel = class { | 34 TimelineModel.TimelineModel = class { |
| 35 /** | 35 /** |
| 36 * @param {!WebInspector.TimelineModel.Filter} eventFilter | 36 * @param {!TimelineModel.TimelineModel.Filter} eventFilter |
| 37 */ | 37 */ |
| 38 constructor(eventFilter) { | 38 constructor(eventFilter) { |
| 39 this._eventFilter = eventFilter; | 39 this._eventFilter = eventFilter; |
| 40 this.reset(); | 40 this.reset(); |
| 41 } | 41 } |
| 42 | 42 |
| 43 /** | 43 /** |
| 44 * @param {!Array.<!WebInspector.TracingModel.Event>} events | 44 * @param {!Array.<!SDK.TracingModel.Event>} events |
| 45 * @param {function(!WebInspector.TracingModel.Event)} onStartEvent | 45 * @param {function(!SDK.TracingModel.Event)} onStartEvent |
| 46 * @param {function(!WebInspector.TracingModel.Event)} onEndEvent | 46 * @param {function(!SDK.TracingModel.Event)} onEndEvent |
| 47 * @param {function(!WebInspector.TracingModel.Event,?WebInspector.TracingMode
l.Event)|undefined=} onInstantEvent | 47 * @param {function(!SDK.TracingModel.Event,?SDK.TracingModel.Event)|undefined
=} onInstantEvent |
| 48 * @param {number=} startTime | 48 * @param {number=} startTime |
| 49 * @param {number=} endTime | 49 * @param {number=} endTime |
| 50 */ | 50 */ |
| 51 static forEachEvent(events, onStartEvent, onEndEvent, onInstantEvent, startTim
e, endTime) { | 51 static forEachEvent(events, onStartEvent, onEndEvent, onInstantEvent, startTim
e, endTime) { |
| 52 startTime = startTime || 0; | 52 startTime = startTime || 0; |
| 53 endTime = endTime || Infinity; | 53 endTime = endTime || Infinity; |
| 54 var stack = []; | 54 var stack = []; |
| 55 for (var i = 0; i < events.length; ++i) { | 55 for (var i = 0; i < events.length; ++i) { |
| 56 var e = events[i]; | 56 var e = events[i]; |
| 57 if ((e.endTime || e.startTime) < startTime) | 57 if ((e.endTime || e.startTime) < startTime) |
| 58 continue; | 58 continue; |
| 59 if (e.startTime >= endTime) | 59 if (e.startTime >= endTime) |
| 60 break; | 60 break; |
| 61 if (WebInspector.TracingModel.isAsyncPhase(e.phase) || WebInspector.Tracin
gModel.isFlowPhase(e.phase)) | 61 if (SDK.TracingModel.isAsyncPhase(e.phase) || SDK.TracingModel.isFlowPhase
(e.phase)) |
| 62 continue; | 62 continue; |
| 63 while (stack.length && stack.peekLast().endTime <= e.startTime) | 63 while (stack.length && stack.peekLast().endTime <= e.startTime) |
| 64 onEndEvent(stack.pop()); | 64 onEndEvent(stack.pop()); |
| 65 if (e.duration) { | 65 if (e.duration) { |
| 66 onStartEvent(e); | 66 onStartEvent(e); |
| 67 stack.push(e); | 67 stack.push(e); |
| 68 } else { | 68 } else { |
| 69 onInstantEvent && onInstantEvent(e, stack.peekLast() || null); | 69 onInstantEvent && onInstantEvent(e, stack.peekLast() || null); |
| 70 } | 70 } |
| 71 } | 71 } |
| 72 while (stack.length) | 72 while (stack.length) |
| 73 onEndEvent(stack.pop()); | 73 onEndEvent(stack.pop()); |
| 74 } | 74 } |
| 75 | 75 |
| 76 /** | 76 /** |
| 77 * @return {!WebInspector.TimelineModel.RecordType} | 77 * @return {!TimelineModel.TimelineModel.RecordType} |
| 78 */ | 78 */ |
| 79 static _eventType(event) { | 79 static _eventType(event) { |
| 80 if (event.hasCategory(WebInspector.TimelineModel.Category.Console)) | 80 if (event.hasCategory(TimelineModel.TimelineModel.Category.Console)) |
| 81 return WebInspector.TimelineModel.RecordType.ConsoleTime; | 81 return TimelineModel.TimelineModel.RecordType.ConsoleTime; |
| 82 if (event.hasCategory(WebInspector.TimelineModel.Category.UserTiming)) | 82 if (event.hasCategory(TimelineModel.TimelineModel.Category.UserTiming)) |
| 83 return WebInspector.TimelineModel.RecordType.UserTiming; | 83 return TimelineModel.TimelineModel.RecordType.UserTiming; |
| 84 if (event.hasCategory(WebInspector.TimelineModel.Category.LatencyInfo)) | 84 if (event.hasCategory(TimelineModel.TimelineModel.Category.LatencyInfo)) |
| 85 return WebInspector.TimelineModel.RecordType.LatencyInfo; | 85 return TimelineModel.TimelineModel.RecordType.LatencyInfo; |
| 86 return /** @type !WebInspector.TimelineModel.RecordType */ (event.name); | 86 return /** @type !TimelineModel.TimelineModel.RecordType */ (event.name); |
| 87 } | 87 } |
| 88 | 88 |
| 89 /** | 89 /** |
| 90 * @param {!Array<!WebInspector.TimelineModel.Filter>} filters | 90 * @param {!Array<!TimelineModel.TimelineModel.Filter>} filters |
| 91 * @param {!WebInspector.TracingModel.Event} event | 91 * @param {!SDK.TracingModel.Event} event |
| 92 * @return {boolean} | 92 * @return {boolean} |
| 93 */ | 93 */ |
| 94 static isVisible(filters, event) { | 94 static isVisible(filters, event) { |
| 95 for (var i = 0; i < filters.length; ++i) { | 95 for (var i = 0; i < filters.length; ++i) { |
| 96 if (!filters[i].accept(event)) | 96 if (!filters[i].accept(event)) |
| 97 return false; | 97 return false; |
| 98 } | 98 } |
| 99 return true; | 99 return true; |
| 100 } | 100 } |
| 101 | 101 |
| 102 /** | 102 /** |
| 103 * @param {!WebInspector.TracingModel.Event} event | 103 * @param {!SDK.TracingModel.Event} event |
| 104 * @return {boolean} | 104 * @return {boolean} |
| 105 */ | 105 */ |
| 106 static isMarkerEvent(event) { | 106 static isMarkerEvent(event) { |
| 107 var recordTypes = WebInspector.TimelineModel.RecordType; | 107 var recordTypes = TimelineModel.TimelineModel.RecordType; |
| 108 switch (event.name) { | 108 switch (event.name) { |
| 109 case recordTypes.TimeStamp: | 109 case recordTypes.TimeStamp: |
| 110 case recordTypes.MarkFirstPaint: | 110 case recordTypes.MarkFirstPaint: |
| 111 return true; | 111 return true; |
| 112 case recordTypes.MarkDOMContent: | 112 case recordTypes.MarkDOMContent: |
| 113 case recordTypes.MarkLoad: | 113 case recordTypes.MarkLoad: |
| 114 return event.args['data']['isMainFrame']; | 114 return event.args['data']['isMainFrame']; |
| 115 default: | 115 default: |
| 116 return false; | 116 return false; |
| 117 } | 117 } |
| 118 } | 118 } |
| 119 | 119 |
| 120 /** | 120 /** |
| 121 * @param {!WebInspector.TracingModel.Event} event | 121 * @param {!SDK.TracingModel.Event} event |
| 122 * @return {string} | 122 * @return {string} |
| 123 */ | 123 */ |
| 124 static eventFrameId(event) { | 124 static eventFrameId(event) { |
| 125 var data = event.args['data'] || event.args['beginData']; | 125 var data = event.args['data'] || event.args['beginData']; |
| 126 var frame = data && data['frame']; | 126 var frame = data && data['frame']; |
| 127 if (!frame) | 127 if (!frame) |
| 128 return ''; | 128 return ''; |
| 129 var processId = event.thread.process().id(); | 129 var processId = event.thread.process().id(); |
| 130 return `${processId}.${frame}`; | 130 return `${processId}.${frame}`; |
| 131 } | 131 } |
| 132 | 132 |
| 133 /** | 133 /** |
| 134 * @deprecated Test use only! | 134 * @deprecated Test use only! |
| 135 * @param {?function(!WebInspector.TimelineModel.Record)|?function(!WebInspect
or.TimelineModel.Record,number)} preOrderCallback | 135 * @param {?function(!TimelineModel.TimelineModel.Record)|?function(!TimelineM
odel.TimelineModel.Record,number)} preOrderCallback |
| 136 * @param {function(!WebInspector.TimelineModel.Record)|function(!WebInspector
.TimelineModel.Record,number)=} postOrderCallback | 136 * @param {function(!TimelineModel.TimelineModel.Record)|function(!TimelineMod
el.TimelineModel.Record,number)=} postOrderCallback |
| 137 * @return {boolean} | 137 * @return {boolean} |
| 138 */ | 138 */ |
| 139 forAllRecords(preOrderCallback, postOrderCallback) { | 139 forAllRecords(preOrderCallback, postOrderCallback) { |
| 140 /** | 140 /** |
| 141 * @param {!Array.<!WebInspector.TimelineModel.Record>} records | 141 * @param {!Array.<!TimelineModel.TimelineModel.Record>} records |
| 142 * @param {number} depth | 142 * @param {number} depth |
| 143 * @return {boolean} | 143 * @return {boolean} |
| 144 */ | 144 */ |
| 145 function processRecords(records, depth) { | 145 function processRecords(records, depth) { |
| 146 for (var i = 0; i < records.length; ++i) { | 146 for (var i = 0; i < records.length; ++i) { |
| 147 var record = records[i]; | 147 var record = records[i]; |
| 148 if (preOrderCallback && preOrderCallback(record, depth)) | 148 if (preOrderCallback && preOrderCallback(record, depth)) |
| 149 return true; | 149 return true; |
| 150 if (processRecords(record.children(), depth + 1)) | 150 if (processRecords(record.children(), depth + 1)) |
| 151 return true; | 151 return true; |
| 152 if (postOrderCallback && postOrderCallback(record, depth)) | 152 if (postOrderCallback && postOrderCallback(record, depth)) |
| 153 return true; | 153 return true; |
| 154 } | 154 } |
| 155 return false; | 155 return false; |
| 156 } | 156 } |
| 157 return processRecords(this._records, 0); | 157 return processRecords(this._records, 0); |
| 158 } | 158 } |
| 159 | 159 |
| 160 /** | 160 /** |
| 161 * @param {!Array<!WebInspector.TimelineModel.Filter>} filters | 161 * @param {!Array<!TimelineModel.TimelineModel.Filter>} filters |
| 162 * @param {function(!WebInspector.TimelineModel.Record)|function(!WebInspector
.TimelineModel.Record,number)} callback | 162 * @param {function(!TimelineModel.TimelineModel.Record)|function(!TimelineMod
el.TimelineModel.Record,number)} callback |
| 163 */ | 163 */ |
| 164 forAllFilteredRecords(filters, callback) { | 164 forAllFilteredRecords(filters, callback) { |
| 165 /** | 165 /** |
| 166 * @param {!WebInspector.TimelineModel.Record} record | 166 * @param {!TimelineModel.TimelineModel.Record} record |
| 167 * @param {number} depth | 167 * @param {number} depth |
| 168 * @this {WebInspector.TimelineModel} | 168 * @this {TimelineModel.TimelineModel} |
| 169 * @return {boolean} | 169 * @return {boolean} |
| 170 */ | 170 */ |
| 171 function processRecord(record, depth) { | 171 function processRecord(record, depth) { |
| 172 var visible = WebInspector.TimelineModel.isVisible(filters, record.traceEv
ent()); | 172 var visible = TimelineModel.TimelineModel.isVisible(filters, record.traceE
vent()); |
| 173 if (visible && callback(record, depth)) | 173 if (visible && callback(record, depth)) |
| 174 return true; | 174 return true; |
| 175 | 175 |
| 176 for (var i = 0; i < record.children().length; ++i) { | 176 for (var i = 0; i < record.children().length; ++i) { |
| 177 if (processRecord.call(this, record.children()[i], visible ? depth + 1 :
depth)) | 177 if (processRecord.call(this, record.children()[i], visible ? depth + 1 :
depth)) |
| 178 return true; | 178 return true; |
| 179 } | 179 } |
| 180 return false; | 180 return false; |
| 181 } | 181 } |
| 182 | 182 |
| 183 for (var i = 0; i < this._records.length; ++i) | 183 for (var i = 0; i < this._records.length; ++i) |
| 184 processRecord.call(this, this._records[i], 0); | 184 processRecord.call(this, this._records[i], 0); |
| 185 } | 185 } |
| 186 | 186 |
| 187 /** | 187 /** |
| 188 * @return {!Array.<!WebInspector.TimelineModel.Record>} | 188 * @return {!Array.<!TimelineModel.TimelineModel.Record>} |
| 189 */ | 189 */ |
| 190 records() { | 190 records() { |
| 191 return this._records; | 191 return this._records; |
| 192 } | 192 } |
| 193 | 193 |
| 194 /** | 194 /** |
| 195 * @return {!Array<!WebInspector.CPUProfileDataModel>} | 195 * @return {!Array<!SDK.CPUProfileDataModel>} |
| 196 */ | 196 */ |
| 197 cpuProfiles() { | 197 cpuProfiles() { |
| 198 return this._cpuProfiles; | 198 return this._cpuProfiles; |
| 199 } | 199 } |
| 200 | 200 |
| 201 /** | 201 /** |
| 202 * @return {?string} | 202 * @return {?string} |
| 203 */ | 203 */ |
| 204 sessionId() { | 204 sessionId() { |
| 205 return this._sessionId; | 205 return this._sessionId; |
| 206 } | 206 } |
| 207 | 207 |
| 208 /** | 208 /** |
| 209 * @param {!WebInspector.TracingModel.Event} event | 209 * @param {!SDK.TracingModel.Event} event |
| 210 * @return {?WebInspector.Target} | 210 * @return {?SDK.Target} |
| 211 */ | 211 */ |
| 212 targetByEvent(event) { | 212 targetByEvent(event) { |
| 213 // FIXME: Consider returning null for loaded traces. | 213 // FIXME: Consider returning null for loaded traces. |
| 214 var workerId = this._workerIdByThread.get(event.thread); | 214 var workerId = this._workerIdByThread.get(event.thread); |
| 215 var mainTarget = WebInspector.targetManager.mainTarget(); | 215 var mainTarget = SDK.targetManager.mainTarget(); |
| 216 return workerId ? mainTarget.subTargetsManager.targetForId(workerId) : mainT
arget; | 216 return workerId ? mainTarget.subTargetsManager.targetForId(workerId) : mainT
arget; |
| 217 } | 217 } |
| 218 | 218 |
| 219 /** | 219 /** |
| 220 * @param {!WebInspector.TracingModel} tracingModel | 220 * @param {!SDK.TracingModel} tracingModel |
| 221 * @param {boolean=} produceTraceStartedInPage | 221 * @param {boolean=} produceTraceStartedInPage |
| 222 */ | 222 */ |
| 223 setEvents(tracingModel, produceTraceStartedInPage) { | 223 setEvents(tracingModel, produceTraceStartedInPage) { |
| 224 this.reset(); | 224 this.reset(); |
| 225 this._resetProcessingState(); | 225 this._resetProcessingState(); |
| 226 | 226 |
| 227 this._minimumRecordTime = tracingModel.minimumRecordTime(); | 227 this._minimumRecordTime = tracingModel.minimumRecordTime(); |
| 228 this._maximumRecordTime = tracingModel.maximumRecordTime(); | 228 this._maximumRecordTime = tracingModel.maximumRecordTime(); |
| 229 | 229 |
| 230 var metadataEvents = this._processMetadataEvents(tracingModel, !!produceTrac
eStartedInPage); | 230 var metadataEvents = this._processMetadataEvents(tracingModel, !!produceTrac
eStartedInPage); |
| 231 if (Runtime.experiments.isEnabled('timelineShowAllProcesses')) { | 231 if (Runtime.experiments.isEnabled('timelineShowAllProcesses')) { |
| 232 var lastPageMetaEvent = metadataEvents.page.peekLast(); | 232 var lastPageMetaEvent = metadataEvents.page.peekLast(); |
| 233 for (var process of tracingModel.sortedProcesses()) { | 233 for (var process of tracingModel.sortedProcesses()) { |
| 234 for (var thread of process.sortedThreads()) | 234 for (var thread of process.sortedThreads()) |
| 235 this._processThreadEvents(tracingModel, 0, Infinity, thread, thread ==
= lastPageMetaEvent.thread); | 235 this._processThreadEvents(tracingModel, 0, Infinity, thread, thread ==
= lastPageMetaEvent.thread); |
| 236 } | 236 } |
| 237 } else { | 237 } else { |
| 238 var startTime = 0; | 238 var startTime = 0; |
| 239 for (var i = 0, length = metadataEvents.page.length; i < length; i++) { | 239 for (var i = 0, length = metadataEvents.page.length; i < length; i++) { |
| 240 var metaEvent = metadataEvents.page[i]; | 240 var metaEvent = metadataEvents.page[i]; |
| 241 var process = metaEvent.thread.process(); | 241 var process = metaEvent.thread.process(); |
| 242 var endTime = i + 1 < length ? metadataEvents.page[i + 1].startTime : In
finity; | 242 var endTime = i + 1 < length ? metadataEvents.page[i + 1].startTime : In
finity; |
| 243 this._currentPage = metaEvent.args['data'] && metaEvent.args['data']['pa
ge']; | 243 this._currentPage = metaEvent.args['data'] && metaEvent.args['data']['pa
ge']; |
| 244 for (var thread of process.sortedThreads()) { | 244 for (var thread of process.sortedThreads()) { |
| 245 if (thread.name() === WebInspector.TimelineModel.WorkerThreadName) { | 245 if (thread.name() === TimelineModel.TimelineModel.WorkerThreadName) { |
| 246 var workerMetaEvent = metadataEvents.workers.find(e => e.args['data'
]['workerThreadId'] === thread.id()); | 246 var workerMetaEvent = metadataEvents.workers.find(e => e.args['data'
]['workerThreadId'] === thread.id()); |
| 247 if (!workerMetaEvent) | 247 if (!workerMetaEvent) |
| 248 continue; | 248 continue; |
| 249 var workerId = workerMetaEvent.args['data']['workerId']; | 249 var workerId = workerMetaEvent.args['data']['workerId']; |
| 250 if (workerId) | 250 if (workerId) |
| 251 this._workerIdByThread.set(thread, workerId); | 251 this._workerIdByThread.set(thread, workerId); |
| 252 } | 252 } |
| 253 this._processThreadEvents(tracingModel, startTime, endTime, thread, th
read === metaEvent.thread); | 253 this._processThreadEvents(tracingModel, startTime, endTime, thread, th
read === metaEvent.thread); |
| 254 } | 254 } |
| 255 startTime = endTime; | 255 startTime = endTime; |
| 256 } | 256 } |
| 257 } | 257 } |
| 258 this._inspectedTargetEvents.sort(WebInspector.TracingModel.Event.compareStar
tTime); | 258 this._inspectedTargetEvents.sort(SDK.TracingModel.Event.compareStartTime); |
| 259 | 259 |
| 260 this._processBrowserEvents(tracingModel); | 260 this._processBrowserEvents(tracingModel); |
| 261 this._buildTimelineRecords(); | 261 this._buildTimelineRecords(); |
| 262 this._buildGPUEvents(tracingModel); | 262 this._buildGPUEvents(tracingModel); |
| 263 this._insertFirstPaintEvent(); | 263 this._insertFirstPaintEvent(); |
| 264 this._resetProcessingState(); | 264 this._resetProcessingState(); |
| 265 } | 265 } |
| 266 | 266 |
| 267 /** | 267 /** |
| 268 * @param {!WebInspector.TracingModel} tracingModel | 268 * @param {!SDK.TracingModel} tracingModel |
| 269 * @param {boolean} produceTraceStartedInPage | 269 * @param {boolean} produceTraceStartedInPage |
| 270 * @return {!WebInspector.TimelineModel.MetadataEvents} | 270 * @return {!TimelineModel.TimelineModel.MetadataEvents} |
| 271 */ | 271 */ |
| 272 _processMetadataEvents(tracingModel, produceTraceStartedInPage) { | 272 _processMetadataEvents(tracingModel, produceTraceStartedInPage) { |
| 273 var metadataEvents = tracingModel.devToolsMetadataEvents(); | 273 var metadataEvents = tracingModel.devToolsMetadataEvents(); |
| 274 | 274 |
| 275 var pageDevToolsMetadataEvents = []; | 275 var pageDevToolsMetadataEvents = []; |
| 276 var workersDevToolsMetadataEvents = []; | 276 var workersDevToolsMetadataEvents = []; |
| 277 for (var event of metadataEvents) { | 277 for (var event of metadataEvents) { |
| 278 if (event.name === WebInspector.TimelineModel.DevToolsMetadataEvent.Tracin
gStartedInPage) { | 278 if (event.name === TimelineModel.TimelineModel.DevToolsMetadataEvent.Traci
ngStartedInPage) { |
| 279 pageDevToolsMetadataEvents.push(event); | 279 pageDevToolsMetadataEvents.push(event); |
| 280 var frames = ((event.args['data'] && event.args['data']['frames']) || []
); | 280 var frames = ((event.args['data'] && event.args['data']['frames']) || []
); |
| 281 frames.forEach(payload => this._addPageFrame(event, payload)); | 281 frames.forEach(payload => this._addPageFrame(event, payload)); |
| 282 } else if (event.name === WebInspector.TimelineModel.DevToolsMetadataEvent
.TracingSessionIdForWorker) { | 282 } else if (event.name === TimelineModel.TimelineModel.DevToolsMetadataEven
t.TracingSessionIdForWorker) { |
| 283 workersDevToolsMetadataEvents.push(event); | 283 workersDevToolsMetadataEvents.push(event); |
| 284 } else if (event.name === WebInspector.TimelineModel.DevToolsMetadataEvent
.TracingStartedInBrowser) { | 284 } else if (event.name === TimelineModel.TimelineModel.DevToolsMetadataEven
t.TracingStartedInBrowser) { |
| 285 console.assert(!this._mainFrameNodeId, 'Multiple sessions in trace'); | 285 console.assert(!this._mainFrameNodeId, 'Multiple sessions in trace'); |
| 286 this._mainFrameNodeId = event.args['frameTreeNodeId']; | 286 this._mainFrameNodeId = event.args['frameTreeNodeId']; |
| 287 } | 287 } |
| 288 } | 288 } |
| 289 if (!pageDevToolsMetadataEvents.length) { | 289 if (!pageDevToolsMetadataEvents.length) { |
| 290 // The trace is probably coming not from DevTools. Make a mock Metadata ev
ent. | 290 // The trace is probably coming not from DevTools. Make a mock Metadata ev
ent. |
| 291 var pageMetaEvent = produceTraceStartedInPage ? this._makeMockPageMetadata
Event(tracingModel) : null; | 291 var pageMetaEvent = produceTraceStartedInPage ? this._makeMockPageMetadata
Event(tracingModel) : null; |
| 292 if (!pageMetaEvent) { | 292 if (!pageMetaEvent) { |
| 293 console.error(WebInspector.TimelineModel.DevToolsMetadataEvent.TracingSt
artedInPage + ' event not found.'); | 293 console.error(TimelineModel.TimelineModel.DevToolsMetadataEvent.TracingS
tartedInPage + ' event not found.'); |
| 294 return {page: [], workers: []}; | 294 return {page: [], workers: []}; |
| 295 } | 295 } |
| 296 pageDevToolsMetadataEvents.push(pageMetaEvent); | 296 pageDevToolsMetadataEvents.push(pageMetaEvent); |
| 297 } | 297 } |
| 298 var sessionId = | 298 var sessionId = |
| 299 pageDevToolsMetadataEvents[0].args['sessionId'] || pageDevToolsMetadataE
vents[0].args['data']['sessionId']; | 299 pageDevToolsMetadataEvents[0].args['sessionId'] || pageDevToolsMetadataE
vents[0].args['data']['sessionId']; |
| 300 this._sessionId = sessionId; | 300 this._sessionId = sessionId; |
| 301 | 301 |
| 302 var mismatchingIds = new Set(); | 302 var mismatchingIds = new Set(); |
| 303 /** | 303 /** |
| 304 * @param {!WebInspector.TracingModel.Event} event | 304 * @param {!SDK.TracingModel.Event} event |
| 305 * @return {boolean} | 305 * @return {boolean} |
| 306 */ | 306 */ |
| 307 function checkSessionId(event) { | 307 function checkSessionId(event) { |
| 308 var args = event.args; | 308 var args = event.args; |
| 309 // FIXME: put sessionId into args["data"] for TracingStartedInPage event. | 309 // FIXME: put sessionId into args["data"] for TracingStartedInPage event. |
| 310 if (args['data']) | 310 if (args['data']) |
| 311 args = args['data']; | 311 args = args['data']; |
| 312 var id = args['sessionId']; | 312 var id = args['sessionId']; |
| 313 if (id === sessionId) | 313 if (id === sessionId) |
| 314 return true; | 314 return true; |
| 315 mismatchingIds.add(id); | 315 mismatchingIds.add(id); |
| 316 return false; | 316 return false; |
| 317 } | 317 } |
| 318 var result = { | 318 var result = { |
| 319 page: pageDevToolsMetadataEvents.filter(checkSessionId).sort(WebInspector.
TracingModel.Event.compareStartTime), | 319 page: pageDevToolsMetadataEvents.filter(checkSessionId).sort(SDK.TracingMo
del.Event.compareStartTime), |
| 320 workers: | 320 workers: |
| 321 workersDevToolsMetadataEvents.filter(checkSessionId).sort(WebInspector
.TracingModel.Event.compareStartTime) | 321 workersDevToolsMetadataEvents.filter(checkSessionId).sort(SDK.TracingM
odel.Event.compareStartTime) |
| 322 }; | 322 }; |
| 323 if (mismatchingIds.size) | 323 if (mismatchingIds.size) |
| 324 WebInspector.console.error( | 324 Common.console.error( |
| 325 'Timeline recording was started in more than one page simultaneously.
Session id mismatch: ' + | 325 'Timeline recording was started in more than one page simultaneously.
Session id mismatch: ' + |
| 326 this._sessionId + ' and ' + mismatchingIds.valuesArray() + '.'); | 326 this._sessionId + ' and ' + mismatchingIds.valuesArray() + '.'); |
| 327 return result; | 327 return result; |
| 328 } | 328 } |
| 329 | 329 |
| 330 /** | 330 /** |
| 331 * @param {!WebInspector.TracingModel} tracingModel | 331 * @param {!SDK.TracingModel} tracingModel |
| 332 * @return {?WebInspector.TracingModel.Event} | 332 * @return {?SDK.TracingModel.Event} |
| 333 */ | 333 */ |
| 334 _makeMockPageMetadataEvent(tracingModel) { | 334 _makeMockPageMetadataEvent(tracingModel) { |
| 335 var rendererMainThreadName = WebInspector.TimelineModel.RendererMainThreadNa
me; | 335 var rendererMainThreadName = TimelineModel.TimelineModel.RendererMainThreadN
ame; |
| 336 // FIXME: pick up the first renderer process for now. | 336 // FIXME: pick up the first renderer process for now. |
| 337 var process = tracingModel.sortedProcesses().filter(function(p) { | 337 var process = tracingModel.sortedProcesses().filter(function(p) { |
| 338 return p.threadByName(rendererMainThreadName); | 338 return p.threadByName(rendererMainThreadName); |
| 339 })[0]; | 339 })[0]; |
| 340 var thread = process && process.threadByName(rendererMainThreadName); | 340 var thread = process && process.threadByName(rendererMainThreadName); |
| 341 if (!thread) | 341 if (!thread) |
| 342 return null; | 342 return null; |
| 343 var pageMetaEvent = new WebInspector.TracingModel.Event( | 343 var pageMetaEvent = new SDK.TracingModel.Event( |
| 344 WebInspector.TracingModel.DevToolsMetadataEventCategory, | 344 SDK.TracingModel.DevToolsMetadataEventCategory, |
| 345 WebInspector.TimelineModel.DevToolsMetadataEvent.TracingStartedInPage, W
ebInspector.TracingModel.Phase.Metadata, | 345 TimelineModel.TimelineModel.DevToolsMetadataEvent.TracingStartedInPage,
SDK.TracingModel.Phase.Metadata, |
| 346 tracingModel.minimumRecordTime(), thread); | 346 tracingModel.minimumRecordTime(), thread); |
| 347 pageMetaEvent.addArgs({'data': {'sessionId': 'mockSessionId'}}); | 347 pageMetaEvent.addArgs({'data': {'sessionId': 'mockSessionId'}}); |
| 348 return pageMetaEvent; | 348 return pageMetaEvent; |
| 349 } | 349 } |
| 350 | 350 |
| 351 _insertFirstPaintEvent() { | 351 _insertFirstPaintEvent() { |
| 352 if (!this._firstCompositeLayers) | 352 if (!this._firstCompositeLayers) |
| 353 return; | 353 return; |
| 354 | 354 |
| 355 // First Paint is actually a DrawFrame that happened after first CompositeLa
yers following last CommitLoadEvent. | 355 // First Paint is actually a DrawFrame that happened after first CompositeLa
yers following last CommitLoadEvent. |
| 356 var recordTypes = WebInspector.TimelineModel.RecordType; | 356 var recordTypes = TimelineModel.TimelineModel.RecordType; |
| 357 var i = this._inspectedTargetEvents.lowerBound( | 357 var i = this._inspectedTargetEvents.lowerBound( |
| 358 this._firstCompositeLayers, WebInspector.TracingModel.Event.compareStart
Time); | 358 this._firstCompositeLayers, SDK.TracingModel.Event.compareStartTime); |
| 359 for (; i < this._inspectedTargetEvents.length && this._inspectedTargetEvents
[i].name !== recordTypes.DrawFrame; | 359 for (; i < this._inspectedTargetEvents.length && this._inspectedTargetEvents
[i].name !== recordTypes.DrawFrame; |
| 360 ++i) { | 360 ++i) { |
| 361 } | 361 } |
| 362 if (i >= this._inspectedTargetEvents.length) | 362 if (i >= this._inspectedTargetEvents.length) |
| 363 return; | 363 return; |
| 364 var drawFrameEvent = this._inspectedTargetEvents[i]; | 364 var drawFrameEvent = this._inspectedTargetEvents[i]; |
| 365 var firstPaintEvent = new WebInspector.TracingModel.Event( | 365 var firstPaintEvent = new SDK.TracingModel.Event( |
| 366 drawFrameEvent.categoriesString, recordTypes.MarkFirstPaint, WebInspecto
r.TracingModel.Phase.Instant, | 366 drawFrameEvent.categoriesString, recordTypes.MarkFirstPaint, SDK.Tracing
Model.Phase.Instant, |
| 367 drawFrameEvent.startTime, drawFrameEvent.thread); | 367 drawFrameEvent.startTime, drawFrameEvent.thread); |
| 368 this._mainThreadEvents.splice( | 368 this._mainThreadEvents.splice( |
| 369 this._mainThreadEvents.lowerBound(firstPaintEvent, WebInspector.TracingM
odel.Event.compareStartTime), 0, | 369 this._mainThreadEvents.lowerBound(firstPaintEvent, SDK.TracingModel.Even
t.compareStartTime), 0, |
| 370 firstPaintEvent); | 370 firstPaintEvent); |
| 371 var firstPaintRecord = new WebInspector.TimelineModel.Record(firstPaintEvent
); | 371 var firstPaintRecord = new TimelineModel.TimelineModel.Record(firstPaintEven
t); |
| 372 this._eventDividerRecords.splice( | 372 this._eventDividerRecords.splice( |
| 373 this._eventDividerRecords.lowerBound(firstPaintRecord, WebInspector.Time
lineModel.Record._compareStartTime), 0, | 373 this._eventDividerRecords.lowerBound(firstPaintRecord, TimelineModel.Tim
elineModel.Record._compareStartTime), 0, |
| 374 firstPaintRecord); | 374 firstPaintRecord); |
| 375 } | 375 } |
| 376 | 376 |
| 377 /** | 377 /** |
| 378 * @param {!WebInspector.TracingModel} tracingModel | 378 * @param {!SDK.TracingModel} tracingModel |
| 379 */ | 379 */ |
| 380 _processBrowserEvents(tracingModel) { | 380 _processBrowserEvents(tracingModel) { |
| 381 var browserMain = WebInspector.TracingModel.browserMainThread(tracingModel); | 381 var browserMain = SDK.TracingModel.browserMainThread(tracingModel); |
| 382 if (!browserMain) | 382 if (!browserMain) |
| 383 return; | 383 return; |
| 384 | 384 |
| 385 // Disregard regular events, we don't need them yet, but still process to ge
t proper metadata. | 385 // Disregard regular events, we don't need them yet, but still process to ge
t proper metadata. |
| 386 browserMain.events().forEach(this._processBrowserEvent, this); | 386 browserMain.events().forEach(this._processBrowserEvent, this); |
| 387 /** @type {!Map<!WebInspector.TimelineModel.AsyncEventGroup, !Array<!WebInsp
ector.TracingModel.AsyncEvent>>} */ | 387 /** @type {!Map<!TimelineModel.TimelineModel.AsyncEventGroup, !Array<!SDK.Tr
acingModel.AsyncEvent>>} */ |
| 388 var asyncEventsByGroup = new Map(); | 388 var asyncEventsByGroup = new Map(); |
| 389 this._processAsyncEvents(asyncEventsByGroup, browserMain.asyncEvents()); | 389 this._processAsyncEvents(asyncEventsByGroup, browserMain.asyncEvents()); |
| 390 this._mergeAsyncEvents(this._mainThreadAsyncEventsByGroup, asyncEventsByGrou
p); | 390 this._mergeAsyncEvents(this._mainThreadAsyncEventsByGroup, asyncEventsByGrou
p); |
| 391 } | 391 } |
| 392 | 392 |
| 393 _buildTimelineRecords() { | 393 _buildTimelineRecords() { |
| 394 var topLevelRecords = this._buildTimelineRecordsForThread(this.mainThreadEve
nts()); | 394 var topLevelRecords = this._buildTimelineRecordsForThread(this.mainThreadEve
nts()); |
| 395 for (var i = 0; i < topLevelRecords.length; i++) { | 395 for (var i = 0; i < topLevelRecords.length; i++) { |
| 396 var record = topLevelRecords[i]; | 396 var record = topLevelRecords[i]; |
| 397 if (WebInspector.TracingModel.isTopLevelEvent(record.traceEvent())) | 397 if (SDK.TracingModel.isTopLevelEvent(record.traceEvent())) |
| 398 this._mainThreadTasks.push(record); | 398 this._mainThreadTasks.push(record); |
| 399 } | 399 } |
| 400 | 400 |
| 401 /** | 401 /** |
| 402 * @param {!WebInspector.TimelineModel.VirtualThread} virtualThread | 402 * @param {!TimelineModel.TimelineModel.VirtualThread} virtualThread |
| 403 * @this {!WebInspector.TimelineModel} | 403 * @this {!TimelineModel.TimelineModel} |
| 404 */ | 404 */ |
| 405 function processVirtualThreadEvents(virtualThread) { | 405 function processVirtualThreadEvents(virtualThread) { |
| 406 var threadRecords = this._buildTimelineRecordsForThread(virtualThread.even
ts); | 406 var threadRecords = this._buildTimelineRecordsForThread(virtualThread.even
ts); |
| 407 topLevelRecords = | 407 topLevelRecords = |
| 408 topLevelRecords.mergeOrdered(threadRecords, WebInspector.TimelineModel
.Record._compareStartTime); | 408 topLevelRecords.mergeOrdered(threadRecords, TimelineModel.TimelineMode
l.Record._compareStartTime); |
| 409 } | 409 } |
| 410 this.virtualThreads().forEach(processVirtualThreadEvents.bind(this)); | 410 this.virtualThreads().forEach(processVirtualThreadEvents.bind(this)); |
| 411 this._records = topLevelRecords; | 411 this._records = topLevelRecords; |
| 412 } | 412 } |
| 413 | 413 |
| 414 /** | 414 /** |
| 415 * @param {!WebInspector.TracingModel} tracingModel | 415 * @param {!SDK.TracingModel} tracingModel |
| 416 */ | 416 */ |
| 417 _buildGPUEvents(tracingModel) { | 417 _buildGPUEvents(tracingModel) { |
| 418 var thread = tracingModel.threadByName('GPU Process', 'CrGpuMain'); | 418 var thread = tracingModel.threadByName('GPU Process', 'CrGpuMain'); |
| 419 if (!thread) | 419 if (!thread) |
| 420 return; | 420 return; |
| 421 var gpuEventName = WebInspector.TimelineModel.RecordType.GPUTask; | 421 var gpuEventName = TimelineModel.TimelineModel.RecordType.GPUTask; |
| 422 this._gpuEvents = thread.events().filter(event => event.name === gpuEventNam
e); | 422 this._gpuEvents = thread.events().filter(event => event.name === gpuEventNam
e); |
| 423 } | 423 } |
| 424 | 424 |
| 425 /** | 425 /** |
| 426 * @param {!Array.<!WebInspector.TracingModel.Event>} threadEvents | 426 * @param {!Array.<!SDK.TracingModel.Event>} threadEvents |
| 427 * @return {!Array.<!WebInspector.TimelineModel.Record>} | 427 * @return {!Array.<!TimelineModel.TimelineModel.Record>} |
| 428 */ | 428 */ |
| 429 _buildTimelineRecordsForThread(threadEvents) { | 429 _buildTimelineRecordsForThread(threadEvents) { |
| 430 var recordStack = []; | 430 var recordStack = []; |
| 431 var topLevelRecords = []; | 431 var topLevelRecords = []; |
| 432 | 432 |
| 433 for (var i = 0, size = threadEvents.length; i < size; ++i) { | 433 for (var i = 0, size = threadEvents.length; i < size; ++i) { |
| 434 var event = threadEvents[i]; | 434 var event = threadEvents[i]; |
| 435 for (var top = recordStack.peekLast(); top && top._event.endTime <= event.
startTime; top = recordStack.peekLast()) | 435 for (var top = recordStack.peekLast(); top && top._event.endTime <= event.
startTime; top = recordStack.peekLast()) |
| 436 recordStack.pop(); | 436 recordStack.pop(); |
| 437 if (event.phase === WebInspector.TracingModel.Phase.AsyncEnd || | 437 if (event.phase === SDK.TracingModel.Phase.AsyncEnd || |
| 438 event.phase === WebInspector.TracingModel.Phase.NestableAsyncEnd) | 438 event.phase === SDK.TracingModel.Phase.NestableAsyncEnd) |
| 439 continue; | 439 continue; |
| 440 var parentRecord = recordStack.peekLast(); | 440 var parentRecord = recordStack.peekLast(); |
| 441 // Maintain the back-end logic of old timeline, skip console.time() / cons
ole.timeEnd() that are not properly nested. | 441 // Maintain the back-end logic of old timeline, skip console.time() / cons
ole.timeEnd() that are not properly nested. |
| 442 if (WebInspector.TracingModel.isAsyncBeginPhase(event.phase) && parentReco
rd && | 442 if (SDK.TracingModel.isAsyncBeginPhase(event.phase) && parentRecord && |
| 443 event.endTime > parentRecord._event.endTime) | 443 event.endTime > parentRecord._event.endTime) |
| 444 continue; | 444 continue; |
| 445 var record = new WebInspector.TimelineModel.Record(event); | 445 var record = new TimelineModel.TimelineModel.Record(event); |
| 446 if (WebInspector.TimelineModel.isMarkerEvent(event)) | 446 if (TimelineModel.TimelineModel.isMarkerEvent(event)) |
| 447 this._eventDividerRecords.push(record); | 447 this._eventDividerRecords.push(record); |
| 448 if (!this._eventFilter.accept(event) && !WebInspector.TracingModel.isTopLe
velEvent(event)) | 448 if (!this._eventFilter.accept(event) && !SDK.TracingModel.isTopLevelEvent(
event)) |
| 449 continue; | 449 continue; |
| 450 if (parentRecord) | 450 if (parentRecord) |
| 451 parentRecord._addChild(record); | 451 parentRecord._addChild(record); |
| 452 else | 452 else |
| 453 topLevelRecords.push(record); | 453 topLevelRecords.push(record); |
| 454 if (event.endTime) | 454 if (event.endTime) |
| 455 recordStack.push(record); | 455 recordStack.push(record); |
| 456 } | 456 } |
| 457 | 457 |
| 458 return topLevelRecords; | 458 return topLevelRecords; |
| 459 } | 459 } |
| 460 | 460 |
| 461 _resetProcessingState() { | 461 _resetProcessingState() { |
| 462 this._asyncEventTracker = new WebInspector.TimelineAsyncEventTracker(); | 462 this._asyncEventTracker = new TimelineModel.TimelineAsyncEventTracker(); |
| 463 this._invalidationTracker = new WebInspector.InvalidationTracker(); | 463 this._invalidationTracker = new TimelineModel.InvalidationTracker(); |
| 464 this._layoutInvalidate = {}; | 464 this._layoutInvalidate = {}; |
| 465 this._lastScheduleStyleRecalculation = {}; | 465 this._lastScheduleStyleRecalculation = {}; |
| 466 this._paintImageEventByPixelRefId = {}; | 466 this._paintImageEventByPixelRefId = {}; |
| 467 this._lastPaintForLayer = {}; | 467 this._lastPaintForLayer = {}; |
| 468 this._lastRecalculateStylesEvent = null; | 468 this._lastRecalculateStylesEvent = null; |
| 469 this._currentScriptEvent = null; | 469 this._currentScriptEvent = null; |
| 470 this._eventStack = []; | 470 this._eventStack = []; |
| 471 this._hadCommitLoad = false; | 471 this._hadCommitLoad = false; |
| 472 this._firstCompositeLayers = null; | 472 this._firstCompositeLayers = null; |
| 473 /** @type {!Set<string>} */ | 473 /** @type {!Set<string>} */ |
| 474 this._knownInputEvents = new Set(); | 474 this._knownInputEvents = new Set(); |
| 475 this._currentPage = null; | 475 this._currentPage = null; |
| 476 } | 476 } |
| 477 | 477 |
| 478 /** | 478 /** |
| 479 * @param {!WebInspector.TracingModel} tracingModel | 479 * @param {!SDK.TracingModel} tracingModel |
| 480 * @param {!WebInspector.TracingModel.Thread} thread | 480 * @param {!SDK.TracingModel.Thread} thread |
| 481 * @return {?WebInspector.CPUProfileDataModel} | 481 * @return {?SDK.CPUProfileDataModel} |
| 482 */ | 482 */ |
| 483 _extractCpuProfile(tracingModel, thread) { | 483 _extractCpuProfile(tracingModel, thread) { |
| 484 var events = thread.events(); | 484 var events = thread.events(); |
| 485 var cpuProfile; | 485 var cpuProfile; |
| 486 | 486 |
| 487 // Check for legacy CpuProfile event format first. | 487 // Check for legacy CpuProfile event format first. |
| 488 var cpuProfileEvent = events.peekLast(); | 488 var cpuProfileEvent = events.peekLast(); |
| 489 if (cpuProfileEvent && cpuProfileEvent.name === WebInspector.TimelineModel.R
ecordType.CpuProfile) { | 489 if (cpuProfileEvent && cpuProfileEvent.name === TimelineModel.TimelineModel.
RecordType.CpuProfile) { |
| 490 var eventData = cpuProfileEvent.args['data']; | 490 var eventData = cpuProfileEvent.args['data']; |
| 491 cpuProfile = /** @type {?Protocol.Profiler.Profile} */ (eventData && event
Data['cpuProfile']); | 491 cpuProfile = /** @type {?Protocol.Profiler.Profile} */ (eventData && event
Data['cpuProfile']); |
| 492 } | 492 } |
| 493 | 493 |
| 494 if (!cpuProfile) { | 494 if (!cpuProfile) { |
| 495 cpuProfileEvent = events.find(e => e.name === WebInspector.TimelineModel.R
ecordType.Profile); | 495 cpuProfileEvent = events.find(e => e.name === TimelineModel.TimelineModel.
RecordType.Profile); |
| 496 if (!cpuProfileEvent) | 496 if (!cpuProfileEvent) |
| 497 return null; | 497 return null; |
| 498 var profileGroup = tracingModel.profileGroup(cpuProfileEvent.id); | 498 var profileGroup = tracingModel.profileGroup(cpuProfileEvent.id); |
| 499 if (!profileGroup) { | 499 if (!profileGroup) { |
| 500 WebInspector.console.error('Invalid CPU profile format.'); | 500 Common.console.error('Invalid CPU profile format.'); |
| 501 return null; | 501 return null; |
| 502 } | 502 } |
| 503 cpuProfile = /** @type {!Protocol.Profiler.Profile} */ ( | 503 cpuProfile = /** @type {!Protocol.Profiler.Profile} */ ( |
| 504 {startTime: cpuProfileEvent.args['data']['startTime'], endTime: 0, nod
es: [], samples: [], timeDeltas: []}); | 504 {startTime: cpuProfileEvent.args['data']['startTime'], endTime: 0, nod
es: [], samples: [], timeDeltas: []}); |
| 505 for (var profileEvent of profileGroup.children) { | 505 for (var profileEvent of profileGroup.children) { |
| 506 var eventData = profileEvent.args['data']; | 506 var eventData = profileEvent.args['data']; |
| 507 if ('startTime' in eventData) | 507 if ('startTime' in eventData) |
| 508 cpuProfile.startTime = eventData['startTime']; | 508 cpuProfile.startTime = eventData['startTime']; |
| 509 if ('endTime' in eventData) | 509 if ('endTime' in eventData) |
| 510 cpuProfile.endTime = eventData['endTime']; | 510 cpuProfile.endTime = eventData['endTime']; |
| 511 var nodesAndSamples = eventData['cpuProfile'] || {}; | 511 var nodesAndSamples = eventData['cpuProfile'] || {}; |
| 512 cpuProfile.nodes.pushAll(nodesAndSamples['nodes'] || []); | 512 cpuProfile.nodes.pushAll(nodesAndSamples['nodes'] || []); |
| 513 cpuProfile.samples.pushAll(nodesAndSamples['samples'] || []); | 513 cpuProfile.samples.pushAll(nodesAndSamples['samples'] || []); |
| 514 cpuProfile.timeDeltas.pushAll(eventData['timeDeltas'] || []); | 514 cpuProfile.timeDeltas.pushAll(eventData['timeDeltas'] || []); |
| 515 if (cpuProfile.samples.length !== cpuProfile.timeDeltas.length) { | 515 if (cpuProfile.samples.length !== cpuProfile.timeDeltas.length) { |
| 516 WebInspector.console.error('Failed to parse CPU profile.'); | 516 Common.console.error('Failed to parse CPU profile.'); |
| 517 return null; | 517 return null; |
| 518 } | 518 } |
| 519 } | 519 } |
| 520 if (!cpuProfile.endTime) | 520 if (!cpuProfile.endTime) |
| 521 cpuProfile.endTime = cpuProfile.timeDeltas.reduce((x, y) => x + y, cpuPr
ofile.startTime); | 521 cpuProfile.endTime = cpuProfile.timeDeltas.reduce((x, y) => x + y, cpuPr
ofile.startTime); |
| 522 } | 522 } |
| 523 | 523 |
| 524 try { | 524 try { |
| 525 var jsProfileModel = new WebInspector.CPUProfileDataModel(cpuProfile); | 525 var jsProfileModel = new SDK.CPUProfileDataModel(cpuProfile); |
| 526 this._cpuProfiles.push(jsProfileModel); | 526 this._cpuProfiles.push(jsProfileModel); |
| 527 return jsProfileModel; | 527 return jsProfileModel; |
| 528 } catch (e) { | 528 } catch (e) { |
| 529 WebInspector.console.error('Failed to parse CPU profile.'); | 529 Common.console.error('Failed to parse CPU profile.'); |
| 530 } | 530 } |
| 531 return null; | 531 return null; |
| 532 } | 532 } |
| 533 | 533 |
| 534 /** | 534 /** |
| 535 * @param {!WebInspector.TracingModel} tracingModel | 535 * @param {!SDK.TracingModel} tracingModel |
| 536 * @param {!WebInspector.TracingModel.Thread} thread | 536 * @param {!SDK.TracingModel.Thread} thread |
| 537 * @return {!Array<!WebInspector.TracingModel.Event>} | 537 * @return {!Array<!SDK.TracingModel.Event>} |
| 538 */ | 538 */ |
| 539 _injectJSFrameEvents(tracingModel, thread) { | 539 _injectJSFrameEvents(tracingModel, thread) { |
| 540 var jsProfileModel = this._extractCpuProfile(tracingModel, thread); | 540 var jsProfileModel = this._extractCpuProfile(tracingModel, thread); |
| 541 var events = thread.events(); | 541 var events = thread.events(); |
| 542 var jsSamples = jsProfileModel ? | 542 var jsSamples = jsProfileModel ? |
| 543 WebInspector.TimelineJSProfileProcessor.generateTracingEventsFromCpuProf
ile(jsProfileModel, thread) : | 543 TimelineModel.TimelineJSProfileProcessor.generateTracingEventsFromCpuPro
file(jsProfileModel, thread) : |
| 544 null; | 544 null; |
| 545 if (jsSamples && jsSamples.length) | 545 if (jsSamples && jsSamples.length) |
| 546 events = events.mergeOrdered(jsSamples, WebInspector.TracingModel.Event.or
deredCompareStartTime); | 546 events = events.mergeOrdered(jsSamples, SDK.TracingModel.Event.orderedComp
areStartTime); |
| 547 if (jsSamples || events.some(e => e.name === WebInspector.TimelineModel.Reco
rdType.JSSample)) { | 547 if (jsSamples || events.some(e => e.name === TimelineModel.TimelineModel.Rec
ordType.JSSample)) { |
| 548 var jsFrameEvents = WebInspector.TimelineJSProfileProcessor.generateJSFram
eEvents(events); | 548 var jsFrameEvents = TimelineModel.TimelineJSProfileProcessor.generateJSFra
meEvents(events); |
| 549 if (jsFrameEvents && jsFrameEvents.length) | 549 if (jsFrameEvents && jsFrameEvents.length) |
| 550 events = jsFrameEvents.mergeOrdered(events, WebInspector.TracingModel.Ev
ent.orderedCompareStartTime); | 550 events = jsFrameEvents.mergeOrdered(events, SDK.TracingModel.Event.order
edCompareStartTime); |
| 551 } | 551 } |
| 552 return events; | 552 return events; |
| 553 } | 553 } |
| 554 | 554 |
| 555 /** | 555 /** |
| 556 * @param {!WebInspector.TracingModel} tracingModel | 556 * @param {!SDK.TracingModel} tracingModel |
| 557 * @param {number} startTime | 557 * @param {number} startTime |
| 558 * @param {number} endTime | 558 * @param {number} endTime |
| 559 * @param {!WebInspector.TracingModel.Thread} thread | 559 * @param {!SDK.TracingModel.Thread} thread |
| 560 * @param {boolean} isMainThread | 560 * @param {boolean} isMainThread |
| 561 */ | 561 */ |
| 562 _processThreadEvents(tracingModel, startTime, endTime, thread, isMainThread) { | 562 _processThreadEvents(tracingModel, startTime, endTime, thread, isMainThread) { |
| 563 var events = this._injectJSFrameEvents(tracingModel, thread); | 563 var events = this._injectJSFrameEvents(tracingModel, thread); |
| 564 var asyncEvents = thread.asyncEvents(); | 564 var asyncEvents = thread.asyncEvents(); |
| 565 var groupByFrame = isMainThread && Runtime.experiments.isEnabled('timelinePe
rFrameTrack'); | 565 var groupByFrame = isMainThread && Runtime.experiments.isEnabled('timelinePe
rFrameTrack'); |
| 566 | 566 |
| 567 var threadEvents; | 567 var threadEvents; |
| 568 var threadAsyncEventsByGroup; | 568 var threadAsyncEventsByGroup; |
| 569 if (isMainThread) { | 569 if (isMainThread) { |
| 570 threadEvents = this._mainThreadEvents; | 570 threadEvents = this._mainThreadEvents; |
| 571 threadAsyncEventsByGroup = this._mainThreadAsyncEventsByGroup; | 571 threadAsyncEventsByGroup = this._mainThreadAsyncEventsByGroup; |
| 572 } else { | 572 } else { |
| 573 var virtualThread = new WebInspector.TimelineModel.VirtualThread(thread.na
me()); | 573 var virtualThread = new TimelineModel.TimelineModel.VirtualThread(thread.n
ame()); |
| 574 this._virtualThreads.push(virtualThread); | 574 this._virtualThreads.push(virtualThread); |
| 575 threadEvents = virtualThread.events; | 575 threadEvents = virtualThread.events; |
| 576 threadAsyncEventsByGroup = virtualThread.asyncEventsByGroup; | 576 threadAsyncEventsByGroup = virtualThread.asyncEventsByGroup; |
| 577 } | 577 } |
| 578 | 578 |
| 579 this._eventStack = []; | 579 this._eventStack = []; |
| 580 var i = events.lowerBound(startTime, (time, event) => time - event.startTime
); | 580 var i = events.lowerBound(startTime, (time, event) => time - event.startTime
); |
| 581 var length = events.length; | 581 var length = events.length; |
| 582 for (; i < length; i++) { | 582 for (; i < length; i++) { |
| 583 var event = events[i]; | 583 var event = events[i]; |
| 584 if (endTime && event.startTime >= endTime) | 584 if (endTime && event.startTime >= endTime) |
| 585 break; | 585 break; |
| 586 if (!this._processEvent(event)) | 586 if (!this._processEvent(event)) |
| 587 continue; | 587 continue; |
| 588 if (groupByFrame) { | 588 if (groupByFrame) { |
| 589 var frameId = WebInspector.TimelineData.forEvent(event).frameId; | 589 var frameId = TimelineModel.TimelineData.forEvent(event).frameId; |
| 590 var pageFrame = frameId && this._pageFrames.get(frameId); | 590 var pageFrame = frameId && this._pageFrames.get(frameId); |
| 591 var isMainFrame = !frameId || !pageFrame || !pageFrame.parent; | 591 var isMainFrame = !frameId || !pageFrame || !pageFrame.parent; |
| 592 if (isMainFrame) | 592 if (isMainFrame) |
| 593 frameId = WebInspector.TimelineModel.PageFrame.mainFrameId; | 593 frameId = TimelineModel.TimelineModel.PageFrame.mainFrameId; |
| 594 var frameEvents = this._eventsByFrame.get(frameId); | 594 var frameEvents = this._eventsByFrame.get(frameId); |
| 595 if (!frameEvents) { | 595 if (!frameEvents) { |
| 596 frameEvents = []; | 596 frameEvents = []; |
| 597 this._eventsByFrame.set(frameId, frameEvents); | 597 this._eventsByFrame.set(frameId, frameEvents); |
| 598 } | 598 } |
| 599 frameEvents.push(event); | 599 frameEvents.push(event); |
| 600 } | 600 } |
| 601 threadEvents.push(event); | 601 threadEvents.push(event); |
| 602 this._inspectedTargetEvents.push(event); | 602 this._inspectedTargetEvents.push(event); |
| 603 } | 603 } |
| 604 this._processAsyncEvents(threadAsyncEventsByGroup, asyncEvents, startTime, e
ndTime); | 604 this._processAsyncEvents(threadAsyncEventsByGroup, asyncEvents, startTime, e
ndTime); |
| 605 // Pretend the compositor's async events are on the main thread. | 605 // Pretend the compositor's async events are on the main thread. |
| 606 if (thread.name() === 'Compositor') { | 606 if (thread.name() === 'Compositor') { |
| 607 this._mergeAsyncEvents(this._mainThreadAsyncEventsByGroup, threadAsyncEven
tsByGroup); | 607 this._mergeAsyncEvents(this._mainThreadAsyncEventsByGroup, threadAsyncEven
tsByGroup); |
| 608 threadAsyncEventsByGroup.clear(); | 608 threadAsyncEventsByGroup.clear(); |
| 609 } | 609 } |
| 610 } | 610 } |
| 611 | 611 |
| 612 /** | 612 /** |
| 613 * @param {!Map<!WebInspector.TimelineModel.AsyncEventGroup, !Array<!WebInspec
tor.TracingModel.AsyncEvent>>} asyncEventsByGroup | 613 * @param {!Map<!TimelineModel.TimelineModel.AsyncEventGroup, !Array<!SDK.Trac
ingModel.AsyncEvent>>} asyncEventsByGroup |
| 614 * @param {!Array<!WebInspector.TracingModel.AsyncEvent>} asyncEvents | 614 * @param {!Array<!SDK.TracingModel.AsyncEvent>} asyncEvents |
| 615 * @param {number=} startTime | 615 * @param {number=} startTime |
| 616 * @param {number=} endTime | 616 * @param {number=} endTime |
| 617 */ | 617 */ |
| 618 _processAsyncEvents(asyncEventsByGroup, asyncEvents, startTime, endTime) { | 618 _processAsyncEvents(asyncEventsByGroup, asyncEvents, startTime, endTime) { |
| 619 var i = startTime ? asyncEvents.lowerBound(startTime, function(time, asyncEv
ent) { | 619 var i = startTime ? asyncEvents.lowerBound(startTime, function(time, asyncEv
ent) { |
| 620 return time - asyncEvent.startTime; | 620 return time - asyncEvent.startTime; |
| 621 }) : 0; | 621 }) : 0; |
| 622 for (; i < asyncEvents.length; ++i) { | 622 for (; i < asyncEvents.length; ++i) { |
| 623 var asyncEvent = asyncEvents[i]; | 623 var asyncEvent = asyncEvents[i]; |
| 624 if (endTime && asyncEvent.startTime >= endTime) | 624 if (endTime && asyncEvent.startTime >= endTime) |
| 625 break; | 625 break; |
| 626 var asyncGroup = this._processAsyncEvent(asyncEvent); | 626 var asyncGroup = this._processAsyncEvent(asyncEvent); |
| 627 if (!asyncGroup) | 627 if (!asyncGroup) |
| 628 continue; | 628 continue; |
| 629 var groupAsyncEvents = asyncEventsByGroup.get(asyncGroup); | 629 var groupAsyncEvents = asyncEventsByGroup.get(asyncGroup); |
| 630 if (!groupAsyncEvents) { | 630 if (!groupAsyncEvents) { |
| 631 groupAsyncEvents = []; | 631 groupAsyncEvents = []; |
| 632 asyncEventsByGroup.set(asyncGroup, groupAsyncEvents); | 632 asyncEventsByGroup.set(asyncGroup, groupAsyncEvents); |
| 633 } | 633 } |
| 634 groupAsyncEvents.push(asyncEvent); | 634 groupAsyncEvents.push(asyncEvent); |
| 635 } | 635 } |
| 636 } | 636 } |
| 637 | 637 |
| 638 /** | 638 /** |
| 639 * @param {!WebInspector.TracingModel.Event} event | 639 * @param {!SDK.TracingModel.Event} event |
| 640 * @return {boolean} | 640 * @return {boolean} |
| 641 */ | 641 */ |
| 642 _processEvent(event) { | 642 _processEvent(event) { |
| 643 var eventStack = this._eventStack; | 643 var eventStack = this._eventStack; |
| 644 while (eventStack.length && eventStack.peekLast().endTime <= event.startTime
) | 644 while (eventStack.length && eventStack.peekLast().endTime <= event.startTime
) |
| 645 eventStack.pop(); | 645 eventStack.pop(); |
| 646 | 646 |
| 647 var recordTypes = WebInspector.TimelineModel.RecordType; | 647 var recordTypes = TimelineModel.TimelineModel.RecordType; |
| 648 | 648 |
| 649 if (this._currentScriptEvent && event.startTime > this._currentScriptEvent.e
ndTime) | 649 if (this._currentScriptEvent && event.startTime > this._currentScriptEvent.e
ndTime) |
| 650 this._currentScriptEvent = null; | 650 this._currentScriptEvent = null; |
| 651 | 651 |
| 652 var eventData = event.args['data'] || event.args['beginData'] || {}; | 652 var eventData = event.args['data'] || event.args['beginData'] || {}; |
| 653 var timelineData = WebInspector.TimelineData.forEvent(event); | 653 var timelineData = TimelineModel.TimelineData.forEvent(event); |
| 654 if (eventData['stackTrace']) | 654 if (eventData['stackTrace']) |
| 655 timelineData.stackTrace = eventData['stackTrace']; | 655 timelineData.stackTrace = eventData['stackTrace']; |
| 656 if (timelineData.stackTrace && event.name !== recordTypes.JSSample) { | 656 if (timelineData.stackTrace && event.name !== recordTypes.JSSample) { |
| 657 // TraceEvents come with 1-based line & column numbers. The frontend code | 657 // TraceEvents come with 1-based line & column numbers. The frontend code |
| 658 // requires 0-based ones. Adjust the values. | 658 // requires 0-based ones. Adjust the values. |
| 659 for (var i = 0; i < timelineData.stackTrace.length; ++i) { | 659 for (var i = 0; i < timelineData.stackTrace.length; ++i) { |
| 660 --timelineData.stackTrace[i].lineNumber; | 660 --timelineData.stackTrace[i].lineNumber; |
| 661 --timelineData.stackTrace[i].columnNumber; | 661 --timelineData.stackTrace[i].columnNumber; |
| 662 } | 662 } |
| 663 } | 663 } |
| 664 var pageFrameId = WebInspector.TimelineModel.eventFrameId(event); | 664 var pageFrameId = TimelineModel.TimelineModel.eventFrameId(event); |
| 665 if (!pageFrameId && eventStack.length) | 665 if (!pageFrameId && eventStack.length) |
| 666 pageFrameId = WebInspector.TimelineData.forEvent(eventStack.peekLast()).fr
ameId; | 666 pageFrameId = TimelineModel.TimelineData.forEvent(eventStack.peekLast()).f
rameId; |
| 667 timelineData.frameId = pageFrameId || WebInspector.TimelineModel.PageFrame.m
ainFrameId; | 667 timelineData.frameId = pageFrameId || TimelineModel.TimelineModel.PageFrame.
mainFrameId; |
| 668 this._asyncEventTracker.processEvent(event); | 668 this._asyncEventTracker.processEvent(event); |
| 669 switch (event.name) { | 669 switch (event.name) { |
| 670 case recordTypes.ResourceSendRequest: | 670 case recordTypes.ResourceSendRequest: |
| 671 case recordTypes.WebSocketCreate: | 671 case recordTypes.WebSocketCreate: |
| 672 timelineData.setInitiator(eventStack.peekLast() || null); | 672 timelineData.setInitiator(eventStack.peekLast() || null); |
| 673 timelineData.url = eventData['url']; | 673 timelineData.url = eventData['url']; |
| 674 break; | 674 break; |
| 675 | 675 |
| 676 case recordTypes.ScheduleStyleRecalculation: | 676 case recordTypes.ScheduleStyleRecalculation: |
| 677 this._lastScheduleStyleRecalculation[eventData['frame']] = event; | 677 this._lastScheduleStyleRecalculation[eventData['frame']] = event; |
| 678 break; | 678 break; |
| 679 | 679 |
| 680 case recordTypes.UpdateLayoutTree: | 680 case recordTypes.UpdateLayoutTree: |
| 681 case recordTypes.RecalculateStyles: | 681 case recordTypes.RecalculateStyles: |
| 682 this._invalidationTracker.didRecalcStyle(event); | 682 this._invalidationTracker.didRecalcStyle(event); |
| 683 if (event.args['beginData']) | 683 if (event.args['beginData']) |
| 684 timelineData.setInitiator(this._lastScheduleStyleRecalculation[event.a
rgs['beginData']['frame']]); | 684 timelineData.setInitiator(this._lastScheduleStyleRecalculation[event.a
rgs['beginData']['frame']]); |
| 685 this._lastRecalculateStylesEvent = event; | 685 this._lastRecalculateStylesEvent = event; |
| 686 if (this._currentScriptEvent) | 686 if (this._currentScriptEvent) |
| 687 timelineData.warning = WebInspector.TimelineModel.WarningType.ForcedSt
yle; | 687 timelineData.warning = TimelineModel.TimelineModel.WarningType.ForcedS
tyle; |
| 688 break; | 688 break; |
| 689 | 689 |
| 690 case recordTypes.ScheduleStyleInvalidationTracking: | 690 case recordTypes.ScheduleStyleInvalidationTracking: |
| 691 case recordTypes.StyleRecalcInvalidationTracking: | 691 case recordTypes.StyleRecalcInvalidationTracking: |
| 692 case recordTypes.StyleInvalidatorInvalidationTracking: | 692 case recordTypes.StyleInvalidatorInvalidationTracking: |
| 693 case recordTypes.LayoutInvalidationTracking: | 693 case recordTypes.LayoutInvalidationTracking: |
| 694 case recordTypes.LayerInvalidationTracking: | 694 case recordTypes.LayerInvalidationTracking: |
| 695 case recordTypes.PaintInvalidationTracking: | 695 case recordTypes.PaintInvalidationTracking: |
| 696 case recordTypes.ScrollInvalidationTracking: | 696 case recordTypes.ScrollInvalidationTracking: |
| 697 this._invalidationTracker.addInvalidation(new WebInspector.InvalidationT
rackingEvent(event)); | 697 this._invalidationTracker.addInvalidation(new TimelineModel.Invalidation
TrackingEvent(event)); |
| 698 break; | 698 break; |
| 699 | 699 |
| 700 case recordTypes.InvalidateLayout: | 700 case recordTypes.InvalidateLayout: |
| 701 // Consider style recalculation as a reason for layout invalidation, | 701 // Consider style recalculation as a reason for layout invalidation, |
| 702 // but only if we had no earlier layout invalidation records. | 702 // but only if we had no earlier layout invalidation records. |
| 703 var layoutInitator = event; | 703 var layoutInitator = event; |
| 704 var frameId = eventData['frame']; | 704 var frameId = eventData['frame']; |
| 705 if (!this._layoutInvalidate[frameId] && this._lastRecalculateStylesEvent
&& | 705 if (!this._layoutInvalidate[frameId] && this._lastRecalculateStylesEvent
&& |
| 706 this._lastRecalculateStylesEvent.endTime > event.startTime) | 706 this._lastRecalculateStylesEvent.endTime > event.startTime) |
| 707 layoutInitator = WebInspector.TimelineData.forEvent(this._lastRecalcul
ateStylesEvent).initiator(); | 707 layoutInitator = TimelineModel.TimelineData.forEvent(this._lastRecalcu
lateStylesEvent).initiator(); |
| 708 this._layoutInvalidate[frameId] = layoutInitator; | 708 this._layoutInvalidate[frameId] = layoutInitator; |
| 709 break; | 709 break; |
| 710 | 710 |
| 711 case recordTypes.Layout: | 711 case recordTypes.Layout: |
| 712 this._invalidationTracker.didLayout(event); | 712 this._invalidationTracker.didLayout(event); |
| 713 var frameId = event.args['beginData']['frame']; | 713 var frameId = event.args['beginData']['frame']; |
| 714 timelineData.setInitiator(this._layoutInvalidate[frameId]); | 714 timelineData.setInitiator(this._layoutInvalidate[frameId]); |
| 715 // In case we have no closing Layout event, endData is not available. | 715 // In case we have no closing Layout event, endData is not available. |
| 716 if (event.args['endData']) | 716 if (event.args['endData']) |
| 717 timelineData.backendNodeId = event.args['endData']['rootNode']; | 717 timelineData.backendNodeId = event.args['endData']['rootNode']; |
| 718 this._layoutInvalidate[frameId] = null; | 718 this._layoutInvalidate[frameId] = null; |
| 719 if (this._currentScriptEvent) | 719 if (this._currentScriptEvent) |
| 720 timelineData.warning = WebInspector.TimelineModel.WarningType.ForcedLa
yout; | 720 timelineData.warning = TimelineModel.TimelineModel.WarningType.ForcedL
ayout; |
| 721 break; | 721 break; |
| 722 | 722 |
| 723 case recordTypes.FunctionCall: | 723 case recordTypes.FunctionCall: |
| 724 // Compatibility with old format. | 724 // Compatibility with old format. |
| 725 if (typeof eventData['scriptName'] === 'string') | 725 if (typeof eventData['scriptName'] === 'string') |
| 726 eventData['url'] = eventData['scriptName']; | 726 eventData['url'] = eventData['scriptName']; |
| 727 if (typeof eventData['scriptLine'] === 'number') | 727 if (typeof eventData['scriptLine'] === 'number') |
| 728 eventData['lineNumber'] = eventData['scriptLine']; | 728 eventData['lineNumber'] = eventData['scriptLine']; |
| 729 // Fallthrough. | 729 // Fallthrough. |
| 730 case recordTypes.EvaluateScript: | 730 case recordTypes.EvaluateScript: |
| (...skipping 24 matching lines...) Expand all Loading... |
| 755 this._lastPaintForLayer[layerId] = event; | 755 this._lastPaintForLayer[layerId] = event; |
| 756 break; | 756 break; |
| 757 | 757 |
| 758 case recordTypes.DisplayItemListSnapshot: | 758 case recordTypes.DisplayItemListSnapshot: |
| 759 case recordTypes.PictureSnapshot: | 759 case recordTypes.PictureSnapshot: |
| 760 var layerUpdateEvent = this._findAncestorEvent(recordTypes.UpdateLayer); | 760 var layerUpdateEvent = this._findAncestorEvent(recordTypes.UpdateLayer); |
| 761 if (!layerUpdateEvent || layerUpdateEvent.args['layerTreeId'] !== this._
inspectedTargetLayerTreeId) | 761 if (!layerUpdateEvent || layerUpdateEvent.args['layerTreeId'] !== this._
inspectedTargetLayerTreeId) |
| 762 break; | 762 break; |
| 763 var paintEvent = this._lastPaintForLayer[layerUpdateEvent.args['layerId'
]]; | 763 var paintEvent = this._lastPaintForLayer[layerUpdateEvent.args['layerId'
]]; |
| 764 if (paintEvent) | 764 if (paintEvent) |
| 765 WebInspector.TimelineData.forEvent(paintEvent).picture = /** @type {!W
ebInspector.TracingModel.ObjectSnapshot} */ (event); | 765 TimelineModel.TimelineData.forEvent(paintEvent).picture = /** @type {!
SDK.TracingModel.ObjectSnapshot} */ (event); |
| 766 break; | 766 break; |
| 767 | 767 |
| 768 case recordTypes.ScrollLayer: | 768 case recordTypes.ScrollLayer: |
| 769 timelineData.backendNodeId = eventData['nodeId']; | 769 timelineData.backendNodeId = eventData['nodeId']; |
| 770 break; | 770 break; |
| 771 | 771 |
| 772 case recordTypes.PaintImage: | 772 case recordTypes.PaintImage: |
| 773 timelineData.backendNodeId = eventData['nodeId']; | 773 timelineData.backendNodeId = eventData['nodeId']; |
| 774 timelineData.url = eventData['url']; | 774 timelineData.url = eventData['url']; |
| 775 break; | 775 break; |
| 776 | 776 |
| 777 case recordTypes.DecodeImage: | 777 case recordTypes.DecodeImage: |
| 778 case recordTypes.ResizeImage: | 778 case recordTypes.ResizeImage: |
| 779 var paintImageEvent = this._findAncestorEvent(recordTypes.PaintImage); | 779 var paintImageEvent = this._findAncestorEvent(recordTypes.PaintImage); |
| 780 if (!paintImageEvent) { | 780 if (!paintImageEvent) { |
| 781 var decodeLazyPixelRefEvent = this._findAncestorEvent(recordTypes.Deco
deLazyPixelRef); | 781 var decodeLazyPixelRefEvent = this._findAncestorEvent(recordTypes.Deco
deLazyPixelRef); |
| 782 paintImageEvent = decodeLazyPixelRefEvent && | 782 paintImageEvent = decodeLazyPixelRefEvent && |
| 783 this._paintImageEventByPixelRefId[decodeLazyPixelRefEvent.args['La
zyPixelRef']]; | 783 this._paintImageEventByPixelRefId[decodeLazyPixelRefEvent.args['La
zyPixelRef']]; |
| 784 } | 784 } |
| 785 if (!paintImageEvent) | 785 if (!paintImageEvent) |
| 786 break; | 786 break; |
| 787 var paintImageData = WebInspector.TimelineData.forEvent(paintImageEvent)
; | 787 var paintImageData = TimelineModel.TimelineData.forEvent(paintImageEvent
); |
| 788 timelineData.backendNodeId = paintImageData.backendNodeId; | 788 timelineData.backendNodeId = paintImageData.backendNodeId; |
| 789 timelineData.url = paintImageData.url; | 789 timelineData.url = paintImageData.url; |
| 790 break; | 790 break; |
| 791 | 791 |
| 792 case recordTypes.DrawLazyPixelRef: | 792 case recordTypes.DrawLazyPixelRef: |
| 793 var paintImageEvent = this._findAncestorEvent(recordTypes.PaintImage); | 793 var paintImageEvent = this._findAncestorEvent(recordTypes.PaintImage); |
| 794 if (!paintImageEvent) | 794 if (!paintImageEvent) |
| 795 break; | 795 break; |
| 796 this._paintImageEventByPixelRefId[event.args['LazyPixelRef']] = paintIma
geEvent; | 796 this._paintImageEventByPixelRefId[event.args['LazyPixelRef']] = paintIma
geEvent; |
| 797 var paintImageData = WebInspector.TimelineData.forEvent(paintImageEvent)
; | 797 var paintImageData = TimelineModel.TimelineData.forEvent(paintImageEvent
); |
| 798 timelineData.backendNodeId = paintImageData.backendNodeId; | 798 timelineData.backendNodeId = paintImageData.backendNodeId; |
| 799 timelineData.url = paintImageData.url; | 799 timelineData.url = paintImageData.url; |
| 800 break; | 800 break; |
| 801 | 801 |
| 802 case recordTypes.MarkDOMContent: | 802 case recordTypes.MarkDOMContent: |
| 803 case recordTypes.MarkLoad: | 803 case recordTypes.MarkLoad: |
| 804 var page = eventData['page']; | 804 var page = eventData['page']; |
| 805 if (page && page !== this._currentPage) | 805 if (page && page !== this._currentPage) |
| 806 return false; | 806 return false; |
| 807 break; | 807 break; |
| 808 | 808 |
| 809 case recordTypes.CommitLoad: | 809 case recordTypes.CommitLoad: |
| 810 var frameId = WebInspector.TimelineModel.eventFrameId(event); | 810 var frameId = TimelineModel.TimelineModel.eventFrameId(event); |
| 811 var pageFrame = this._pageFrames.get(frameId); | 811 var pageFrame = this._pageFrames.get(frameId); |
| 812 if (pageFrame) | 812 if (pageFrame) |
| 813 pageFrame.update(eventData.name || '', eventData.url || ''); | 813 pageFrame.update(eventData.name || '', eventData.url || ''); |
| 814 else | 814 else |
| 815 this._addPageFrame(event, eventData); | 815 this._addPageFrame(event, eventData); |
| 816 var page = eventData['page']; | 816 var page = eventData['page']; |
| 817 if (page && page !== this._currentPage) | 817 if (page && page !== this._currentPage) |
| 818 return false; | 818 return false; |
| 819 if (!eventData['isMainFrame']) | 819 if (!eventData['isMainFrame']) |
| 820 break; | 820 break; |
| 821 this._hadCommitLoad = true; | 821 this._hadCommitLoad = true; |
| 822 this._firstCompositeLayers = null; | 822 this._firstCompositeLayers = null; |
| 823 break; | 823 break; |
| 824 | 824 |
| 825 case recordTypes.CompositeLayers: | 825 case recordTypes.CompositeLayers: |
| 826 if (!this._firstCompositeLayers && this._hadCommitLoad) | 826 if (!this._firstCompositeLayers && this._hadCommitLoad) |
| 827 this._firstCompositeLayers = event; | 827 this._firstCompositeLayers = event; |
| 828 break; | 828 break; |
| 829 | 829 |
| 830 case recordTypes.FireIdleCallback: | 830 case recordTypes.FireIdleCallback: |
| 831 if (event.duration > eventData['allottedMilliseconds']) { | 831 if (event.duration > eventData['allottedMilliseconds']) { |
| 832 timelineData.warning = WebInspector.TimelineModel.WarningType.IdleDead
lineExceeded; | 832 timelineData.warning = TimelineModel.TimelineModel.WarningType.IdleDea
dlineExceeded; |
| 833 } | 833 } |
| 834 break; | 834 break; |
| 835 } | 835 } |
| 836 if (WebInspector.TracingModel.isAsyncPhase(event.phase)) | 836 if (SDK.TracingModel.isAsyncPhase(event.phase)) |
| 837 return true; | 837 return true; |
| 838 var duration = event.duration; | 838 var duration = event.duration; |
| 839 if (!duration) | 839 if (!duration) |
| 840 return true; | 840 return true; |
| 841 if (eventStack.length) { | 841 if (eventStack.length) { |
| 842 var parent = eventStack.peekLast(); | 842 var parent = eventStack.peekLast(); |
| 843 parent.selfTime -= duration; | 843 parent.selfTime -= duration; |
| 844 if (parent.selfTime < 0) { | 844 if (parent.selfTime < 0) { |
| 845 var epsilon = 1e-3; | 845 var epsilon = 1e-3; |
| 846 if (parent.selfTime < -epsilon) | 846 if (parent.selfTime < -epsilon) |
| 847 console.error( | 847 console.error( |
| 848 'Children are longer than parent at ' + event.startTime + ' (' + | 848 'Children are longer than parent at ' + event.startTime + ' (' + |
| 849 (event.startTime - this.minimumRecordTime()).toFixed(3) + ') by '
+ parent.selfTime.toFixed(3)); | 849 (event.startTime - this.minimumRecordTime()).toFixed(3) + ') by '
+ parent.selfTime.toFixed(3)); |
| 850 parent.selfTime = 0; | 850 parent.selfTime = 0; |
| 851 } | 851 } |
| 852 } | 852 } |
| 853 event.selfTime = duration; | 853 event.selfTime = duration; |
| 854 eventStack.push(event); | 854 eventStack.push(event); |
| 855 return true; | 855 return true; |
| 856 } | 856 } |
| 857 | 857 |
| 858 /** | 858 /** |
| 859 * @param {!WebInspector.TracingModel.Event} event | 859 * @param {!SDK.TracingModel.Event} event |
| 860 */ | 860 */ |
| 861 _processBrowserEvent(event) { | 861 _processBrowserEvent(event) { |
| 862 if (event.name !== WebInspector.TimelineModel.RecordType.LatencyInfoFlow) | 862 if (event.name !== TimelineModel.TimelineModel.RecordType.LatencyInfoFlow) |
| 863 return; | 863 return; |
| 864 var frameId = event.args['frameTreeNodeId']; | 864 var frameId = event.args['frameTreeNodeId']; |
| 865 if (typeof frameId === 'number' && frameId === this._mainFrameNodeId) | 865 if (typeof frameId === 'number' && frameId === this._mainFrameNodeId) |
| 866 this._knownInputEvents.add(event.bind_id); | 866 this._knownInputEvents.add(event.bind_id); |
| 867 } | 867 } |
| 868 | 868 |
| 869 /** | 869 /** |
| 870 * @param {!WebInspector.TracingModel.AsyncEvent} asyncEvent | 870 * @param {!SDK.TracingModel.AsyncEvent} asyncEvent |
| 871 * @return {?WebInspector.TimelineModel.AsyncEventGroup} | 871 * @return {?TimelineModel.TimelineModel.AsyncEventGroup} |
| 872 */ | 872 */ |
| 873 _processAsyncEvent(asyncEvent) { | 873 _processAsyncEvent(asyncEvent) { |
| 874 var groups = WebInspector.TimelineModel.AsyncEventGroup; | 874 var groups = TimelineModel.TimelineModel.AsyncEventGroup; |
| 875 if (asyncEvent.hasCategory(WebInspector.TimelineModel.Category.Console)) | 875 if (asyncEvent.hasCategory(TimelineModel.TimelineModel.Category.Console)) |
| 876 return groups.console; | 876 return groups.console; |
| 877 if (asyncEvent.hasCategory(WebInspector.TimelineModel.Category.UserTiming)) | 877 if (asyncEvent.hasCategory(TimelineModel.TimelineModel.Category.UserTiming)) |
| 878 return groups.userTiming; | 878 return groups.userTiming; |
| 879 if (asyncEvent.name === WebInspector.TimelineModel.RecordType.Animation) | 879 if (asyncEvent.name === TimelineModel.TimelineModel.RecordType.Animation) |
| 880 return groups.animation; | 880 return groups.animation; |
| 881 if (asyncEvent.hasCategory(WebInspector.TimelineModel.Category.LatencyInfo)
|| | 881 if (asyncEvent.hasCategory(TimelineModel.TimelineModel.Category.LatencyInfo)
|| |
| 882 asyncEvent.name === WebInspector.TimelineModel.RecordType.ImplSideFling)
{ | 882 asyncEvent.name === TimelineModel.TimelineModel.RecordType.ImplSideFling
) { |
| 883 var lastStep = asyncEvent.steps.peekLast(); | 883 var lastStep = asyncEvent.steps.peekLast(); |
| 884 // FIXME: fix event termination on the back-end instead. | 884 // FIXME: fix event termination on the back-end instead. |
| 885 if (lastStep.phase !== WebInspector.TracingModel.Phase.AsyncEnd) | 885 if (lastStep.phase !== SDK.TracingModel.Phase.AsyncEnd) |
| 886 return null; | 886 return null; |
| 887 var data = lastStep.args['data']; | 887 var data = lastStep.args['data']; |
| 888 asyncEvent.causedFrame = !!(data && data['INPUT_EVENT_LATENCY_RENDERER_SWA
P_COMPONENT']); | 888 asyncEvent.causedFrame = !!(data && data['INPUT_EVENT_LATENCY_RENDERER_SWA
P_COMPONENT']); |
| 889 if (asyncEvent.hasCategory(WebInspector.TimelineModel.Category.LatencyInfo
)) { | 889 if (asyncEvent.hasCategory(TimelineModel.TimelineModel.Category.LatencyInf
o)) { |
| 890 if (!this._knownInputEvents.has(lastStep.id)) | 890 if (!this._knownInputEvents.has(lastStep.id)) |
| 891 return null; | 891 return null; |
| 892 if (asyncEvent.name === WebInspector.TimelineModel.RecordType.InputLaten
cyMouseMove && !asyncEvent.causedFrame) | 892 if (asyncEvent.name === TimelineModel.TimelineModel.RecordType.InputLate
ncyMouseMove && !asyncEvent.causedFrame) |
| 893 return null; | 893 return null; |
| 894 var rendererMain = data['INPUT_EVENT_LATENCY_RENDERER_MAIN_COMPONENT']; | 894 var rendererMain = data['INPUT_EVENT_LATENCY_RENDERER_MAIN_COMPONENT']; |
| 895 if (rendererMain) { | 895 if (rendererMain) { |
| 896 var time = rendererMain['time'] / 1000; | 896 var time = rendererMain['time'] / 1000; |
| 897 WebInspector.TimelineData.forEvent(asyncEvent.steps[0]).timeWaitingFor
MainThread = time - asyncEvent.steps[0].startTime; | 897 TimelineModel.TimelineData.forEvent(asyncEvent.steps[0]).timeWaitingFo
rMainThread = time - asyncEvent.steps[0].startTime; |
| 898 } | 898 } |
| 899 } | 899 } |
| 900 return groups.input; | 900 return groups.input; |
| 901 } | 901 } |
| 902 return null; | 902 return null; |
| 903 } | 903 } |
| 904 | 904 |
| 905 /** | 905 /** |
| 906 * @param {string} name | 906 * @param {string} name |
| 907 * @return {?WebInspector.TracingModel.Event} | 907 * @return {?SDK.TracingModel.Event} |
| 908 */ | 908 */ |
| 909 _findAncestorEvent(name) { | 909 _findAncestorEvent(name) { |
| 910 for (var i = this._eventStack.length - 1; i >= 0; --i) { | 910 for (var i = this._eventStack.length - 1; i >= 0; --i) { |
| 911 var event = this._eventStack[i]; | 911 var event = this._eventStack[i]; |
| 912 if (event.name === name) | 912 if (event.name === name) |
| 913 return event; | 913 return event; |
| 914 } | 914 } |
| 915 return null; | 915 return null; |
| 916 } | 916 } |
| 917 | 917 |
| 918 /** | 918 /** |
| 919 * @param {!Map<!WebInspector.TimelineModel.AsyncEventGroup, !Array<!WebInspec
tor.TracingModel.AsyncEvent>>} target | 919 * @param {!Map<!TimelineModel.TimelineModel.AsyncEventGroup, !Array<!SDK.Trac
ingModel.AsyncEvent>>} target |
| 920 * @param {!Map<!WebInspector.TimelineModel.AsyncEventGroup, !Array<!WebInspec
tor.TracingModel.AsyncEvent>>} source | 920 * @param {!Map<!TimelineModel.TimelineModel.AsyncEventGroup, !Array<!SDK.Trac
ingModel.AsyncEvent>>} source |
| 921 */ | 921 */ |
| 922 _mergeAsyncEvents(target, source) { | 922 _mergeAsyncEvents(target, source) { |
| 923 for (var group of source.keys()) { | 923 for (var group of source.keys()) { |
| 924 var events = target.get(group) || []; | 924 var events = target.get(group) || []; |
| 925 events = events.mergeOrdered(source.get(group) || [], WebInspector.Tracing
Model.Event.compareStartAndEndTime); | 925 events = events.mergeOrdered(source.get(group) || [], SDK.TracingModel.Eve
nt.compareStartAndEndTime); |
| 926 target.set(group, events); | 926 target.set(group, events); |
| 927 } | 927 } |
| 928 } | 928 } |
| 929 | 929 |
| 930 /** | 930 /** |
| 931 * @param {!WebInspector.TracingModel.Event} event | 931 * @param {!SDK.TracingModel.Event} event |
| 932 * @param {!Object} payload | 932 * @param {!Object} payload |
| 933 */ | 933 */ |
| 934 _addPageFrame(event, payload) { | 934 _addPageFrame(event, payload) { |
| 935 var processId = event.thread.process().id(); | 935 var processId = event.thread.process().id(); |
| 936 var pageFrame = new WebInspector.TimelineModel.PageFrame(this.targetByEvent(
event), processId, payload); | 936 var pageFrame = new TimelineModel.TimelineModel.PageFrame(this.targetByEvent
(event), processId, payload); |
| 937 this._pageFrames.set(pageFrame.id, pageFrame); | 937 this._pageFrames.set(pageFrame.id, pageFrame); |
| 938 var parent = payload['parent'] && this._pageFrames.get(`${processId}.${paylo
ad['parent']}`); | 938 var parent = payload['parent'] && this._pageFrames.get(`${processId}.${paylo
ad['parent']}`); |
| 939 if (parent) | 939 if (parent) |
| 940 parent.addChild(pageFrame); | 940 parent.addChild(pageFrame); |
| 941 } | 941 } |
| 942 | 942 |
| 943 reset() { | 943 reset() { |
| 944 this._virtualThreads = []; | 944 this._virtualThreads = []; |
| 945 /** @type {!Array<!WebInspector.TracingModel.Event>} */ | 945 /** @type {!Array<!SDK.TracingModel.Event>} */ |
| 946 this._mainThreadEvents = []; | 946 this._mainThreadEvents = []; |
| 947 /** @type {!Map<!WebInspector.TimelineModel.AsyncEventGroup, !Array<!WebInsp
ector.TracingModel.AsyncEvent>>} */ | 947 /** @type {!Map<!TimelineModel.TimelineModel.AsyncEventGroup, !Array<!SDK.Tr
acingModel.AsyncEvent>>} */ |
| 948 this._mainThreadAsyncEventsByGroup = new Map(); | 948 this._mainThreadAsyncEventsByGroup = new Map(); |
| 949 /** @type {!Array<!WebInspector.TracingModel.Event>} */ | 949 /** @type {!Array<!SDK.TracingModel.Event>} */ |
| 950 this._inspectedTargetEvents = []; | 950 this._inspectedTargetEvents = []; |
| 951 /** @type {!Array<!WebInspector.TimelineModel.Record>} */ | 951 /** @type {!Array<!TimelineModel.TimelineModel.Record>} */ |
| 952 this._records = []; | 952 this._records = []; |
| 953 /** @type {!Array<!WebInspector.TimelineModel.Record>} */ | 953 /** @type {!Array<!TimelineModel.TimelineModel.Record>} */ |
| 954 this._mainThreadTasks = []; | 954 this._mainThreadTasks = []; |
| 955 /** @type {!Array<!WebInspector.TracingModel.Event>} */ | 955 /** @type {!Array<!SDK.TracingModel.Event>} */ |
| 956 this._gpuEvents = []; | 956 this._gpuEvents = []; |
| 957 /** @type {!Array<!WebInspector.TimelineModel.Record>} */ | 957 /** @type {!Array<!TimelineModel.TimelineModel.Record>} */ |
| 958 this._eventDividerRecords = []; | 958 this._eventDividerRecords = []; |
| 959 /** @type {?string} */ | 959 /** @type {?string} */ |
| 960 this._sessionId = null; | 960 this._sessionId = null; |
| 961 /** @type {?number} */ | 961 /** @type {?number} */ |
| 962 this._mainFrameNodeId = null; | 962 this._mainFrameNodeId = null; |
| 963 /** @type {!Array<!WebInspector.CPUProfileDataModel>} */ | 963 /** @type {!Array<!SDK.CPUProfileDataModel>} */ |
| 964 this._cpuProfiles = []; | 964 this._cpuProfiles = []; |
| 965 /** @type {!WeakMap<!WebInspector.TracingModel.Thread, string>} */ | 965 /** @type {!WeakMap<!SDK.TracingModel.Thread, string>} */ |
| 966 this._workerIdByThread = new WeakMap(); | 966 this._workerIdByThread = new WeakMap(); |
| 967 /** @type {!Map<string, !WebInspector.TimelineModel.PageFrame>} */ | 967 /** @type {!Map<string, !TimelineModel.TimelineModel.PageFrame>} */ |
| 968 this._pageFrames = new Map(); | 968 this._pageFrames = new Map(); |
| 969 /** @type {!Map<string, !Array<!WebInspector.TracingModel.Event>>} */ | 969 /** @type {!Map<string, !Array<!SDK.TracingModel.Event>>} */ |
| 970 this._eventsByFrame = new Map(); | 970 this._eventsByFrame = new Map(); |
| 971 | 971 |
| 972 this._minimumRecordTime = 0; | 972 this._minimumRecordTime = 0; |
| 973 this._maximumRecordTime = 0; | 973 this._maximumRecordTime = 0; |
| 974 } | 974 } |
| 975 | 975 |
| 976 /** | 976 /** |
| 977 * @return {number} | 977 * @return {number} |
| 978 */ | 978 */ |
| 979 minimumRecordTime() { | 979 minimumRecordTime() { |
| 980 return this._minimumRecordTime; | 980 return this._minimumRecordTime; |
| 981 } | 981 } |
| 982 | 982 |
| 983 /** | 983 /** |
| 984 * @return {number} | 984 * @return {number} |
| 985 */ | 985 */ |
| 986 maximumRecordTime() { | 986 maximumRecordTime() { |
| 987 return this._maximumRecordTime; | 987 return this._maximumRecordTime; |
| 988 } | 988 } |
| 989 | 989 |
| 990 /** | 990 /** |
| 991 * @return {!Array<!WebInspector.TracingModel.Event>} | 991 * @return {!Array<!SDK.TracingModel.Event>} |
| 992 */ | 992 */ |
| 993 inspectedTargetEvents() { | 993 inspectedTargetEvents() { |
| 994 return this._inspectedTargetEvents; | 994 return this._inspectedTargetEvents; |
| 995 } | 995 } |
| 996 | 996 |
| 997 /** | 997 /** |
| 998 * @return {!Array<!WebInspector.TracingModel.Event>} | 998 * @return {!Array<!SDK.TracingModel.Event>} |
| 999 */ | 999 */ |
| 1000 mainThreadEvents() { | 1000 mainThreadEvents() { |
| 1001 return this._mainThreadEvents; | 1001 return this._mainThreadEvents; |
| 1002 } | 1002 } |
| 1003 | 1003 |
| 1004 /** | 1004 /** |
| 1005 * @param {!Array<!WebInspector.TracingModel.Event>} events | 1005 * @param {!Array<!SDK.TracingModel.Event>} events |
| 1006 */ | 1006 */ |
| 1007 _setMainThreadEvents(events) { | 1007 _setMainThreadEvents(events) { |
| 1008 this._mainThreadEvents = events; | 1008 this._mainThreadEvents = events; |
| 1009 } | 1009 } |
| 1010 | 1010 |
| 1011 /** | 1011 /** |
| 1012 * @return {!Map<!WebInspector.TimelineModel.AsyncEventGroup, !Array.<!WebInsp
ector.TracingModel.AsyncEvent>>} | 1012 * @return {!Map<!TimelineModel.TimelineModel.AsyncEventGroup, !Array.<!SDK.Tr
acingModel.AsyncEvent>>} |
| 1013 */ | 1013 */ |
| 1014 mainThreadAsyncEvents() { | 1014 mainThreadAsyncEvents() { |
| 1015 return this._mainThreadAsyncEventsByGroup; | 1015 return this._mainThreadAsyncEventsByGroup; |
| 1016 } | 1016 } |
| 1017 | 1017 |
| 1018 /** | 1018 /** |
| 1019 * @return {!Array<!WebInspector.TimelineModel.VirtualThread>} | 1019 * @return {!Array<!TimelineModel.TimelineModel.VirtualThread>} |
| 1020 */ | 1020 */ |
| 1021 virtualThreads() { | 1021 virtualThreads() { |
| 1022 return this._virtualThreads; | 1022 return this._virtualThreads; |
| 1023 } | 1023 } |
| 1024 | 1024 |
| 1025 /** | 1025 /** |
| 1026 * @return {boolean} | 1026 * @return {boolean} |
| 1027 */ | 1027 */ |
| 1028 isEmpty() { | 1028 isEmpty() { |
| 1029 return this.minimumRecordTime() === 0 && this.maximumRecordTime() === 0; | 1029 return this.minimumRecordTime() === 0 && this.maximumRecordTime() === 0; |
| 1030 } | 1030 } |
| 1031 | 1031 |
| 1032 /** | 1032 /** |
| 1033 * @return {!Array.<!WebInspector.TimelineModel.Record>} | 1033 * @return {!Array.<!TimelineModel.TimelineModel.Record>} |
| 1034 */ | 1034 */ |
| 1035 mainThreadTasks() { | 1035 mainThreadTasks() { |
| 1036 return this._mainThreadTasks; | 1036 return this._mainThreadTasks; |
| 1037 } | 1037 } |
| 1038 | 1038 |
| 1039 /** | 1039 /** |
| 1040 * @return {!Array<!WebInspector.TracingModel.Event>} | 1040 * @return {!Array<!SDK.TracingModel.Event>} |
| 1041 */ | 1041 */ |
| 1042 gpuEvents() { | 1042 gpuEvents() { |
| 1043 return this._gpuEvents; | 1043 return this._gpuEvents; |
| 1044 } | 1044 } |
| 1045 | 1045 |
| 1046 /** | 1046 /** |
| 1047 * @return {!Array.<!WebInspector.TimelineModel.Record>} | 1047 * @return {!Array.<!TimelineModel.TimelineModel.Record>} |
| 1048 */ | 1048 */ |
| 1049 eventDividerRecords() { | 1049 eventDividerRecords() { |
| 1050 return this._eventDividerRecords; | 1050 return this._eventDividerRecords; |
| 1051 } | 1051 } |
| 1052 | 1052 |
| 1053 /** | 1053 /** |
| 1054 * @return {!Array<!WebInspector.TimelineModel.PageFrame>} | 1054 * @return {!Array<!TimelineModel.TimelineModel.PageFrame>} |
| 1055 */ | 1055 */ |
| 1056 rootFrames() { | 1056 rootFrames() { |
| 1057 return Array.from(this._pageFrames.values()).filter(frame => !frame.parent); | 1057 return Array.from(this._pageFrames.values()).filter(frame => !frame.parent); |
| 1058 } | 1058 } |
| 1059 | 1059 |
| 1060 /** | 1060 /** |
| 1061 * @param {string} frameId | 1061 * @param {string} frameId |
| 1062 * @return {?WebInspector.TimelineModel.PageFrame} | 1062 * @return {?TimelineModel.TimelineModel.PageFrame} |
| 1063 */ | 1063 */ |
| 1064 pageFrameById(frameId) { | 1064 pageFrameById(frameId) { |
| 1065 return frameId ? this._pageFrames.get(frameId) || null : null; | 1065 return frameId ? this._pageFrames.get(frameId) || null : null; |
| 1066 } | 1066 } |
| 1067 | 1067 |
| 1068 /** | 1068 /** |
| 1069 * @param {string} frameId | 1069 * @param {string} frameId |
| 1070 * @return {!Array<!WebInspector.TracingModel.Event>} | 1070 * @return {!Array<!SDK.TracingModel.Event>} |
| 1071 */ | 1071 */ |
| 1072 eventsForFrame(frameId) { | 1072 eventsForFrame(frameId) { |
| 1073 return this._eventsByFrame.get(frameId) || []; | 1073 return this._eventsByFrame.get(frameId) || []; |
| 1074 } | 1074 } |
| 1075 | 1075 |
| 1076 /** | 1076 /** |
| 1077 * @return {!Array<!WebInspector.TimelineModel.NetworkRequest>} | 1077 * @return {!Array<!TimelineModel.TimelineModel.NetworkRequest>} |
| 1078 */ | 1078 */ |
| 1079 networkRequests() { | 1079 networkRequests() { |
| 1080 /** @type {!Map<string,!WebInspector.TimelineModel.NetworkRequest>} */ | 1080 /** @type {!Map<string,!TimelineModel.TimelineModel.NetworkRequest>} */ |
| 1081 var requests = new Map(); | 1081 var requests = new Map(); |
| 1082 /** @type {!Array<!WebInspector.TimelineModel.NetworkRequest>} */ | 1082 /** @type {!Array<!TimelineModel.TimelineModel.NetworkRequest>} */ |
| 1083 var requestsList = []; | 1083 var requestsList = []; |
| 1084 /** @type {!Array<!WebInspector.TimelineModel.NetworkRequest>} */ | 1084 /** @type {!Array<!TimelineModel.TimelineModel.NetworkRequest>} */ |
| 1085 var zeroStartRequestsList = []; | 1085 var zeroStartRequestsList = []; |
| 1086 var types = WebInspector.TimelineModel.RecordType; | 1086 var types = TimelineModel.TimelineModel.RecordType; |
| 1087 var resourceTypes = new Set( | 1087 var resourceTypes = new Set( |
| 1088 [types.ResourceSendRequest, types.ResourceReceiveResponse, types.Resourc
eReceivedData, types.ResourceFinish]); | 1088 [types.ResourceSendRequest, types.ResourceReceiveResponse, types.Resourc
eReceivedData, types.ResourceFinish]); |
| 1089 var events = this.mainThreadEvents(); | 1089 var events = this.mainThreadEvents(); |
| 1090 for (var i = 0; i < events.length; ++i) { | 1090 for (var i = 0; i < events.length; ++i) { |
| 1091 var e = events[i]; | 1091 var e = events[i]; |
| 1092 if (!resourceTypes.has(e.name)) | 1092 if (!resourceTypes.has(e.name)) |
| 1093 continue; | 1093 continue; |
| 1094 var id = e.args['data']['requestId']; | 1094 var id = e.args['data']['requestId']; |
| 1095 var request = requests.get(id); | 1095 var request = requests.get(id); |
| 1096 if (request) { | 1096 if (request) { |
| 1097 request.addEvent(e); | 1097 request.addEvent(e); |
| 1098 } else { | 1098 } else { |
| 1099 request = new WebInspector.TimelineModel.NetworkRequest(e); | 1099 request = new TimelineModel.TimelineModel.NetworkRequest(e); |
| 1100 requests.set(id, request); | 1100 requests.set(id, request); |
| 1101 if (request.startTime) | 1101 if (request.startTime) |
| 1102 requestsList.push(request); | 1102 requestsList.push(request); |
| 1103 else | 1103 else |
| 1104 zeroStartRequestsList.push(request); | 1104 zeroStartRequestsList.push(request); |
| 1105 } | 1105 } |
| 1106 } | 1106 } |
| 1107 return zeroStartRequestsList.concat(requestsList); | 1107 return zeroStartRequestsList.concat(requestsList); |
| 1108 } | 1108 } |
| 1109 }; | 1109 }; |
| 1110 | 1110 |
| 1111 /** | 1111 /** |
| 1112 * @enum {string} | 1112 * @enum {string} |
| 1113 */ | 1113 */ |
| 1114 WebInspector.TimelineModel.RecordType = { | 1114 TimelineModel.TimelineModel.RecordType = { |
| 1115 Task: 'Task', | 1115 Task: 'Task', |
| 1116 Program: 'Program', | 1116 Program: 'Program', |
| 1117 EventDispatch: 'EventDispatch', | 1117 EventDispatch: 'EventDispatch', |
| 1118 | 1118 |
| 1119 GPUTask: 'GPUTask', | 1119 GPUTask: 'GPUTask', |
| 1120 | 1120 |
| 1121 Animation: 'Animation', | 1121 Animation: 'Animation', |
| 1122 RequestMainThreadFrame: 'RequestMainThreadFrame', | 1122 RequestMainThreadFrame: 'RequestMainThreadFrame', |
| 1123 BeginFrame: 'BeginFrame', | 1123 BeginFrame: 'BeginFrame', |
| 1124 NeedsBeginFrameChanged: 'NeedsBeginFrameChanged', | 1124 NeedsBeginFrameChanged: 'NeedsBeginFrameChanged', |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1228 GCIdleLazySweep: 'ThreadState::performIdleLazySweep', | 1228 GCIdleLazySweep: 'ThreadState::performIdleLazySweep', |
| 1229 GCCompleteSweep: 'ThreadState::completeSweep', | 1229 GCCompleteSweep: 'ThreadState::completeSweep', |
| 1230 GCCollectGarbage: 'BlinkGCMarking', | 1230 GCCollectGarbage: 'BlinkGCMarking', |
| 1231 | 1231 |
| 1232 // CpuProfile is a virtual event created on frontend to support | 1232 // CpuProfile is a virtual event created on frontend to support |
| 1233 // serialization of CPU Profiles within tracing timeline data. | 1233 // serialization of CPU Profiles within tracing timeline data. |
| 1234 CpuProfile: 'CpuProfile', | 1234 CpuProfile: 'CpuProfile', |
| 1235 Profile: 'Profile' | 1235 Profile: 'Profile' |
| 1236 }; | 1236 }; |
| 1237 | 1237 |
| 1238 WebInspector.TimelineModel.Category = { | 1238 TimelineModel.TimelineModel.Category = { |
| 1239 Console: 'blink.console', | 1239 Console: 'blink.console', |
| 1240 UserTiming: 'blink.user_timing', | 1240 UserTiming: 'blink.user_timing', |
| 1241 LatencyInfo: 'latencyInfo' | 1241 LatencyInfo: 'latencyInfo' |
| 1242 }; | 1242 }; |
| 1243 | 1243 |
| 1244 /** | 1244 /** |
| 1245 * @enum {string} | 1245 * @enum {string} |
| 1246 */ | 1246 */ |
| 1247 WebInspector.TimelineModel.WarningType = { | 1247 TimelineModel.TimelineModel.WarningType = { |
| 1248 ForcedStyle: 'ForcedStyle', | 1248 ForcedStyle: 'ForcedStyle', |
| 1249 ForcedLayout: 'ForcedLayout', | 1249 ForcedLayout: 'ForcedLayout', |
| 1250 IdleDeadlineExceeded: 'IdleDeadlineExceeded', | 1250 IdleDeadlineExceeded: 'IdleDeadlineExceeded', |
| 1251 V8Deopt: 'V8Deopt' | 1251 V8Deopt: 'V8Deopt' |
| 1252 }; | 1252 }; |
| 1253 | 1253 |
| 1254 WebInspector.TimelineModel.MainThreadName = 'main'; | 1254 TimelineModel.TimelineModel.MainThreadName = 'main'; |
| 1255 WebInspector.TimelineModel.WorkerThreadName = 'DedicatedWorker Thread'; | 1255 TimelineModel.TimelineModel.WorkerThreadName = 'DedicatedWorker Thread'; |
| 1256 WebInspector.TimelineModel.RendererMainThreadName = 'CrRendererMain'; | 1256 TimelineModel.TimelineModel.RendererMainThreadName = 'CrRendererMain'; |
| 1257 | 1257 |
| 1258 /** | 1258 /** |
| 1259 * @enum {symbol} | 1259 * @enum {symbol} |
| 1260 */ | 1260 */ |
| 1261 WebInspector.TimelineModel.AsyncEventGroup = { | 1261 TimelineModel.TimelineModel.AsyncEventGroup = { |
| 1262 animation: Symbol('animation'), | 1262 animation: Symbol('animation'), |
| 1263 console: Symbol('console'), | 1263 console: Symbol('console'), |
| 1264 userTiming: Symbol('userTiming'), | 1264 userTiming: Symbol('userTiming'), |
| 1265 input: Symbol('input') | 1265 input: Symbol('input') |
| 1266 }; | 1266 }; |
| 1267 | 1267 |
| 1268 | 1268 |
| 1269 WebInspector.TimelineModel.DevToolsMetadataEvent = { | 1269 TimelineModel.TimelineModel.DevToolsMetadataEvent = { |
| 1270 TracingStartedInBrowser: 'TracingStartedInBrowser', | 1270 TracingStartedInBrowser: 'TracingStartedInBrowser', |
| 1271 TracingStartedInPage: 'TracingStartedInPage', | 1271 TracingStartedInPage: 'TracingStartedInPage', |
| 1272 TracingSessionIdForWorker: 'TracingSessionIdForWorker', | 1272 TracingSessionIdForWorker: 'TracingSessionIdForWorker', |
| 1273 }; | 1273 }; |
| 1274 | 1274 |
| 1275 /** | 1275 /** |
| 1276 * @unrestricted | 1276 * @unrestricted |
| 1277 */ | 1277 */ |
| 1278 WebInspector.TimelineModel.VirtualThread = class { | 1278 TimelineModel.TimelineModel.VirtualThread = class { |
| 1279 /** | 1279 /** |
| 1280 * @param {string} name | 1280 * @param {string} name |
| 1281 */ | 1281 */ |
| 1282 constructor(name) { | 1282 constructor(name) { |
| 1283 this.name = name; | 1283 this.name = name; |
| 1284 /** @type {!Array<!WebInspector.TracingModel.Event>} */ | 1284 /** @type {!Array<!SDK.TracingModel.Event>} */ |
| 1285 this.events = []; | 1285 this.events = []; |
| 1286 /** @type {!Map<!WebInspector.TimelineModel.AsyncEventGroup, !Array<!WebInsp
ector.TracingModel.AsyncEvent>>} */ | 1286 /** @type {!Map<!TimelineModel.TimelineModel.AsyncEventGroup, !Array<!SDK.Tr
acingModel.AsyncEvent>>} */ |
| 1287 this.asyncEventsByGroup = new Map(); | 1287 this.asyncEventsByGroup = new Map(); |
| 1288 } | 1288 } |
| 1289 | 1289 |
| 1290 /** | 1290 /** |
| 1291 * @return {boolean} | 1291 * @return {boolean} |
| 1292 */ | 1292 */ |
| 1293 isWorker() { | 1293 isWorker() { |
| 1294 return this.name === WebInspector.TimelineModel.WorkerThreadName; | 1294 return this.name === TimelineModel.TimelineModel.WorkerThreadName; |
| 1295 } | 1295 } |
| 1296 }; | 1296 }; |
| 1297 | 1297 |
| 1298 /** | 1298 /** |
| 1299 * @unrestricted | 1299 * @unrestricted |
| 1300 */ | 1300 */ |
| 1301 WebInspector.TimelineModel.Record = class { | 1301 TimelineModel.TimelineModel.Record = class { |
| 1302 /** | 1302 /** |
| 1303 * @param {!WebInspector.TracingModel.Event} traceEvent | 1303 * @param {!SDK.TracingModel.Event} traceEvent |
| 1304 */ | 1304 */ |
| 1305 constructor(traceEvent) { | 1305 constructor(traceEvent) { |
| 1306 this._event = traceEvent; | 1306 this._event = traceEvent; |
| 1307 this._children = []; | 1307 this._children = []; |
| 1308 } | 1308 } |
| 1309 | 1309 |
| 1310 /** | 1310 /** |
| 1311 * @param {!WebInspector.TimelineModel.Record} a | 1311 * @param {!TimelineModel.TimelineModel.Record} a |
| 1312 * @param {!WebInspector.TimelineModel.Record} b | 1312 * @param {!TimelineModel.TimelineModel.Record} b |
| 1313 * @return {number} | 1313 * @return {number} |
| 1314 */ | 1314 */ |
| 1315 static _compareStartTime(a, b) { | 1315 static _compareStartTime(a, b) { |
| 1316 // Never return 0 as otherwise equal records would be merged. | 1316 // Never return 0 as otherwise equal records would be merged. |
| 1317 return a.startTime() <= b.startTime() ? -1 : 1; | 1317 return a.startTime() <= b.startTime() ? -1 : 1; |
| 1318 } | 1318 } |
| 1319 | 1319 |
| 1320 /** | 1320 /** |
| 1321 * @return {?WebInspector.Target} | 1321 * @return {?SDK.Target} |
| 1322 */ | 1322 */ |
| 1323 target() { | 1323 target() { |
| 1324 var threadName = this._event.thread.name(); | 1324 var threadName = this._event.thread.name(); |
| 1325 // FIXME: correctly specify target | 1325 // FIXME: correctly specify target |
| 1326 return threadName === WebInspector.TimelineModel.RendererMainThreadName ? | 1326 return threadName === TimelineModel.TimelineModel.RendererMainThreadName ? |
| 1327 WebInspector.targetManager.targets()[0] || null : | 1327 SDK.targetManager.targets()[0] || null : |
| 1328 null; | 1328 null; |
| 1329 } | 1329 } |
| 1330 | 1330 |
| 1331 /** | 1331 /** |
| 1332 * @return {!Array.<!WebInspector.TimelineModel.Record>} | 1332 * @return {!Array.<!TimelineModel.TimelineModel.Record>} |
| 1333 */ | 1333 */ |
| 1334 children() { | 1334 children() { |
| 1335 return this._children; | 1335 return this._children; |
| 1336 } | 1336 } |
| 1337 | 1337 |
| 1338 /** | 1338 /** |
| 1339 * @return {number} | 1339 * @return {number} |
| 1340 */ | 1340 */ |
| 1341 startTime() { | 1341 startTime() { |
| 1342 return this._event.startTime; | 1342 return this._event.startTime; |
| 1343 } | 1343 } |
| 1344 | 1344 |
| 1345 /** | 1345 /** |
| 1346 * @return {number} | 1346 * @return {number} |
| 1347 */ | 1347 */ |
| 1348 endTime() { | 1348 endTime() { |
| 1349 return this._event.endTime || this._event.startTime; | 1349 return this._event.endTime || this._event.startTime; |
| 1350 } | 1350 } |
| 1351 | 1351 |
| 1352 /** | 1352 /** |
| 1353 * @return {string} | 1353 * @return {string} |
| 1354 */ | 1354 */ |
| 1355 thread() { | 1355 thread() { |
| 1356 if (this._event.thread.name() === WebInspector.TimelineModel.RendererMainThr
eadName) | 1356 if (this._event.thread.name() === TimelineModel.TimelineModel.RendererMainTh
readName) |
| 1357 return WebInspector.TimelineModel.MainThreadName; | 1357 return TimelineModel.TimelineModel.MainThreadName; |
| 1358 return this._event.thread.name(); | 1358 return this._event.thread.name(); |
| 1359 } | 1359 } |
| 1360 | 1360 |
| 1361 /** | 1361 /** |
| 1362 * @return {!WebInspector.TimelineModel.RecordType} | 1362 * @return {!TimelineModel.TimelineModel.RecordType} |
| 1363 */ | 1363 */ |
| 1364 type() { | 1364 type() { |
| 1365 return WebInspector.TimelineModel._eventType(this._event); | 1365 return TimelineModel.TimelineModel._eventType(this._event); |
| 1366 } | 1366 } |
| 1367 | 1367 |
| 1368 /** | 1368 /** |
| 1369 * @return {!WebInspector.TracingModel.Event} | 1369 * @return {!SDK.TracingModel.Event} |
| 1370 */ | 1370 */ |
| 1371 traceEvent() { | 1371 traceEvent() { |
| 1372 return this._event; | 1372 return this._event; |
| 1373 } | 1373 } |
| 1374 | 1374 |
| 1375 /** | 1375 /** |
| 1376 * @param {!WebInspector.TimelineModel.Record} child | 1376 * @param {!TimelineModel.TimelineModel.Record} child |
| 1377 */ | 1377 */ |
| 1378 _addChild(child) { | 1378 _addChild(child) { |
| 1379 this._children.push(child); | 1379 this._children.push(child); |
| 1380 child.parent = this; | 1380 child.parent = this; |
| 1381 } | 1381 } |
| 1382 }; | 1382 }; |
| 1383 | 1383 |
| 1384 | 1384 |
| 1385 /** @typedef {!{page: !Array<!WebInspector.TracingModel.Event>, workers: !Array<
!WebInspector.TracingModel.Event>}} */ | 1385 /** @typedef {!{page: !Array<!SDK.TracingModel.Event>, workers: !Array<!SDK.Trac
ingModel.Event>}} */ |
| 1386 WebInspector.TimelineModel.MetadataEvents; | 1386 TimelineModel.TimelineModel.MetadataEvents; |
| 1387 | 1387 |
| 1388 | 1388 |
| 1389 WebInspector.TimelineModel.PageFrame = class { | 1389 TimelineModel.TimelineModel.PageFrame = class { |
| 1390 /** | 1390 /** |
| 1391 * @param {?WebInspector.Target} target | 1391 * @param {?SDK.Target} target |
| 1392 * @param {number} pid | 1392 * @param {number} pid |
| 1393 * @param {!Object} payload | 1393 * @param {!Object} payload |
| 1394 */ | 1394 */ |
| 1395 constructor(target, pid, payload) { | 1395 constructor(target, pid, payload) { |
| 1396 this.frameId = payload['frame']; | 1396 this.frameId = payload['frame']; |
| 1397 this.url = payload['url'] || ''; | 1397 this.url = payload['url'] || ''; |
| 1398 this.name = payload['name']; | 1398 this.name = payload['name']; |
| 1399 this.processId = pid; | 1399 this.processId = pid; |
| 1400 this.children = []; | 1400 this.children = []; |
| 1401 /** @type {?WebInspector.TimelineModel.PageFrame} */ | 1401 /** @type {?TimelineModel.TimelineModel.PageFrame} */ |
| 1402 this.parent = null; | 1402 this.parent = null; |
| 1403 this.id = `${this.processId}.${this.frameId}`; | 1403 this.id = `${this.processId}.${this.frameId}`; |
| 1404 this.ownerNode = target && payload['nodeId'] ? new WebInspector.DeferredDOMN
ode(target, payload['nodeId']) : null; | 1404 this.ownerNode = target && payload['nodeId'] ? new SDK.DeferredDOMNode(targe
t, payload['nodeId']) : null; |
| 1405 } | 1405 } |
| 1406 | 1406 |
| 1407 /** | 1407 /** |
| 1408 * @param {string} name | 1408 * @param {string} name |
| 1409 * @param {string} url | 1409 * @param {string} url |
| 1410 */ | 1410 */ |
| 1411 update(name, url) { | 1411 update(name, url) { |
| 1412 this.name = name; | 1412 this.name = name; |
| 1413 this.url = url; | 1413 this.url = url; |
| 1414 } | 1414 } |
| 1415 | 1415 |
| 1416 /** | 1416 /** |
| 1417 * @param {!WebInspector.TimelineModel.PageFrame} child | 1417 * @param {!TimelineModel.TimelineModel.PageFrame} child |
| 1418 */ | 1418 */ |
| 1419 addChild(child) { | 1419 addChild(child) { |
| 1420 this.children.push(child); | 1420 this.children.push(child); |
| 1421 child.parent = this; | 1421 child.parent = this; |
| 1422 } | 1422 } |
| 1423 }; | 1423 }; |
| 1424 | 1424 |
| 1425 WebInspector.TimelineModel.PageFrame.mainFrameId = ''; | 1425 TimelineModel.TimelineModel.PageFrame.mainFrameId = ''; |
| 1426 | 1426 |
| 1427 | 1427 |
| 1428 /** | 1428 /** |
| 1429 * @unrestricted | 1429 * @unrestricted |
| 1430 */ | 1430 */ |
| 1431 WebInspector.TimelineModel.NetworkRequest = class { | 1431 TimelineModel.TimelineModel.NetworkRequest = class { |
| 1432 /** | 1432 /** |
| 1433 * @param {!WebInspector.TracingModel.Event} event | 1433 * @param {!SDK.TracingModel.Event} event |
| 1434 */ | 1434 */ |
| 1435 constructor(event) { | 1435 constructor(event) { |
| 1436 this.startTime = event.name === WebInspector.TimelineModel.RecordType.Resour
ceSendRequest ? event.startTime : 0; | 1436 this.startTime = event.name === TimelineModel.TimelineModel.RecordType.Resou
rceSendRequest ? event.startTime : 0; |
| 1437 this.endTime = Infinity; | 1437 this.endTime = Infinity; |
| 1438 /** @type {!Array<!WebInspector.TracingModel.Event>} */ | 1438 /** @type {!Array<!SDK.TracingModel.Event>} */ |
| 1439 this.children = []; | 1439 this.children = []; |
| 1440 /** @type {?Object} */ | 1440 /** @type {?Object} */ |
| 1441 this.timing; | 1441 this.timing; |
| 1442 /** @type {string} */ | 1442 /** @type {string} */ |
| 1443 this.mimeType; | 1443 this.mimeType; |
| 1444 /** @type {string} */ | 1444 /** @type {string} */ |
| 1445 this.url; | 1445 this.url; |
| 1446 /** @type {string} */ | 1446 /** @type {string} */ |
| 1447 this.requestMethod; | 1447 this.requestMethod; |
| 1448 this.addEvent(event); | 1448 this.addEvent(event); |
| 1449 } | 1449 } |
| 1450 | 1450 |
| 1451 /** | 1451 /** |
| 1452 * @param {!WebInspector.TracingModel.Event} event | 1452 * @param {!SDK.TracingModel.Event} event |
| 1453 */ | 1453 */ |
| 1454 addEvent(event) { | 1454 addEvent(event) { |
| 1455 this.children.push(event); | 1455 this.children.push(event); |
| 1456 var recordType = WebInspector.TimelineModel.RecordType; | 1456 var recordType = TimelineModel.TimelineModel.RecordType; |
| 1457 this.startTime = Math.min(this.startTime, event.startTime); | 1457 this.startTime = Math.min(this.startTime, event.startTime); |
| 1458 var eventData = event.args['data']; | 1458 var eventData = event.args['data']; |
| 1459 if (eventData['mimeType']) | 1459 if (eventData['mimeType']) |
| 1460 this.mimeType = eventData['mimeType']; | 1460 this.mimeType = eventData['mimeType']; |
| 1461 if ('priority' in eventData) | 1461 if ('priority' in eventData) |
| 1462 this.priority = eventData['priority']; | 1462 this.priority = eventData['priority']; |
| 1463 if (event.name === recordType.ResourceFinish) | 1463 if (event.name === recordType.ResourceFinish) |
| 1464 this.endTime = event.startTime; | 1464 this.endTime = event.startTime; |
| 1465 if (eventData['finishTime']) | 1465 if (eventData['finishTime']) |
| 1466 this.finishTime = eventData['finishTime'] * 1000; | 1466 this.finishTime = eventData['finishTime'] * 1000; |
| 1467 if (!this.responseTime && | 1467 if (!this.responseTime && |
| 1468 (event.name === recordType.ResourceReceiveResponse || event.name === rec
ordType.ResourceReceivedData)) | 1468 (event.name === recordType.ResourceReceiveResponse || event.name === rec
ordType.ResourceReceivedData)) |
| 1469 this.responseTime = event.startTime; | 1469 this.responseTime = event.startTime; |
| 1470 if (!this.url) | 1470 if (!this.url) |
| 1471 this.url = eventData['url']; | 1471 this.url = eventData['url']; |
| 1472 if (!this.requestMethod) | 1472 if (!this.requestMethod) |
| 1473 this.requestMethod = eventData['requestMethod']; | 1473 this.requestMethod = eventData['requestMethod']; |
| 1474 if (!this.timing) | 1474 if (!this.timing) |
| 1475 this.timing = eventData['timing']; | 1475 this.timing = eventData['timing']; |
| 1476 } | 1476 } |
| 1477 }; | 1477 }; |
| 1478 | 1478 |
| 1479 WebInspector.TimelineModel.Filter = class { | 1479 TimelineModel.TimelineModel.Filter = class { |
| 1480 /** | 1480 /** |
| 1481 * @param {!WebInspector.TracingModel.Event} event | 1481 * @param {!SDK.TracingModel.Event} event |
| 1482 * @return {boolean} | 1482 * @return {boolean} |
| 1483 */ | 1483 */ |
| 1484 accept(event) { | 1484 accept(event) { |
| 1485 return true; | 1485 return true; |
| 1486 } | 1486 } |
| 1487 }; | 1487 }; |
| 1488 | 1488 |
| 1489 WebInspector.TimelineVisibleEventsFilter = class extends WebInspector.TimelineMo
del.Filter { | 1489 TimelineModel.TimelineVisibleEventsFilter = class extends TimelineModel.Timeline
Model.Filter { |
| 1490 /** | 1490 /** |
| 1491 * @param {!Array.<string>} visibleTypes | 1491 * @param {!Array.<string>} visibleTypes |
| 1492 */ | 1492 */ |
| 1493 constructor(visibleTypes) { | 1493 constructor(visibleTypes) { |
| 1494 super(); | 1494 super(); |
| 1495 this._visibleTypes = new Set(visibleTypes); | 1495 this._visibleTypes = new Set(visibleTypes); |
| 1496 } | 1496 } |
| 1497 | 1497 |
| 1498 /** | 1498 /** |
| 1499 * @override | 1499 * @override |
| 1500 * @param {!WebInspector.TracingModel.Event} event | 1500 * @param {!SDK.TracingModel.Event} event |
| 1501 * @return {boolean} | 1501 * @return {boolean} |
| 1502 */ | 1502 */ |
| 1503 accept(event) { | 1503 accept(event) { |
| 1504 return this._visibleTypes.has(WebInspector.TimelineModel._eventType(event)); | 1504 return this._visibleTypes.has(TimelineModel.TimelineModel._eventType(event))
; |
| 1505 } | 1505 } |
| 1506 }; | 1506 }; |
| 1507 | 1507 |
| 1508 WebInspector.ExclusiveNameFilter = class extends WebInspector.TimelineModel.Filt
er { | 1508 TimelineModel.ExclusiveNameFilter = class extends TimelineModel.TimelineModel.Fi
lter { |
| 1509 /** | 1509 /** |
| 1510 * @param {!Array<string>} excludeNames | 1510 * @param {!Array<string>} excludeNames |
| 1511 */ | 1511 */ |
| 1512 constructor(excludeNames) { | 1512 constructor(excludeNames) { |
| 1513 super(); | 1513 super(); |
| 1514 this._excludeNames = new Set(excludeNames); | 1514 this._excludeNames = new Set(excludeNames); |
| 1515 } | 1515 } |
| 1516 | 1516 |
| 1517 /** | 1517 /** |
| 1518 * @override | 1518 * @override |
| 1519 * @param {!WebInspector.TracingModel.Event} event | 1519 * @param {!SDK.TracingModel.Event} event |
| 1520 * @return {boolean} | 1520 * @return {boolean} |
| 1521 */ | 1521 */ |
| 1522 accept(event) { | 1522 accept(event) { |
| 1523 return !this._excludeNames.has(event.name); | 1523 return !this._excludeNames.has(event.name); |
| 1524 } | 1524 } |
| 1525 }; | 1525 }; |
| 1526 | 1526 |
| 1527 WebInspector.ExcludeTopLevelFilter = class extends WebInspector.TimelineModel.Fi
lter { | 1527 TimelineModel.ExcludeTopLevelFilter = class extends TimelineModel.TimelineModel.
Filter { |
| 1528 constructor() { | 1528 constructor() { |
| 1529 super(); | 1529 super(); |
| 1530 } | 1530 } |
| 1531 | 1531 |
| 1532 /** | 1532 /** |
| 1533 * @override | 1533 * @override |
| 1534 * @param {!WebInspector.TracingModel.Event} event | 1534 * @param {!SDK.TracingModel.Event} event |
| 1535 * @return {boolean} | 1535 * @return {boolean} |
| 1536 */ | 1536 */ |
| 1537 accept(event) { | 1537 accept(event) { |
| 1538 return !WebInspector.TracingModel.isTopLevelEvent(event); | 1538 return !SDK.TracingModel.isTopLevelEvent(event); |
| 1539 } | 1539 } |
| 1540 }; | 1540 }; |
| 1541 | 1541 |
| 1542 /** | 1542 /** |
| 1543 * @unrestricted | 1543 * @unrestricted |
| 1544 */ | 1544 */ |
| 1545 WebInspector.InvalidationTrackingEvent = class { | 1545 TimelineModel.InvalidationTrackingEvent = class { |
| 1546 /** | 1546 /** |
| 1547 * @param {!WebInspector.TracingModel.Event} event | 1547 * @param {!SDK.TracingModel.Event} event |
| 1548 */ | 1548 */ |
| 1549 constructor(event) { | 1549 constructor(event) { |
| 1550 /** @type {string} */ | 1550 /** @type {string} */ |
| 1551 this.type = event.name; | 1551 this.type = event.name; |
| 1552 /** @type {number} */ | 1552 /** @type {number} */ |
| 1553 this.startTime = event.startTime; | 1553 this.startTime = event.startTime; |
| 1554 /** @type {!WebInspector.TracingModel.Event} */ | 1554 /** @type {!SDK.TracingModel.Event} */ |
| 1555 this._tracingEvent = event; | 1555 this._tracingEvent = event; |
| 1556 | 1556 |
| 1557 var eventData = event.args['data']; | 1557 var eventData = event.args['data']; |
| 1558 | 1558 |
| 1559 /** @type {number} */ | 1559 /** @type {number} */ |
| 1560 this.frame = eventData['frame']; | 1560 this.frame = eventData['frame']; |
| 1561 /** @type {?number} */ | 1561 /** @type {?number} */ |
| 1562 this.nodeId = eventData['nodeId']; | 1562 this.nodeId = eventData['nodeId']; |
| 1563 /** @type {?string} */ | 1563 /** @type {?string} */ |
| 1564 this.nodeName = eventData['nodeName']; | 1564 this.nodeName = eventData['nodeName']; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1575 /** @type {?string} */ | 1575 /** @type {?string} */ |
| 1576 this.changedAttribute = eventData['changedAttribute']; | 1576 this.changedAttribute = eventData['changedAttribute']; |
| 1577 /** @type {?string} */ | 1577 /** @type {?string} */ |
| 1578 this.changedPseudo = eventData['changedPseudo']; | 1578 this.changedPseudo = eventData['changedPseudo']; |
| 1579 /** @type {?string} */ | 1579 /** @type {?string} */ |
| 1580 this.selectorPart = eventData['selectorPart']; | 1580 this.selectorPart = eventData['selectorPart']; |
| 1581 /** @type {?string} */ | 1581 /** @type {?string} */ |
| 1582 this.extraData = eventData['extraData']; | 1582 this.extraData = eventData['extraData']; |
| 1583 /** @type {?Array.<!Object.<string, number>>} */ | 1583 /** @type {?Array.<!Object.<string, number>>} */ |
| 1584 this.invalidationList = eventData['invalidationList']; | 1584 this.invalidationList = eventData['invalidationList']; |
| 1585 /** @type {!WebInspector.InvalidationCause} */ | 1585 /** @type {!TimelineModel.InvalidationCause} */ |
| 1586 this.cause = {reason: eventData['reason'], stackTrace: eventData['stackTrace
']}; | 1586 this.cause = {reason: eventData['reason'], stackTrace: eventData['stackTrace
']}; |
| 1587 | 1587 |
| 1588 // FIXME: Move this to TimelineUIUtils.js. | 1588 // FIXME: Move this to TimelineUIUtils.js. |
| 1589 if (!this.cause.reason && this.cause.stackTrace && | 1589 if (!this.cause.reason && this.cause.stackTrace && |
| 1590 this.type === WebInspector.TimelineModel.RecordType.LayoutInvalidationTr
acking) | 1590 this.type === TimelineModel.TimelineModel.RecordType.LayoutInvalidationT
racking) |
| 1591 this.cause.reason = 'Layout forced'; | 1591 this.cause.reason = 'Layout forced'; |
| 1592 } | 1592 } |
| 1593 }; | 1593 }; |
| 1594 | 1594 |
| 1595 /** @typedef {{reason: string, stackTrace: ?Array<!Protocol.Runtime.CallFrame>}}
*/ | 1595 /** @typedef {{reason: string, stackTrace: ?Array<!Protocol.Runtime.CallFrame>}}
*/ |
| 1596 WebInspector.InvalidationCause; | 1596 TimelineModel.InvalidationCause; |
| 1597 | 1597 |
| 1598 WebInspector.InvalidationTracker = class { | 1598 TimelineModel.InvalidationTracker = class { |
| 1599 constructor() { | 1599 constructor() { |
| 1600 /** @type {?WebInspector.TracingModel.Event} */ | 1600 /** @type {?SDK.TracingModel.Event} */ |
| 1601 this._lastRecalcStyle = null; | 1601 this._lastRecalcStyle = null; |
| 1602 /** @type {?WebInspector.TracingModel.Event} */ | 1602 /** @type {?SDK.TracingModel.Event} */ |
| 1603 this._lastPaintWithLayer = null; | 1603 this._lastPaintWithLayer = null; |
| 1604 this._didPaint = false; | 1604 this._didPaint = false; |
| 1605 this._initializePerFrameState(); | 1605 this._initializePerFrameState(); |
| 1606 } | 1606 } |
| 1607 | 1607 |
| 1608 /** | 1608 /** |
| 1609 * @param {!WebInspector.TracingModel.Event} event | 1609 * @param {!SDK.TracingModel.Event} event |
| 1610 * @return {?Array<!WebInspector.InvalidationTrackingEvent>} | 1610 * @return {?Array<!TimelineModel.InvalidationTrackingEvent>} |
| 1611 */ | 1611 */ |
| 1612 static invalidationEventsFor(event) { | 1612 static invalidationEventsFor(event) { |
| 1613 return event[WebInspector.InvalidationTracker._invalidationTrackingEventsSym
bol] || null; | 1613 return event[TimelineModel.InvalidationTracker._invalidationTrackingEventsSy
mbol] || null; |
| 1614 } | 1614 } |
| 1615 | 1615 |
| 1616 /** | 1616 /** |
| 1617 * @param {!WebInspector.InvalidationTrackingEvent} invalidation | 1617 * @param {!TimelineModel.InvalidationTrackingEvent} invalidation |
| 1618 */ | 1618 */ |
| 1619 addInvalidation(invalidation) { | 1619 addInvalidation(invalidation) { |
| 1620 this._startNewFrameIfNeeded(); | 1620 this._startNewFrameIfNeeded(); |
| 1621 | 1621 |
| 1622 if (!invalidation.nodeId && !invalidation.paintId) { | 1622 if (!invalidation.nodeId && !invalidation.paintId) { |
| 1623 console.error('Invalidation lacks node information.'); | 1623 console.error('Invalidation lacks node information.'); |
| 1624 console.error(invalidation); | 1624 console.error(invalidation); |
| 1625 return; | 1625 return; |
| 1626 } | 1626 } |
| 1627 | 1627 |
| 1628 // PaintInvalidationTracking events provide a paintId and a nodeId which | 1628 // PaintInvalidationTracking events provide a paintId and a nodeId which |
| 1629 // we can use to update the paintId for all other invalidation tracking | 1629 // we can use to update the paintId for all other invalidation tracking |
| 1630 // events. | 1630 // events. |
| 1631 var recordTypes = WebInspector.TimelineModel.RecordType; | 1631 var recordTypes = TimelineModel.TimelineModel.RecordType; |
| 1632 if (invalidation.type === recordTypes.PaintInvalidationTracking && invalidat
ion.nodeId) { | 1632 if (invalidation.type === recordTypes.PaintInvalidationTracking && invalidat
ion.nodeId) { |
| 1633 var invalidations = this._invalidationsByNodeId[invalidation.nodeId] || []
; | 1633 var invalidations = this._invalidationsByNodeId[invalidation.nodeId] || []
; |
| 1634 for (var i = 0; i < invalidations.length; ++i) | 1634 for (var i = 0; i < invalidations.length; ++i) |
| 1635 invalidations[i].paintId = invalidation.paintId; | 1635 invalidations[i].paintId = invalidation.paintId; |
| 1636 | 1636 |
| 1637 // PaintInvalidationTracking is only used for updating paintIds. | 1637 // PaintInvalidationTracking is only used for updating paintIds. |
| 1638 return; | 1638 return; |
| 1639 } | 1639 } |
| 1640 | 1640 |
| 1641 // Suppress StyleInvalidator StyleRecalcInvalidationTracking invalidations b
ecause they | 1641 // Suppress StyleInvalidator StyleRecalcInvalidationTracking invalidations b
ecause they |
| (...skipping 25 matching lines...) Expand all Loading... |
| 1667 this._invalidations[invalidation.type] = [invalidation]; | 1667 this._invalidations[invalidation.type] = [invalidation]; |
| 1668 if (invalidation.nodeId) { | 1668 if (invalidation.nodeId) { |
| 1669 if (this._invalidationsByNodeId[invalidation.nodeId]) | 1669 if (this._invalidationsByNodeId[invalidation.nodeId]) |
| 1670 this._invalidationsByNodeId[invalidation.nodeId].push(invalidation); | 1670 this._invalidationsByNodeId[invalidation.nodeId].push(invalidation); |
| 1671 else | 1671 else |
| 1672 this._invalidationsByNodeId[invalidation.nodeId] = [invalidation]; | 1672 this._invalidationsByNodeId[invalidation.nodeId] = [invalidation]; |
| 1673 } | 1673 } |
| 1674 } | 1674 } |
| 1675 | 1675 |
| 1676 /** | 1676 /** |
| 1677 * @param {!WebInspector.TracingModel.Event} recalcStyleEvent | 1677 * @param {!SDK.TracingModel.Event} recalcStyleEvent |
| 1678 */ | 1678 */ |
| 1679 didRecalcStyle(recalcStyleEvent) { | 1679 didRecalcStyle(recalcStyleEvent) { |
| 1680 this._lastRecalcStyle = recalcStyleEvent; | 1680 this._lastRecalcStyle = recalcStyleEvent; |
| 1681 var types = [ | 1681 var types = [ |
| 1682 WebInspector.TimelineModel.RecordType.ScheduleStyleInvalidationTracking, | 1682 TimelineModel.TimelineModel.RecordType.ScheduleStyleInvalidationTracking, |
| 1683 WebInspector.TimelineModel.RecordType.StyleInvalidatorInvalidationTracking
, | 1683 TimelineModel.TimelineModel.RecordType.StyleInvalidatorInvalidationTrackin
g, |
| 1684 WebInspector.TimelineModel.RecordType.StyleRecalcInvalidationTracking | 1684 TimelineModel.TimelineModel.RecordType.StyleRecalcInvalidationTracking |
| 1685 ]; | 1685 ]; |
| 1686 for (var invalidation of this._invalidationsOfTypes(types)) | 1686 for (var invalidation of this._invalidationsOfTypes(types)) |
| 1687 this._associateWithLastRecalcStyleEvent(invalidation); | 1687 this._associateWithLastRecalcStyleEvent(invalidation); |
| 1688 } | 1688 } |
| 1689 | 1689 |
| 1690 /** | 1690 /** |
| 1691 * @param {!WebInspector.InvalidationTrackingEvent} invalidation | 1691 * @param {!TimelineModel.InvalidationTrackingEvent} invalidation |
| 1692 */ | 1692 */ |
| 1693 _associateWithLastRecalcStyleEvent(invalidation) { | 1693 _associateWithLastRecalcStyleEvent(invalidation) { |
| 1694 if (invalidation.linkedRecalcStyleEvent) | 1694 if (invalidation.linkedRecalcStyleEvent) |
| 1695 return; | 1695 return; |
| 1696 | 1696 |
| 1697 var recordTypes = WebInspector.TimelineModel.RecordType; | 1697 var recordTypes = TimelineModel.TimelineModel.RecordType; |
| 1698 var recalcStyleFrameId = this._lastRecalcStyle.args['beginData']['frame']; | 1698 var recalcStyleFrameId = this._lastRecalcStyle.args['beginData']['frame']; |
| 1699 if (invalidation.type === recordTypes.StyleInvalidatorInvalidationTracking)
{ | 1699 if (invalidation.type === recordTypes.StyleInvalidatorInvalidationTracking)
{ |
| 1700 // Instead of calling _addInvalidationToEvent directly, we create syntheti
c | 1700 // Instead of calling _addInvalidationToEvent directly, we create syntheti
c |
| 1701 // StyleRecalcInvalidationTracking events which will be added in _addInval
idationToEvent. | 1701 // StyleRecalcInvalidationTracking events which will be added in _addInval
idationToEvent. |
| 1702 this._addSyntheticStyleRecalcInvalidations(this._lastRecalcStyle, recalcSt
yleFrameId, invalidation); | 1702 this._addSyntheticStyleRecalcInvalidations(this._lastRecalcStyle, recalcSt
yleFrameId, invalidation); |
| 1703 } else if (invalidation.type === recordTypes.ScheduleStyleInvalidationTracki
ng) { | 1703 } else if (invalidation.type === recordTypes.ScheduleStyleInvalidationTracki
ng) { |
| 1704 // ScheduleStyleInvalidationTracking events are only used for adding infor
mation to | 1704 // ScheduleStyleInvalidationTracking events are only used for adding infor
mation to |
| 1705 // StyleInvalidatorInvalidationTracking events. See: _addSyntheticStyleRec
alcInvalidations. | 1705 // StyleInvalidatorInvalidationTracking events. See: _addSyntheticStyleRec
alcInvalidations. |
| 1706 } else { | 1706 } else { |
| 1707 this._addInvalidationToEvent(this._lastRecalcStyle, recalcStyleFrameId, in
validation); | 1707 this._addInvalidationToEvent(this._lastRecalcStyle, recalcStyleFrameId, in
validation); |
| 1708 } | 1708 } |
| 1709 | 1709 |
| 1710 invalidation.linkedRecalcStyleEvent = true; | 1710 invalidation.linkedRecalcStyleEvent = true; |
| 1711 } | 1711 } |
| 1712 | 1712 |
| 1713 /** | 1713 /** |
| 1714 * @param {!WebInspector.TracingModel.Event} event | 1714 * @param {!SDK.TracingModel.Event} event |
| 1715 * @param {number} frameId | 1715 * @param {number} frameId |
| 1716 * @param {!WebInspector.InvalidationTrackingEvent} styleInvalidatorInvalidati
on | 1716 * @param {!TimelineModel.InvalidationTrackingEvent} styleInvalidatorInvalidat
ion |
| 1717 */ | 1717 */ |
| 1718 _addSyntheticStyleRecalcInvalidations(event, frameId, styleInvalidatorInvalida
tion) { | 1718 _addSyntheticStyleRecalcInvalidations(event, frameId, styleInvalidatorInvalida
tion) { |
| 1719 if (!styleInvalidatorInvalidation.invalidationList) { | 1719 if (!styleInvalidatorInvalidation.invalidationList) { |
| 1720 this._addSyntheticStyleRecalcInvalidation( | 1720 this._addSyntheticStyleRecalcInvalidation( |
| 1721 styleInvalidatorInvalidation._tracingEvent, styleInvalidatorInvalidati
on); | 1721 styleInvalidatorInvalidation._tracingEvent, styleInvalidatorInvalidati
on); |
| 1722 return; | 1722 return; |
| 1723 } | 1723 } |
| 1724 if (!styleInvalidatorInvalidation.nodeId) { | 1724 if (!styleInvalidatorInvalidation.nodeId) { |
| 1725 console.error('Invalidation lacks node information.'); | 1725 console.error('Invalidation lacks node information.'); |
| 1726 console.error(invalidation); | 1726 console.error(invalidation); |
| 1727 return; | 1727 return; |
| 1728 } | 1728 } |
| 1729 for (var i = 0; i < styleInvalidatorInvalidation.invalidationList.length; i+
+) { | 1729 for (var i = 0; i < styleInvalidatorInvalidation.invalidationList.length; i+
+) { |
| 1730 var setId = styleInvalidatorInvalidation.invalidationList[i]['id']; | 1730 var setId = styleInvalidatorInvalidation.invalidationList[i]['id']; |
| 1731 var lastScheduleStyleRecalculation; | 1731 var lastScheduleStyleRecalculation; |
| 1732 var nodeInvalidations = this._invalidationsByNodeId[styleInvalidatorInvali
dation.nodeId] || []; | 1732 var nodeInvalidations = this._invalidationsByNodeId[styleInvalidatorInvali
dation.nodeId] || []; |
| 1733 for (var j = 0; j < nodeInvalidations.length; j++) { | 1733 for (var j = 0; j < nodeInvalidations.length; j++) { |
| 1734 var invalidation = nodeInvalidations[j]; | 1734 var invalidation = nodeInvalidations[j]; |
| 1735 if (invalidation.frame !== frameId || invalidation.invalidationSet !== s
etId || | 1735 if (invalidation.frame !== frameId || invalidation.invalidationSet !== s
etId || |
| 1736 invalidation.type !== WebInspector.TimelineModel.RecordType.Schedule
StyleInvalidationTracking) | 1736 invalidation.type !== TimelineModel.TimelineModel.RecordType.Schedul
eStyleInvalidationTracking) |
| 1737 continue; | 1737 continue; |
| 1738 lastScheduleStyleRecalculation = invalidation; | 1738 lastScheduleStyleRecalculation = invalidation; |
| 1739 } | 1739 } |
| 1740 if (!lastScheduleStyleRecalculation) { | 1740 if (!lastScheduleStyleRecalculation) { |
| 1741 console.error('Failed to lookup the event that scheduled a style invalid
ator invalidation.'); | 1741 console.error('Failed to lookup the event that scheduled a style invalid
ator invalidation.'); |
| 1742 continue; | 1742 continue; |
| 1743 } | 1743 } |
| 1744 this._addSyntheticStyleRecalcInvalidation( | 1744 this._addSyntheticStyleRecalcInvalidation( |
| 1745 lastScheduleStyleRecalculation._tracingEvent, styleInvalidatorInvalida
tion); | 1745 lastScheduleStyleRecalculation._tracingEvent, styleInvalidatorInvalida
tion); |
| 1746 } | 1746 } |
| 1747 } | 1747 } |
| 1748 | 1748 |
| 1749 /** | 1749 /** |
| 1750 * @param {!WebInspector.TracingModel.Event} baseEvent | 1750 * @param {!SDK.TracingModel.Event} baseEvent |
| 1751 * @param {!WebInspector.InvalidationTrackingEvent} styleInvalidatorInvalidati
on | 1751 * @param {!TimelineModel.InvalidationTrackingEvent} styleInvalidatorInvalidat
ion |
| 1752 */ | 1752 */ |
| 1753 _addSyntheticStyleRecalcInvalidation(baseEvent, styleInvalidatorInvalidation)
{ | 1753 _addSyntheticStyleRecalcInvalidation(baseEvent, styleInvalidatorInvalidation)
{ |
| 1754 var invalidation = new WebInspector.InvalidationTrackingEvent(baseEvent); | 1754 var invalidation = new TimelineModel.InvalidationTrackingEvent(baseEvent); |
| 1755 invalidation.type = WebInspector.TimelineModel.RecordType.StyleRecalcInvalid
ationTracking; | 1755 invalidation.type = TimelineModel.TimelineModel.RecordType.StyleRecalcInvali
dationTracking; |
| 1756 if (styleInvalidatorInvalidation.cause.reason) | 1756 if (styleInvalidatorInvalidation.cause.reason) |
| 1757 invalidation.cause.reason = styleInvalidatorInvalidation.cause.reason; | 1757 invalidation.cause.reason = styleInvalidatorInvalidation.cause.reason; |
| 1758 if (styleInvalidatorInvalidation.selectorPart) | 1758 if (styleInvalidatorInvalidation.selectorPart) |
| 1759 invalidation.selectorPart = styleInvalidatorInvalidation.selectorPart; | 1759 invalidation.selectorPart = styleInvalidatorInvalidation.selectorPart; |
| 1760 | 1760 |
| 1761 this.addInvalidation(invalidation); | 1761 this.addInvalidation(invalidation); |
| 1762 if (!invalidation.linkedRecalcStyleEvent) | 1762 if (!invalidation.linkedRecalcStyleEvent) |
| 1763 this._associateWithLastRecalcStyleEvent(invalidation); | 1763 this._associateWithLastRecalcStyleEvent(invalidation); |
| 1764 } | 1764 } |
| 1765 | 1765 |
| 1766 /** | 1766 /** |
| 1767 * @param {!WebInspector.TracingModel.Event} layoutEvent | 1767 * @param {!SDK.TracingModel.Event} layoutEvent |
| 1768 */ | 1768 */ |
| 1769 didLayout(layoutEvent) { | 1769 didLayout(layoutEvent) { |
| 1770 var layoutFrameId = layoutEvent.args['beginData']['frame']; | 1770 var layoutFrameId = layoutEvent.args['beginData']['frame']; |
| 1771 for (var invalidation of this._invalidationsOfTypes( | 1771 for (var invalidation of this._invalidationsOfTypes( |
| 1772 [WebInspector.TimelineModel.RecordType.LayoutInvalidationTracking])
) { | 1772 [TimelineModel.TimelineModel.RecordType.LayoutInvalidationTracking]
)) { |
| 1773 if (invalidation.linkedLayoutEvent) | 1773 if (invalidation.linkedLayoutEvent) |
| 1774 continue; | 1774 continue; |
| 1775 this._addInvalidationToEvent(layoutEvent, layoutFrameId, invalidation); | 1775 this._addInvalidationToEvent(layoutEvent, layoutFrameId, invalidation); |
| 1776 invalidation.linkedLayoutEvent = true; | 1776 invalidation.linkedLayoutEvent = true; |
| 1777 } | 1777 } |
| 1778 } | 1778 } |
| 1779 | 1779 |
| 1780 /** | 1780 /** |
| 1781 * @param {!WebInspector.TracingModel.Event} paintEvent | 1781 * @param {!SDK.TracingModel.Event} paintEvent |
| 1782 */ | 1782 */ |
| 1783 didPaint(paintEvent) { | 1783 didPaint(paintEvent) { |
| 1784 this._didPaint = true; | 1784 this._didPaint = true; |
| 1785 | 1785 |
| 1786 // If a paint doesn't have a corresponding graphics layer id, it paints | 1786 // If a paint doesn't have a corresponding graphics layer id, it paints |
| 1787 // into its parent so add an effectivePaintId to these events. | 1787 // into its parent so add an effectivePaintId to these events. |
| 1788 var layerId = paintEvent.args['data']['layerId']; | 1788 var layerId = paintEvent.args['data']['layerId']; |
| 1789 if (layerId) | 1789 if (layerId) |
| 1790 this._lastPaintWithLayer = paintEvent; | 1790 this._lastPaintWithLayer = paintEvent; |
| 1791 // Quietly discard top-level paints without layerId, as these are likely | 1791 // Quietly discard top-level paints without layerId, as these are likely |
| 1792 // to come from overlay. | 1792 // to come from overlay. |
| 1793 if (!this._lastPaintWithLayer) | 1793 if (!this._lastPaintWithLayer) |
| 1794 return; | 1794 return; |
| 1795 | 1795 |
| 1796 var effectivePaintId = this._lastPaintWithLayer.args['data']['nodeId']; | 1796 var effectivePaintId = this._lastPaintWithLayer.args['data']['nodeId']; |
| 1797 var paintFrameId = paintEvent.args['data']['frame']; | 1797 var paintFrameId = paintEvent.args['data']['frame']; |
| 1798 var types = [ | 1798 var types = [ |
| 1799 WebInspector.TimelineModel.RecordType.StyleRecalcInvalidationTracking, | 1799 TimelineModel.TimelineModel.RecordType.StyleRecalcInvalidationTracking, |
| 1800 WebInspector.TimelineModel.RecordType.LayoutInvalidationTracking, | 1800 TimelineModel.TimelineModel.RecordType.LayoutInvalidationTracking, |
| 1801 WebInspector.TimelineModel.RecordType.PaintInvalidationTracking, | 1801 TimelineModel.TimelineModel.RecordType.PaintInvalidationTracking, |
| 1802 WebInspector.TimelineModel.RecordType.ScrollInvalidationTracking | 1802 TimelineModel.TimelineModel.RecordType.ScrollInvalidationTracking |
| 1803 ]; | 1803 ]; |
| 1804 for (var invalidation of this._invalidationsOfTypes(types)) { | 1804 for (var invalidation of this._invalidationsOfTypes(types)) { |
| 1805 if (invalidation.paintId === effectivePaintId) | 1805 if (invalidation.paintId === effectivePaintId) |
| 1806 this._addInvalidationToEvent(paintEvent, paintFrameId, invalidation); | 1806 this._addInvalidationToEvent(paintEvent, paintFrameId, invalidation); |
| 1807 } | 1807 } |
| 1808 } | 1808 } |
| 1809 | 1809 |
| 1810 /** | 1810 /** |
| 1811 * @param {!WebInspector.TracingModel.Event} event | 1811 * @param {!SDK.TracingModel.Event} event |
| 1812 * @param {number} eventFrameId | 1812 * @param {number} eventFrameId |
| 1813 * @param {!WebInspector.InvalidationTrackingEvent} invalidation | 1813 * @param {!TimelineModel.InvalidationTrackingEvent} invalidation |
| 1814 */ | 1814 */ |
| 1815 _addInvalidationToEvent(event, eventFrameId, invalidation) { | 1815 _addInvalidationToEvent(event, eventFrameId, invalidation) { |
| 1816 if (eventFrameId !== invalidation.frame) | 1816 if (eventFrameId !== invalidation.frame) |
| 1817 return; | 1817 return; |
| 1818 if (!event[WebInspector.InvalidationTracker._invalidationTrackingEventsSymbo
l]) | 1818 if (!event[TimelineModel.InvalidationTracker._invalidationTrackingEventsSymb
ol]) |
| 1819 event[WebInspector.InvalidationTracker._invalidationTrackingEventsSymbol]
= [invalidation]; | 1819 event[TimelineModel.InvalidationTracker._invalidationTrackingEventsSymbol]
= [invalidation]; |
| 1820 else | 1820 else |
| 1821 event[WebInspector.InvalidationTracker._invalidationTrackingEventsSymbol].
push(invalidation); | 1821 event[TimelineModel.InvalidationTracker._invalidationTrackingEventsSymbol]
.push(invalidation); |
| 1822 } | 1822 } |
| 1823 | 1823 |
| 1824 /** | 1824 /** |
| 1825 * @param {!Array.<string>=} types | 1825 * @param {!Array.<string>=} types |
| 1826 * @return {!Iterator.<!WebInspector.InvalidationTrackingEvent>} | 1826 * @return {!Iterator.<!TimelineModel.InvalidationTrackingEvent>} |
| 1827 */ | 1827 */ |
| 1828 _invalidationsOfTypes(types) { | 1828 _invalidationsOfTypes(types) { |
| 1829 var invalidations = this._invalidations; | 1829 var invalidations = this._invalidations; |
| 1830 if (!types) | 1830 if (!types) |
| 1831 types = Object.keys(invalidations); | 1831 types = Object.keys(invalidations); |
| 1832 function* generator() { | 1832 function* generator() { |
| 1833 for (var i = 0; i < types.length; ++i) { | 1833 for (var i = 0; i < types.length; ++i) { |
| 1834 var invalidationList = invalidations[types[i]] || []; | 1834 var invalidationList = invalidations[types[i]] || []; |
| 1835 for (var j = 0; j < invalidationList.length; ++j) | 1835 for (var j = 0; j < invalidationList.length; ++j) |
| 1836 yield invalidationList[j]; | 1836 yield invalidationList[j]; |
| 1837 } | 1837 } |
| 1838 } | 1838 } |
| 1839 return generator(); | 1839 return generator(); |
| 1840 } | 1840 } |
| 1841 | 1841 |
| 1842 _startNewFrameIfNeeded() { | 1842 _startNewFrameIfNeeded() { |
| 1843 if (!this._didPaint) | 1843 if (!this._didPaint) |
| 1844 return; | 1844 return; |
| 1845 | 1845 |
| 1846 this._initializePerFrameState(); | 1846 this._initializePerFrameState(); |
| 1847 } | 1847 } |
| 1848 | 1848 |
| 1849 _initializePerFrameState() { | 1849 _initializePerFrameState() { |
| 1850 /** @type {!Object.<string, !Array.<!WebInspector.InvalidationTrackingEvent>
>} */ | 1850 /** @type {!Object.<string, !Array.<!TimelineModel.InvalidationTrackingEvent
>>} */ |
| 1851 this._invalidations = {}; | 1851 this._invalidations = {}; |
| 1852 /** @type {!Object.<number, !Array.<!WebInspector.InvalidationTrackingEvent>
>} */ | 1852 /** @type {!Object.<number, !Array.<!TimelineModel.InvalidationTrackingEvent
>>} */ |
| 1853 this._invalidationsByNodeId = {}; | 1853 this._invalidationsByNodeId = {}; |
| 1854 | 1854 |
| 1855 this._lastRecalcStyle = null; | 1855 this._lastRecalcStyle = null; |
| 1856 this._lastPaintWithLayer = null; | 1856 this._lastPaintWithLayer = null; |
| 1857 this._didPaint = false; | 1857 this._didPaint = false; |
| 1858 } | 1858 } |
| 1859 }; | 1859 }; |
| 1860 | 1860 |
| 1861 WebInspector.InvalidationTracker._invalidationTrackingEventsSymbol = Symbol('inv
alidationTrackingEvents'); | 1861 TimelineModel.InvalidationTracker._invalidationTrackingEventsSymbol = Symbol('in
validationTrackingEvents'); |
| 1862 | 1862 |
| 1863 /** | 1863 /** |
| 1864 * @unrestricted | 1864 * @unrestricted |
| 1865 */ | 1865 */ |
| 1866 WebInspector.TimelineAsyncEventTracker = class { | 1866 TimelineModel.TimelineAsyncEventTracker = class { |
| 1867 constructor() { | 1867 constructor() { |
| 1868 WebInspector.TimelineAsyncEventTracker._initialize(); | 1868 TimelineModel.TimelineAsyncEventTracker._initialize(); |
| 1869 /** @type {!Map<!WebInspector.TimelineModel.RecordType, !Map<string, !WebIns
pector.TracingModel.Event>>} */ | 1869 /** @type {!Map<!TimelineModel.TimelineModel.RecordType, !Map<string, !SDK.T
racingModel.Event>>} */ |
| 1870 this._initiatorByType = new Map(); | 1870 this._initiatorByType = new Map(); |
| 1871 for (var initiator of WebInspector.TimelineAsyncEventTracker._asyncEvents.ke
ys()) | 1871 for (var initiator of TimelineModel.TimelineAsyncEventTracker._asyncEvents.k
eys()) |
| 1872 this._initiatorByType.set(initiator, new Map()); | 1872 this._initiatorByType.set(initiator, new Map()); |
| 1873 } | 1873 } |
| 1874 | 1874 |
| 1875 static _initialize() { | 1875 static _initialize() { |
| 1876 if (WebInspector.TimelineAsyncEventTracker._asyncEvents) | 1876 if (TimelineModel.TimelineAsyncEventTracker._asyncEvents) |
| 1877 return; | 1877 return; |
| 1878 var events = new Map(); | 1878 var events = new Map(); |
| 1879 var type = WebInspector.TimelineModel.RecordType; | 1879 var type = TimelineModel.TimelineModel.RecordType; |
| 1880 | 1880 |
| 1881 events.set(type.TimerInstall, {causes: [type.TimerFire], joinBy: 'timerId'})
; | 1881 events.set(type.TimerInstall, {causes: [type.TimerFire], joinBy: 'timerId'})
; |
| 1882 events.set( | 1882 events.set( |
| 1883 type.ResourceSendRequest, | 1883 type.ResourceSendRequest, |
| 1884 {causes: [type.ResourceReceiveResponse, type.ResourceReceivedData, type.
ResourceFinish], joinBy: 'requestId'}); | 1884 {causes: [type.ResourceReceiveResponse, type.ResourceReceivedData, type.
ResourceFinish], joinBy: 'requestId'}); |
| 1885 events.set(type.RequestAnimationFrame, {causes: [type.FireAnimationFrame], j
oinBy: 'id'}); | 1885 events.set(type.RequestAnimationFrame, {causes: [type.FireAnimationFrame], j
oinBy: 'id'}); |
| 1886 events.set(type.RequestIdleCallback, {causes: [type.FireIdleCallback], joinB
y: 'id'}); | 1886 events.set(type.RequestIdleCallback, {causes: [type.FireIdleCallback], joinB
y: 'id'}); |
| 1887 events.set(type.WebSocketCreate, { | 1887 events.set(type.WebSocketCreate, { |
| 1888 causes: [type.WebSocketSendHandshakeRequest, type.WebSocketReceiveHandshak
eResponse, type.WebSocketDestroy], | 1888 causes: [type.WebSocketSendHandshakeRequest, type.WebSocketReceiveHandshak
eResponse, type.WebSocketDestroy], |
| 1889 joinBy: 'identifier' | 1889 joinBy: 'identifier' |
| 1890 }); | 1890 }); |
| 1891 | 1891 |
| 1892 WebInspector.TimelineAsyncEventTracker._asyncEvents = events; | 1892 TimelineModel.TimelineAsyncEventTracker._asyncEvents = events; |
| 1893 /** @type {!Map<!WebInspector.TimelineModel.RecordType, !WebInspector.Timeli
neModel.RecordType>} */ | 1893 /** @type {!Map<!TimelineModel.TimelineModel.RecordType, !TimelineModel.Time
lineModel.RecordType>} */ |
| 1894 WebInspector.TimelineAsyncEventTracker._typeToInitiator = new Map(); | 1894 TimelineModel.TimelineAsyncEventTracker._typeToInitiator = new Map(); |
| 1895 for (var entry of events) { | 1895 for (var entry of events) { |
| 1896 var types = entry[1].causes; | 1896 var types = entry[1].causes; |
| 1897 for (type of types) | 1897 for (type of types) |
| 1898 WebInspector.TimelineAsyncEventTracker._typeToInitiator.set(type, entry[
0]); | 1898 TimelineModel.TimelineAsyncEventTracker._typeToInitiator.set(type, entry
[0]); |
| 1899 } | 1899 } |
| 1900 } | 1900 } |
| 1901 | 1901 |
| 1902 /** | 1902 /** |
| 1903 * @param {!WebInspector.TracingModel.Event} event | 1903 * @param {!SDK.TracingModel.Event} event |
| 1904 */ | 1904 */ |
| 1905 processEvent(event) { | 1905 processEvent(event) { |
| 1906 var initiatorType = WebInspector.TimelineAsyncEventTracker._typeToInitiator.
get( | 1906 var initiatorType = TimelineModel.TimelineAsyncEventTracker._typeToInitiator
.get( |
| 1907 /** @type {!WebInspector.TimelineModel.RecordType} */ (event.name)); | 1907 /** @type {!TimelineModel.TimelineModel.RecordType} */ (event.name)); |
| 1908 var isInitiator = !initiatorType; | 1908 var isInitiator = !initiatorType; |
| 1909 if (!initiatorType) | 1909 if (!initiatorType) |
| 1910 initiatorType = /** @type {!WebInspector.TimelineModel.RecordType} */ (eve
nt.name); | 1910 initiatorType = /** @type {!TimelineModel.TimelineModel.RecordType} */ (ev
ent.name); |
| 1911 var initiatorInfo = WebInspector.TimelineAsyncEventTracker._asyncEvents.get(
initiatorType); | 1911 var initiatorInfo = TimelineModel.TimelineAsyncEventTracker._asyncEvents.get
(initiatorType); |
| 1912 if (!initiatorInfo) | 1912 if (!initiatorInfo) |
| 1913 return; | 1913 return; |
| 1914 var id = event.args['data'][initiatorInfo.joinBy]; | 1914 var id = event.args['data'][initiatorInfo.joinBy]; |
| 1915 if (!id) | 1915 if (!id) |
| 1916 return; | 1916 return; |
| 1917 /** @type {!Map<string, !WebInspector.TracingModel.Event>|undefined} */ | 1917 /** @type {!Map<string, !SDK.TracingModel.Event>|undefined} */ |
| 1918 var initiatorMap = this._initiatorByType.get(initiatorType); | 1918 var initiatorMap = this._initiatorByType.get(initiatorType); |
| 1919 if (isInitiator) | 1919 if (isInitiator) |
| 1920 initiatorMap.set(id, event); | 1920 initiatorMap.set(id, event); |
| 1921 else | 1921 else |
| 1922 WebInspector.TimelineData.forEvent(event).setInitiator(initiatorMap.get(id
) || null); | 1922 TimelineModel.TimelineData.forEvent(event).setInitiator(initiatorMap.get(i
d) || null); |
| 1923 } | 1923 } |
| 1924 }; | 1924 }; |
| 1925 | 1925 |
| 1926 | 1926 |
| 1927 WebInspector.TimelineData = class { | 1927 TimelineModel.TimelineData = class { |
| 1928 constructor() { | 1928 constructor() { |
| 1929 /** @type {?string} */ | 1929 /** @type {?string} */ |
| 1930 this.warning = null; | 1930 this.warning = null; |
| 1931 /** @type {?Element} */ | 1931 /** @type {?Element} */ |
| 1932 this.previewElement = null; | 1932 this.previewElement = null; |
| 1933 /** @type {?string} */ | 1933 /** @type {?string} */ |
| 1934 this.url = null; | 1934 this.url = null; |
| 1935 /** @type {number} */ | 1935 /** @type {number} */ |
| 1936 this.backendNodeId = 0; | 1936 this.backendNodeId = 0; |
| 1937 /** @type {?Array<!Protocol.Runtime.CallFrame>} */ | 1937 /** @type {?Array<!Protocol.Runtime.CallFrame>} */ |
| 1938 this.stackTrace = null; | 1938 this.stackTrace = null; |
| 1939 /** @type {?WebInspector.TracingModel.ObjectSnapshot} */ | 1939 /** @type {?SDK.TracingModel.ObjectSnapshot} */ |
| 1940 this.picture = null; | 1940 this.picture = null; |
| 1941 /** @type {?WebInspector.TracingModel.Event} */ | 1941 /** @type {?SDK.TracingModel.Event} */ |
| 1942 this._initiator = null; | 1942 this._initiator = null; |
| 1943 this.frameId = ''; | 1943 this.frameId = ''; |
| 1944 /** @type {number|undefined} */ | 1944 /** @type {number|undefined} */ |
| 1945 this.timeWaitingForMainThread; | 1945 this.timeWaitingForMainThread; |
| 1946 } | 1946 } |
| 1947 | 1947 |
| 1948 /** | 1948 /** |
| 1949 * @param {!WebInspector.TracingModel.Event} initiator | 1949 * @param {!SDK.TracingModel.Event} initiator |
| 1950 */ | 1950 */ |
| 1951 setInitiator(initiator) { | 1951 setInitiator(initiator) { |
| 1952 this._initiator = initiator; | 1952 this._initiator = initiator; |
| 1953 if (!initiator || this.url) | 1953 if (!initiator || this.url) |
| 1954 return; | 1954 return; |
| 1955 var initiatorURL = WebInspector.TimelineData.forEvent(initiator).url; | 1955 var initiatorURL = TimelineModel.TimelineData.forEvent(initiator).url; |
| 1956 if (initiatorURL) | 1956 if (initiatorURL) |
| 1957 this.url = initiatorURL; | 1957 this.url = initiatorURL; |
| 1958 } | 1958 } |
| 1959 | 1959 |
| 1960 /** | 1960 /** |
| 1961 * @return {?WebInspector.TracingModel.Event} | 1961 * @return {?SDK.TracingModel.Event} |
| 1962 */ | 1962 */ |
| 1963 initiator() { | 1963 initiator() { |
| 1964 return this._initiator; | 1964 return this._initiator; |
| 1965 } | 1965 } |
| 1966 | 1966 |
| 1967 /** | 1967 /** |
| 1968 * @return {?Protocol.Runtime.CallFrame} | 1968 * @return {?Protocol.Runtime.CallFrame} |
| 1969 */ | 1969 */ |
| 1970 topFrame() { | 1970 topFrame() { |
| 1971 var stackTrace = this.stackTraceForSelfOrInitiator(); | 1971 var stackTrace = this.stackTraceForSelfOrInitiator(); |
| 1972 return stackTrace && stackTrace[0] || null; | 1972 return stackTrace && stackTrace[0] || null; |
| 1973 } | 1973 } |
| 1974 | 1974 |
| 1975 /** | 1975 /** |
| 1976 * @return {?Array<!Protocol.Runtime.CallFrame>} | 1976 * @return {?Array<!Protocol.Runtime.CallFrame>} |
| 1977 */ | 1977 */ |
| 1978 stackTraceForSelfOrInitiator() { | 1978 stackTraceForSelfOrInitiator() { |
| 1979 return this.stackTrace || (this._initiator && WebInspector.TimelineData.forE
vent(this._initiator).stackTrace); | 1979 return this.stackTrace || (this._initiator && TimelineModel.TimelineData.for
Event(this._initiator).stackTrace); |
| 1980 } | 1980 } |
| 1981 | 1981 |
| 1982 /** | 1982 /** |
| 1983 * @param {!WebInspector.TracingModel.Event} event | 1983 * @param {!SDK.TracingModel.Event} event |
| 1984 * @return {!WebInspector.TimelineData} | 1984 * @return {!TimelineModel.TimelineData} |
| 1985 */ | 1985 */ |
| 1986 static forEvent(event) { | 1986 static forEvent(event) { |
| 1987 var data = event[WebInspector.TimelineData._symbol]; | 1987 var data = event[TimelineModel.TimelineData._symbol]; |
| 1988 if (!data) { | 1988 if (!data) { |
| 1989 data = new WebInspector.TimelineData(); | 1989 data = new TimelineModel.TimelineData(); |
| 1990 event[WebInspector.TimelineData._symbol] = data; | 1990 event[TimelineModel.TimelineData._symbol] = data; |
| 1991 } | 1991 } |
| 1992 return data; | 1992 return data; |
| 1993 } | 1993 } |
| 1994 }; | 1994 }; |
| 1995 | 1995 |
| 1996 WebInspector.TimelineData._symbol = Symbol('timelineData'); | 1996 TimelineModel.TimelineData._symbol = Symbol('timelineData'); |
| OLD | NEW |