Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2050)

Unified Diff: Source/devtools/front_end/timeline/TracingTimelineModel.js

Issue 620123002: DevTools: Support JS frames save/load for tracing timeline. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Addressing comment. Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/devtools/front_end/timeline/TracingModel.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..c904fe7b0925f5b96fc9912862bc94d986e8cd8f 100644
--- a/Source/devtools/front_end/timeline/TracingTimelineModel.js
+++ b/Source/devtools/front_end/timeline/TracingTimelineModel.js
@@ -99,7 +99,11 @@ WebInspector.TracingTimelineModel.RecordType = {
LazyPixelRef: "LazyPixelRef",
LayerTreeHostImplSnapshot: "cc::LayerTreeHostImpl",
- PictureSnapshot: "cc::Picture"
+ PictureSnapshot: "cc::Picture",
+
+ // CpuProfile is a virtual event created on frontend to support
+ // serialization of CPU Profiles within tracing timeline data.
+ CpuProfile: "CpuProfile"
};
/**
@@ -154,8 +158,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 +214,6 @@ WebInspector.TracingTimelineModel.prototype = {
_onTracingComplete: function()
{
- this._tracingModel.tracingComplete();
if (this._stopCallbackBarrier)
this._stopCallbackBarrier.callWhenDone(this._didStopRecordingTraceEvents.bind(this));
else
@@ -225,12 +228,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 +267,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 +555,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"];
« no previous file with comments | « Source/devtools/front_end/timeline/TracingModel.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698