Index: Source/devtools/front_end/timeline/TracingTimelineModel.js |
diff --git a/Source/devtools/front_end/timeline/TracingTimelineModel.js b/Source/devtools/front_end/timeline/TracingTimelineModel.js |
index 3909859f0b0b61c7ec6b4089d17661b67889346b..e8915263cc0e40d4a663571d9ebc114da9173ca1 100644 |
--- a/Source/devtools/front_end/timeline/TracingTimelineModel.js |
+++ b/Source/devtools/front_end/timeline/TracingTimelineModel.js |
@@ -69,6 +69,7 @@ WebInspector.TracingTimelineModel.RecordType = { |
ResourceReceivedData: "ResourceReceivedData", |
ResourceFinish: "ResourceFinish", |
+ CpuProfile: "CpuProfile", |
yurys
2014/10/02 16:17:17
Can you move this event at the end and add a comme
|
FunctionCall: "FunctionCall", |
GCEvent: "GCEvent", |
JSFrame: "JSFrame", |
@@ -154,8 +155,8 @@ WebInspector.TracingTimelineModel.prototype = { |
stopRecording: function() |
{ |
- this._stopCallbackBarrier = new CallbackBarrier(); |
if (this._jsProfilerStarted) { |
+ this._stopCallbackBarrier = new CallbackBarrier(); |
this._currentTarget.profilerAgent().stop(this._stopCallbackBarrier.createCallback(this._didStopRecordingJSSamples.bind(this))); |
this._jsProfilerStarted = false; |
} |
@@ -210,7 +211,6 @@ WebInspector.TracingTimelineModel.prototype = { |
_onTracingComplete: function() |
{ |
- this._tracingModel.tracingComplete(); |
if (this._stopCallbackBarrier) |
this._stopCallbackBarrier.callWhenDone(this._didStopRecordingTraceEvents.bind(this)); |
else |
@@ -225,12 +225,19 @@ WebInspector.TracingTimelineModel.prototype = { |
{ |
if (error) |
WebInspector.console.error(error); |
- this._cpuProfile = cpuProfile; |
+ this._recordedCpuProfile = cpuProfile; |
}, |
_didStopRecordingTraceEvents: function() |
{ |
this._stopCallbackBarrier = null; |
+ |
+ if (this._recordedCpuProfile) { |
+ this._injectCpuProfileEvent(this._recordedCpuProfile); |
+ this._recordedCpuProfile = null; |
+ } |
+ this._tracingModel.tracingComplete(); |
+ |
var events = this._tracingModel.devtoolsPageMetadataEvents(); |
var workerMetadataEvents = this._tracingModel.devtoolsWorkerMetadataEvents(); |
@@ -257,17 +264,44 @@ WebInspector.TracingTimelineModel.prototype = { |
this._inspectedTargetEvents.sort(WebInspector.TracingModel.Event.compareStartTime); |
if (this._cpuProfile) { |
- var jsSamples = WebInspector.TimelineJSProfileProcessor.generateTracingEventsFromCpuProfile(this, this._cpuProfile); |
- this._inspectedTargetEvents = this._inspectedTargetEvents.mergeOrdered(jsSamples, WebInspector.TracingModel.Event.orderedCompareStartTime); |
- this._setMainThreadEvents(this.mainThreadEvents().mergeOrdered(jsSamples, WebInspector.TracingModel.Event.orderedCompareStartTime)); |
+ this._processCpuProfile(this._cpuProfile); |
this._cpuProfile = null; |
} |
- |
this._buildTimelineRecords(); |
this.dispatchEventToListeners(WebInspector.TimelineModel.Events.RecordingStopped); |
}, |
/** |
+ * @param {!ProfilerAgent.CPUProfile} cpuProfile |
+ */ |
+ _injectCpuProfileEvent: function(cpuProfile) |
+ { |
+ var metaEvent = this._tracingModel.devtoolsPageMetadataEvents().peekLast(); |
+ if (!metaEvent) |
+ return; |
+ var cpuProfileEvent = /** @type {!WebInspector.TracingManager.EventPayload} */ ({ |
+ cat: WebInspector.TracingModel.DevToolsMetadataEventCategory, |
+ ph: WebInspector.TracingModel.Phase.Instant, |
+ ts: this._tracingModel.maximumRecordTime() * 1000, |
+ pid: metaEvent.thread.process().id(), |
+ tid: metaEvent.thread.id(), |
+ name: WebInspector.TracingTimelineModel.RecordType.CpuProfile, |
+ args: { data: { cpuProfile: cpuProfile } } |
+ }); |
+ this._tracingModel.addEvents([cpuProfileEvent]); |
+ }, |
+ |
+ /** |
+ * @param {!ProfilerAgent.CPUProfile} cpuProfile |
+ */ |
+ _processCpuProfile: function(cpuProfile) |
+ { |
+ var jsSamples = WebInspector.TimelineJSProfileProcessor.generateTracingEventsFromCpuProfile(this, cpuProfile); |
+ this._inspectedTargetEvents = this._inspectedTargetEvents.mergeOrdered(jsSamples, WebInspector.TracingModel.Event.orderedCompareStartTime); |
+ this._setMainThreadEvents(this.mainThreadEvents().mergeOrdered(jsSamples, WebInspector.TracingModel.Event.orderedCompareStartTime)); |
+ }, |
+ |
+ /** |
* @return {number} |
*/ |
minimumRecordTime: function() |
@@ -518,6 +552,10 @@ WebInspector.TracingTimelineModel.prototype = { |
lastMainThreadEvent.stackTrace = event.args["stack"]; |
break; |
+ case recordTypes.CpuProfile: |
+ this._cpuProfile = event.args["data"]["cpuProfile"]; |
+ break; |
+ |
case recordTypes.ResourceSendRequest: |
this._sendRequestEvents[event.args["data"]["requestId"]] = event; |
event.imageURL = event.args["data"]["url"]; |