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 * @constructor | 6 * @constructor |
| 7 * @param {!WebInspector.TracingManager} tracingManager | 7 * @param {!WebInspector.TracingManager} tracingManager |
| 8 * @param {!WebInspector.TracingModel} tracingModel | 8 * @param {!WebInspector.TracingModel} tracingModel |
| 9 * @param {!WebInspector.TimelineModel.Filter} recordFilter | 9 * @param {!WebInspector.TimelineModel.Filter} recordFilter |
| 10 * @extends {WebInspector.TimelineModel} | 10 * @extends {WebInspector.TimelineModel} |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 62 MarkFirstPaint: "MarkFirstPaint", | 62 MarkFirstPaint: "MarkFirstPaint", |
| 63 | 63 |
| 64 TimeStamp: "TimeStamp", | 64 TimeStamp: "TimeStamp", |
| 65 ConsoleTime: "ConsoleTime", | 65 ConsoleTime: "ConsoleTime", |
| 66 | 66 |
| 67 ResourceSendRequest: "ResourceSendRequest", | 67 ResourceSendRequest: "ResourceSendRequest", |
| 68 ResourceReceiveResponse: "ResourceReceiveResponse", | 68 ResourceReceiveResponse: "ResourceReceiveResponse", |
| 69 ResourceReceivedData: "ResourceReceivedData", | 69 ResourceReceivedData: "ResourceReceivedData", |
| 70 ResourceFinish: "ResourceFinish", | 70 ResourceFinish: "ResourceFinish", |
| 71 | 71 |
| 72 CpuProfile: "CpuProfile", | |
|
yurys
2014/10/02 16:17:17
Can you move this event at the end and add a comme
| |
| 72 FunctionCall: "FunctionCall", | 73 FunctionCall: "FunctionCall", |
| 73 GCEvent: "GCEvent", | 74 GCEvent: "GCEvent", |
| 74 JSFrame: "JSFrame", | 75 JSFrame: "JSFrame", |
| 75 JSSample: "JSSample", | 76 JSSample: "JSSample", |
| 76 | 77 |
| 77 UpdateCounters: "UpdateCounters", | 78 UpdateCounters: "UpdateCounters", |
| 78 | 79 |
| 79 RequestAnimationFrame: "RequestAnimationFrame", | 80 RequestAnimationFrame: "RequestAnimationFrame", |
| 80 CancelAnimationFrame: "CancelAnimationFrame", | 81 CancelAnimationFrame: "CancelAnimationFrame", |
| 81 FireAnimationFrame: "FireAnimationFrame", | 82 FireAnimationFrame: "FireAnimationFrame", |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 147 disabledByDefault("devtools.timeline.layers"), | 148 disabledByDefault("devtools.timeline.layers"), |
| 148 disabledByDefault("devtools.timeline.picture"), | 149 disabledByDefault("devtools.timeline.picture"), |
| 149 disabledByDefault("blink.graphics_context_annotations")]); | 150 disabledByDefault("blink.graphics_context_annotations")]); |
| 150 } | 151 } |
| 151 var categories = categoriesArray.join(","); | 152 var categories = categoriesArray.join(","); |
| 152 this._startRecordingWithCategories(categories); | 153 this._startRecordingWithCategories(categories); |
| 153 }, | 154 }, |
| 154 | 155 |
| 155 stopRecording: function() | 156 stopRecording: function() |
| 156 { | 157 { |
| 157 this._stopCallbackBarrier = new CallbackBarrier(); | |
| 158 if (this._jsProfilerStarted) { | 158 if (this._jsProfilerStarted) { |
| 159 this._stopCallbackBarrier = new CallbackBarrier(); | |
| 159 this._currentTarget.profilerAgent().stop(this._stopCallbackBarrier.c reateCallback(this._didStopRecordingJSSamples.bind(this))); | 160 this._currentTarget.profilerAgent().stop(this._stopCallbackBarrier.c reateCallback(this._didStopRecordingJSSamples.bind(this))); |
| 160 this._jsProfilerStarted = false; | 161 this._jsProfilerStarted = false; |
| 161 } | 162 } |
| 162 this._tracingManager.stop(); | 163 this._tracingManager.stop(); |
| 163 }, | 164 }, |
| 164 | 165 |
| 165 /** | 166 /** |
| 166 * @param {!Array.<!WebInspector.TracingManager.EventPayload>} events | 167 * @param {!Array.<!WebInspector.TracingManager.EventPayload>} events |
| 167 */ | 168 */ |
| 168 setEventsForTest: function(events) | 169 setEventsForTest: function(events) |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 203 * @param {!WebInspector.Event} event | 204 * @param {!WebInspector.Event} event |
| 204 */ | 205 */ |
| 205 _onEventsCollected: function(event) | 206 _onEventsCollected: function(event) |
| 206 { | 207 { |
| 207 var traceEvents = /** @type {!Array.<!WebInspector.TracingManager.EventP ayload>} */ (event.data); | 208 var traceEvents = /** @type {!Array.<!WebInspector.TracingManager.EventP ayload>} */ (event.data); |
| 208 this._tracingModel.addEvents(traceEvents); | 209 this._tracingModel.addEvents(traceEvents); |
| 209 }, | 210 }, |
| 210 | 211 |
| 211 _onTracingComplete: function() | 212 _onTracingComplete: function() |
| 212 { | 213 { |
| 213 this._tracingModel.tracingComplete(); | |
| 214 if (this._stopCallbackBarrier) | 214 if (this._stopCallbackBarrier) |
| 215 this._stopCallbackBarrier.callWhenDone(this._didStopRecordingTraceEv ents.bind(this)); | 215 this._stopCallbackBarrier.callWhenDone(this._didStopRecordingTraceEv ents.bind(this)); |
| 216 else | 216 else |
| 217 this._didStopRecordingTraceEvents(); | 217 this._didStopRecordingTraceEvents(); |
| 218 }, | 218 }, |
| 219 | 219 |
| 220 /** | 220 /** |
| 221 * @param {?Protocol.Error} error | 221 * @param {?Protocol.Error} error |
| 222 * @param {?ProfilerAgent.CPUProfile} cpuProfile | 222 * @param {?ProfilerAgent.CPUProfile} cpuProfile |
| 223 */ | 223 */ |
| 224 _didStopRecordingJSSamples: function(error, cpuProfile) | 224 _didStopRecordingJSSamples: function(error, cpuProfile) |
| 225 { | 225 { |
| 226 if (error) | 226 if (error) |
| 227 WebInspector.console.error(error); | 227 WebInspector.console.error(error); |
| 228 this._cpuProfile = cpuProfile; | 228 this._recordedCpuProfile = cpuProfile; |
| 229 }, | 229 }, |
| 230 | 230 |
| 231 _didStopRecordingTraceEvents: function() | 231 _didStopRecordingTraceEvents: function() |
| 232 { | 232 { |
| 233 this._stopCallbackBarrier = null; | 233 this._stopCallbackBarrier = null; |
| 234 | |
| 235 if (this._recordedCpuProfile) { | |
| 236 this._injectCpuProfileEvent(this._recordedCpuProfile); | |
| 237 this._recordedCpuProfile = null; | |
| 238 } | |
| 239 this._tracingModel.tracingComplete(); | |
| 240 | |
| 234 var events = this._tracingModel.devtoolsPageMetadataEvents(); | 241 var events = this._tracingModel.devtoolsPageMetadataEvents(); |
| 235 var workerMetadataEvents = this._tracingModel.devtoolsWorkerMetadataEven ts(); | 242 var workerMetadataEvents = this._tracingModel.devtoolsWorkerMetadataEven ts(); |
| 236 | 243 |
| 237 this._resetProcessingState(); | 244 this._resetProcessingState(); |
| 238 for (var i = 0, length = events.length; i < length; i++) { | 245 for (var i = 0, length = events.length; i < length; i++) { |
| 239 var event = events[i]; | 246 var event = events[i]; |
| 240 var process = event.thread.process(); | 247 var process = event.thread.process(); |
| 241 var startTime = event.startTime; | 248 var startTime = event.startTime; |
| 242 | 249 |
| 243 var endTime = Infinity; | 250 var endTime = Infinity; |
| 244 if (i + 1 < length) | 251 if (i + 1 < length) |
| 245 endTime = events[i + 1].startTime; | 252 endTime = events[i + 1].startTime; |
| 246 | 253 |
| 247 var threads = process.sortedThreads(); | 254 var threads = process.sortedThreads(); |
| 248 for (var j = 0; j < threads.length; j++) { | 255 for (var j = 0; j < threads.length; j++) { |
| 249 var thread = threads[j]; | 256 var thread = threads[j]; |
| 250 if (thread.name() === "WebCore: Worker" && !workerMetadataEvents .some(function(e) { return e.args["data"]["workerThreadId"] === thread.id(); })) | 257 if (thread.name() === "WebCore: Worker" && !workerMetadataEvents .some(function(e) { return e.args["data"]["workerThreadId"] === thread.id(); })) |
| 251 continue; | 258 continue; |
| 252 this._processThreadEvents(startTime, endTime, event.thread, thre ad); | 259 this._processThreadEvents(startTime, endTime, event.thread, thre ad); |
| 253 } | 260 } |
| 254 } | 261 } |
| 255 this._resetProcessingState(); | 262 this._resetProcessingState(); |
| 256 | 263 |
| 257 this._inspectedTargetEvents.sort(WebInspector.TracingModel.Event.compare StartTime); | 264 this._inspectedTargetEvents.sort(WebInspector.TracingModel.Event.compare StartTime); |
| 258 | 265 |
| 259 if (this._cpuProfile) { | 266 if (this._cpuProfile) { |
| 260 var jsSamples = WebInspector.TimelineJSProfileProcessor.generateTrac ingEventsFromCpuProfile(this, this._cpuProfile); | 267 this._processCpuProfile(this._cpuProfile); |
| 261 this._inspectedTargetEvents = this._inspectedTargetEvents.mergeOrder ed(jsSamples, WebInspector.TracingModel.Event.orderedCompareStartTime); | |
| 262 this._setMainThreadEvents(this.mainThreadEvents().mergeOrdered(jsSam ples, WebInspector.TracingModel.Event.orderedCompareStartTime)); | |
| 263 this._cpuProfile = null; | 268 this._cpuProfile = null; |
| 264 } | 269 } |
| 265 | |
| 266 this._buildTimelineRecords(); | 270 this._buildTimelineRecords(); |
| 267 this.dispatchEventToListeners(WebInspector.TimelineModel.Events.Recordin gStopped); | 271 this.dispatchEventToListeners(WebInspector.TimelineModel.Events.Recordin gStopped); |
| 268 }, | 272 }, |
| 269 | 273 |
| 270 /** | 274 /** |
| 275 * @param {!ProfilerAgent.CPUProfile} cpuProfile | |
| 276 */ | |
| 277 _injectCpuProfileEvent: function(cpuProfile) | |
| 278 { | |
| 279 var metaEvent = this._tracingModel.devtoolsPageMetadataEvents().peekLast (); | |
| 280 if (!metaEvent) | |
| 281 return; | |
| 282 var cpuProfileEvent = /** @type {!WebInspector.TracingManager.EventPaylo ad} */ ({ | |
| 283 cat: WebInspector.TracingModel.DevToolsMetadataEventCategory, | |
| 284 ph: WebInspector.TracingModel.Phase.Instant, | |
| 285 ts: this._tracingModel.maximumRecordTime() * 1000, | |
| 286 pid: metaEvent.thread.process().id(), | |
| 287 tid: metaEvent.thread.id(), | |
| 288 name: WebInspector.TracingTimelineModel.RecordType.CpuProfile, | |
| 289 args: { data: { cpuProfile: cpuProfile } } | |
| 290 }); | |
| 291 this._tracingModel.addEvents([cpuProfileEvent]); | |
| 292 }, | |
| 293 | |
| 294 /** | |
| 295 * @param {!ProfilerAgent.CPUProfile} cpuProfile | |
| 296 */ | |
| 297 _processCpuProfile: function(cpuProfile) | |
| 298 { | |
| 299 var jsSamples = WebInspector.TimelineJSProfileProcessor.generateTracingE ventsFromCpuProfile(this, cpuProfile); | |
| 300 this._inspectedTargetEvents = this._inspectedTargetEvents.mergeOrdered(j sSamples, WebInspector.TracingModel.Event.orderedCompareStartTime); | |
| 301 this._setMainThreadEvents(this.mainThreadEvents().mergeOrdered(jsSamples , WebInspector.TracingModel.Event.orderedCompareStartTime)); | |
| 302 }, | |
| 303 | |
| 304 /** | |
| 271 * @return {number} | 305 * @return {number} |
| 272 */ | 306 */ |
| 273 minimumRecordTime: function() | 307 minimumRecordTime: function() |
| 274 { | 308 { |
| 275 return this._tracingModel.minimumRecordTime(); | 309 return this._tracingModel.minimumRecordTime(); |
| 276 }, | 310 }, |
| 277 | 311 |
| 278 /** | 312 /** |
| 279 * @return {number} | 313 * @return {number} |
| 280 */ | 314 */ |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 511 if (this._currentScriptEvent && event.startTime > this._currentScriptEve nt.endTime) | 545 if (this._currentScriptEvent && event.startTime > this._currentScriptEve nt.endTime) |
| 512 this._currentScriptEvent = null; | 546 this._currentScriptEvent = null; |
| 513 | 547 |
| 514 switch (event.name) { | 548 switch (event.name) { |
| 515 case recordTypes.CallStack: | 549 case recordTypes.CallStack: |
| 516 var lastMainThreadEvent = this.mainThreadEvents().peekLast(); | 550 var lastMainThreadEvent = this.mainThreadEvents().peekLast(); |
| 517 if (lastMainThreadEvent && event.args["stack"] && event.args["stack" ].length) | 551 if (lastMainThreadEvent && event.args["stack"] && event.args["stack" ].length) |
| 518 lastMainThreadEvent.stackTrace = event.args["stack"]; | 552 lastMainThreadEvent.stackTrace = event.args["stack"]; |
| 519 break; | 553 break; |
| 520 | 554 |
| 555 case recordTypes.CpuProfile: | |
| 556 this._cpuProfile = event.args["data"]["cpuProfile"]; | |
| 557 break; | |
| 558 | |
| 521 case recordTypes.ResourceSendRequest: | 559 case recordTypes.ResourceSendRequest: |
| 522 this._sendRequestEvents[event.args["data"]["requestId"]] = event; | 560 this._sendRequestEvents[event.args["data"]["requestId"]] = event; |
| 523 event.imageURL = event.args["data"]["url"]; | 561 event.imageURL = event.args["data"]["url"]; |
| 524 break; | 562 break; |
| 525 | 563 |
| 526 case recordTypes.ResourceReceiveResponse: | 564 case recordTypes.ResourceReceiveResponse: |
| 527 case recordTypes.ResourceReceivedData: | 565 case recordTypes.ResourceReceivedData: |
| 528 case recordTypes.ResourceFinish: | 566 case recordTypes.ResourceFinish: |
| 529 event.initiator = this._sendRequestEvents[event.args["data"]["reques tId"]]; | 567 event.initiator = this._sendRequestEvents[event.args["data"]["reques tId"]]; |
| 530 if (event.initiator) | 568 if (event.initiator) |
| (...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1057 * @param {!WebInspector.ChunkedReader} reader | 1095 * @param {!WebInspector.ChunkedReader} reader |
| 1058 */ | 1096 */ |
| 1059 onChunkTransferred: function(reader) { }, | 1097 onChunkTransferred: function(reader) { }, |
| 1060 | 1098 |
| 1061 /** | 1099 /** |
| 1062 * @param {!WebInspector.ChunkedReader} reader | 1100 * @param {!WebInspector.ChunkedReader} reader |
| 1063 * @param {!Event} event | 1101 * @param {!Event} event |
| 1064 */ | 1102 */ |
| 1065 onError: function(reader, event) { }, | 1103 onError: function(reader, event) { }, |
| 1066 } | 1104 } |
| OLD | NEW |