Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 /** | 5 /** |
| 6 * @param {!WebInspector.TracingModel} tracingModel | 6 * @param {!WebInspector.TracingModel} tracingModel |
| 7 * @constructor | 7 * @constructor |
| 8 */ | 8 */ |
| 9 WebInspector.TracingTimelineModel = function(tracingModel) | 9 WebInspector.TracingTimelineModel = function(tracingModel) |
| 10 { | 10 { |
| 11 this._tracingModel = tracingModel; | 11 this._tracingModel = tracingModel; |
| 12 this._mainThreadEvents = []; | 12 this._mainThreadEvents = []; |
| 13 this._inspectedTargetEvents = []; | |
| 13 } | 14 } |
| 14 | 15 |
| 15 WebInspector.TracingTimelineModel.RecordType = { | 16 WebInspector.TracingTimelineModel.RecordType = { |
| 16 Program: "Program", | 17 Program: "Program", |
| 17 EventDispatch: "EventDispatch", | 18 EventDispatch: "EventDispatch", |
| 18 | 19 |
| 19 GPUTask: "GPUTask", | 20 GPUTask: "GPUTask", |
| 20 | 21 |
| 21 RequestMainThreadFrame: "RequestMainThreadFrame", | 22 RequestMainThreadFrame: "RequestMainThreadFrame", |
| 22 BeginFrame: "BeginFrame", | 23 BeginFrame: "BeginFrame", |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 81 | 82 |
| 82 DecodeImage: "Decode Image", | 83 DecodeImage: "Decode Image", |
| 83 ResizeImage: "Resize Image", | 84 ResizeImage: "Resize Image", |
| 84 DrawLazyPixelRef: "Draw LazyPixelRef", | 85 DrawLazyPixelRef: "Draw LazyPixelRef", |
| 85 DecodeLazyPixelRef: "Decode LazyPixelRef", | 86 DecodeLazyPixelRef: "Decode LazyPixelRef", |
| 86 | 87 |
| 87 LazyPixelRef: "LazyPixelRef", | 88 LazyPixelRef: "LazyPixelRef", |
| 88 LayerTreeHostImplSnapshot: "cc::LayerTreeHostImpl" | 89 LayerTreeHostImplSnapshot: "cc::LayerTreeHostImpl" |
| 89 }; | 90 }; |
| 90 | 91 |
| 91 | |
| 92 WebInspector.TracingTimelineModel.prototype = { | 92 WebInspector.TracingTimelineModel.prototype = { |
| 93 willStartRecordingTraceEvents: function() | 93 willStartRecordingTraceEvents: function() |
|
caseq
2014/06/04 13:08:59
nit: I wonder if we really need this one?
yurys
2014/06/04 13:22:16
This will be merged with one on TimelineModel even
| |
| 94 { | 94 { |
| 95 this._mainThreadEvents = []; | 95 this._mainThreadEvents = []; |
| 96 this._inspectedTargetEvents = []; | |
| 96 }, | 97 }, |
| 97 | 98 |
| 98 didStopRecordingTraceEvents: function() | 99 didStopRecordingTraceEvents: function() |
|
caseq
2014/06/04 13:08:59
Can we get it as an event from TracingModel instea
yurys
2014/06/04 13:22:16
I was going to do this in a separate change. Timel
| |
| 99 { | 100 { |
| 100 var events = this._tracingModel.inspectedTargetEvents(); | 101 var events = this._tracingModel.devtoolsMetadataEvents(); |
| 102 events.sort(WebInspector.TracingModel.Event.compareStartTime); | |
| 103 | |
| 101 this._resetProcessingState(); | 104 this._resetProcessingState(); |
| 102 for (var i = 0, length = events.length; i < length; i++) | 105 for (var i = 0, length = events.length; i < length; i++) { |
| 103 this._processEvent(events[i]); | 106 var event = events[i]; |
| 107 var process = event.thread.process(); | |
| 108 var startTime = event.startTime; | |
| 109 | |
| 110 var endTime = null; | |
|
caseq
2014/06/04 13:08:59
nit: endTime = Infinity, so that you don't have sp
yurys
2014/06/04 13:22:16
Done.
| |
| 111 if (i + 1 < length) | |
| 112 endTime = events[i + 1].startTime; | |
| 113 | |
| 114 this._mainThread = event.thread; | |
|
caseq
2014/06/04 13:08:59
Can we rather bind this to processThreadEvents as
yurys
2014/06/04 13:22:16
Done.
| |
| 115 process.sortedThreads().forEach(this._processThreadEvents.bind(this, startTime, endTime)); | |
| 116 this._mainThread = null; | |
| 117 } | |
| 104 this._resetProcessingState(); | 118 this._resetProcessingState(); |
| 119 | |
| 120 this._inspectedTargetEvents.sort(WebInspector.TracingModel.Event.compare StartTime); | |
| 105 }, | 121 }, |
| 106 | 122 |
| 107 /** | 123 /** |
| 108 * @return {?number} | 124 * @return {?number} |
| 109 */ | 125 */ |
| 110 minimumRecordTime: function() | 126 minimumRecordTime: function() |
| 111 { | 127 { |
| 112 return this._tracingModel.minimumRecordTime(); | 128 return this._tracingModel.minimumRecordTime(); |
| 113 }, | 129 }, |
| 114 | 130 |
| 115 /** | 131 /** |
| 116 * @return {?number} | 132 * @return {?number} |
| 117 */ | 133 */ |
| 118 maximumRecordTime: function() | 134 maximumRecordTime: function() |
| 119 { | 135 { |
| 120 return this._tracingModel.maximumRecordTime(); | 136 return this._tracingModel.maximumRecordTime(); |
| 121 }, | 137 }, |
| 122 | 138 |
| 123 /** | 139 /** |
| 124 * @return {!Array.<!WebInspector.TracingModel.Event>} | 140 * @return {!Array.<!WebInspector.TracingModel.Event>} |
| 125 */ | 141 */ |
| 126 inspectedTargetEvents: function() | 142 inspectedTargetEvents: function() |
| 127 { | 143 { |
| 128 return this._tracingModel.inspectedTargetEvents(); | 144 return this._inspectedTargetEvents; |
| 129 }, | 145 }, |
| 130 | 146 |
| 131 /** | 147 /** |
| 132 * @return {!Array.<!WebInspector.TracingModel.Event>} | 148 * @return {!Array.<!WebInspector.TracingModel.Event>} |
| 133 */ | 149 */ |
| 134 mainThreadEvents: function() | 150 mainThreadEvents: function() |
| 135 { | 151 { |
| 136 return this._mainThreadEvents; | 152 return this._mainThreadEvents; |
| 137 }, | 153 }, |
| 138 | 154 |
| 139 _resetProcessingState: function() | 155 _resetProcessingState: function() |
| 140 { | 156 { |
| 157 this._mainThread = null; | |
| 158 | |
| 141 this._sendRequestEvents = {}; | 159 this._sendRequestEvents = {}; |
| 142 this._timerEvents = {}; | 160 this._timerEvents = {}; |
| 143 this._requestAnimationFrameEvents = {}; | 161 this._requestAnimationFrameEvents = {}; |
| 144 this._layoutInvalidate = {}; | 162 this._layoutInvalidate = {}; |
| 145 this._lastScheduleStyleRecalculation = {}; | 163 this._lastScheduleStyleRecalculation = {}; |
| 146 this._webSocketCreateEvents = {}; | 164 this._webSocketCreateEvents = {}; |
| 147 this._paintImageEventByPixelRefId = {}; | 165 this._paintImageEventByPixelRefId = {}; |
| 148 | 166 |
| 149 this._lastRecalculateStylesEvent = null; | 167 this._lastRecalculateStylesEvent = null; |
| 150 this._currentScriptEvent = null; | 168 this._currentScriptEvent = null; |
| 151 this._eventStack = []; | 169 this._eventStack = []; |
| 152 }, | 170 }, |
| 153 | 171 |
| 154 /** | 172 /** |
| 173 * @param {number} startTime | |
| 174 * @param {?number} endTime | |
| 175 * @param {!WebInspector.TracingModel.Thread} thread | |
| 176 */ | |
| 177 _processThreadEvents: function(startTime, endTime, thread) | |
| 178 { | |
| 179 var events = thread.events(); | |
| 180 var i = 0 | |
| 181 var length = events.length; | |
| 182 while (i < length && events[i].startTime < startTime) | |
|
caseq
2014/06/04 13:08:59
nit: i = events.upperBound(startTime, function (ti
yurys
2014/06/04 13:22:16
Done. Changed to use lowerBound
| |
| 183 i++; | |
| 184 | |
| 185 this._eventStack = []; | |
|
caseq
2014/06/04 13:08:59
unused?
yurys
2014/06/04 13:22:16
It is used. This is to make sure that event stack
| |
| 186 for (; i < length; i++) { | |
| 187 var event = events[i]; | |
| 188 if (endTime && event.startTime >= endTime) | |
| 189 break; | |
| 190 this._processEvent(event); | |
| 191 if (thread === this._mainThread) | |
| 192 this._mainThreadEvents.push(event); | |
| 193 this._inspectedTargetEvents.push(event); | |
| 194 } | |
| 195 }, | |
| 196 | |
| 197 /** | |
| 155 * @param {!WebInspector.TracingModel.Event} event | 198 * @param {!WebInspector.TracingModel.Event} event |
| 156 */ | 199 */ |
| 157 _processEvent: function(event) | 200 _processEvent: function(event) |
| 158 { | 201 { |
| 159 var recordTypes = WebInspector.TracingTimelineModel.RecordType; | 202 var recordTypes = WebInspector.TracingTimelineModel.RecordType; |
| 160 | 203 |
| 161 var eventStack = this._eventStack; | 204 var eventStack = this._eventStack; |
| 162 while (eventStack.length && eventStack.peekLast().endTime < event.startT ime) | 205 while (eventStack.length && eventStack.peekLast().endTime < event.startT ime) |
| 163 eventStack.pop(); | 206 eventStack.pop(); |
| 164 var duration = event.duration; | 207 var duration = event.duration; |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 251 case recordTypes.EvaluateScript: | 294 case recordTypes.EvaluateScript: |
| 252 case recordTypes.FunctionCall: | 295 case recordTypes.FunctionCall: |
| 253 if (!this._currentScriptEvent) | 296 if (!this._currentScriptEvent) |
| 254 this._currentScriptEvent = event; | 297 this._currentScriptEvent = event; |
| 255 break; | 298 break; |
| 256 | 299 |
| 257 case recordTypes.SetLayerTreeId: | 300 case recordTypes.SetLayerTreeId: |
| 258 this._inspectedTargetLayerTreeId = event.args["layerTreeId"]; | 301 this._inspectedTargetLayerTreeId = event.args["layerTreeId"]; |
| 259 break; | 302 break; |
| 260 | 303 |
| 261 case recordTypes.TracingStartedInPage: | |
| 262 this._mainThread = event.thread; | |
| 263 break; | |
| 264 | |
| 265 case recordTypes.Paint: | 304 case recordTypes.Paint: |
| 266 case recordTypes.ScrollLayer: | 305 case recordTypes.ScrollLayer: |
| 267 event.backendNodeId = event.args["data"]["nodeId"]; | 306 event.backendNodeId = event.args["data"]["nodeId"]; |
| 268 break; | 307 break; |
| 269 | 308 |
| 270 case recordTypes.PaintImage: | 309 case recordTypes.PaintImage: |
| 271 event.backendNodeId = event.args["data"]["nodeId"]; | 310 event.backendNodeId = event.args["data"]["nodeId"]; |
| 272 event.imageURL = event.args["data"]["url"]; | 311 event.imageURL = event.args["data"]["url"]; |
| 273 break; | 312 break; |
| 274 | 313 |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 287 | 326 |
| 288 case recordTypes.DrawLazyPixelRef: | 327 case recordTypes.DrawLazyPixelRef: |
| 289 var paintImageEvent = this._findAncestorEvent(recordTypes.PaintImage ); | 328 var paintImageEvent = this._findAncestorEvent(recordTypes.PaintImage ); |
| 290 if (!paintImageEvent) | 329 if (!paintImageEvent) |
| 291 break; | 330 break; |
| 292 this._paintImageEventByPixelRefId[event.args["LazyPixelRef"]] = pain tImageEvent; | 331 this._paintImageEventByPixelRefId[event.args["LazyPixelRef"]] = pain tImageEvent; |
| 293 event.backendNodeId = paintImageEvent.backendNodeId; | 332 event.backendNodeId = paintImageEvent.backendNodeId; |
| 294 event.imageURL = paintImageEvent.imageURL; | 333 event.imageURL = paintImageEvent.imageURL; |
| 295 break; | 334 break; |
| 296 } | 335 } |
| 297 if (this._mainThread === event.thread) | |
| 298 this._mainThreadEvents.push(event); | |
| 299 }, | 336 }, |
| 300 | 337 |
| 301 /** | 338 /** |
| 302 * @param {string} name | 339 * @param {string} name |
| 303 * @return {?WebInspector.TracingModel.Event} | 340 * @return {?WebInspector.TracingModel.Event} |
| 304 */ | 341 */ |
| 305 _findAncestorEvent: function(name) | 342 _findAncestorEvent: function(name) |
| 306 { | 343 { |
| 307 for (var i = this._eventStack.length - 1; i >= 0; --i) { | 344 for (var i = this._eventStack.length - 1; i >= 0; --i) { |
| 308 var event = this._eventStack[i]; | 345 var event = this._eventStack[i]; |
| 309 if (event.name === name) | 346 if (event.name === name) |
| 310 return event; | 347 return event; |
| 311 } | 348 } |
| 312 return null; | 349 return null; |
| 313 } | 350 } |
| 314 } | 351 } |
| 315 | 352 |
| OLD | NEW |