Commit 3bf2cff7 authored by yurys@chromium.org's avatar yurys@chromium.org

Create Tracing{Timeline}Model in TimelinePanel constructor

start/stop recording logic for trace events moved into TracingTimelineModel.

BUG=361045
R=caseq@chromium.org

Review URL: https://codereview.chromium.org/317273004

git-svn-id: svn://svn.chromium.org/blink/trunk@175649 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 0c925d9c
...@@ -25,7 +25,7 @@ function doActions(callback) ...@@ -25,7 +25,7 @@ function doActions(callback)
function test() function test()
{ {
InspectorTest.invokeWithTracing(WebInspector.TimelinePanel.defaultTracingCategoryFilter, "doActions", onTracingComplete); InspectorTest.invokeWithTracing(WebInspector.TracingTimelineModel.defaultTracingCategoryFilter, "doActions", onTracingComplete);
var target = /** @type {!WebInspector.Target} */ (WebInspector.targetManager.activeTarget()); var target = /** @type {!WebInspector.Target} */ (WebInspector.targetManager.activeTarget());
var layerTree = new WebInspector.TracingLayerTree(target); var layerTree = new WebInspector.TracingLayerTree(target);
......
...@@ -92,6 +92,15 @@ WebInspector.TimelinePanel = function() ...@@ -92,6 +92,15 @@ WebInspector.TimelinePanel = function()
this._model.addFilter(this._durationFilter); this._model.addFilter(this._durationFilter);
this._model.addFilter(this._textFilter); this._model.addFilter(this._textFilter);
if (WebInspector.experimentsSettings.timelineTracingMode.isEnabled() ||
WebInspector.experimentsSettings.timelineOnTraceEvents.isEnabled()) {
this._tracingModel = new WebInspector.TracingModel(WebInspector.targetManager.activeTarget());
this._tracingModel.addEventListener(WebInspector.TracingModel.Events.BufferUsage, this._onTracingBufferUsage, this);
this._tracingTimelineModel = new WebInspector.TracingTimelineModel(this._tracingModel);
this._tracingTimelineModel.addEventListener(WebInspector.TracingTimelineModel.Events.TracingComplete, this._onTracingComplete, this);
}
/** @type {!Array.<!WebInspector.TimelineModeView>} */ /** @type {!Array.<!WebInspector.TimelineModeView>} */
this._currentViews = []; this._currentViews = [];
...@@ -153,8 +162,6 @@ WebInspector.TimelinePanel.headerHeight = 20; ...@@ -153,8 +162,6 @@ WebInspector.TimelinePanel.headerHeight = 20;
WebInspector.TimelinePanel.durationFilterPresetsMs = [0, 1, 15]; WebInspector.TimelinePanel.durationFilterPresetsMs = [0, 1, 15];
WebInspector.TimelinePanel.defaultTracingCategoryFilter = "*,disabled-by-default-cc.debug,disabled-by-default-devtools.timeline";
WebInspector.TimelinePanel.prototype = { WebInspector.TimelinePanel.prototype = {
/** /**
* @return {?WebInspector.SearchableView} * @return {?WebInspector.SearchableView}
...@@ -253,25 +260,12 @@ WebInspector.TimelinePanel.prototype = { ...@@ -253,25 +260,12 @@ WebInspector.TimelinePanel.prototype = {
this._lazyFrameModel = new WebInspector.TimelineFrameModel(this._model.target()); this._lazyFrameModel = new WebInspector.TimelineFrameModel(this._model.target());
this._lazyFrameModel.setMergeRecords(!WebInspector.experimentsSettings.timelineNoLiveUpdate.isEnabled() || !this._recordingInProgress); this._lazyFrameModel.setMergeRecords(!WebInspector.experimentsSettings.timelineNoLiveUpdate.isEnabled() || !this._recordingInProgress);
this._lazyFrameModel.addRecords(this._model.records()); this._lazyFrameModel.addRecords(this._model.records());
if (this._lazyTracingModel) if (this._tracingModel)
this._lazyFrameModel.addTraceEvents(this._tracingTimelineModel.inspectedTargetEvents(), this._lazyTracingModel.sessionId()); this._lazyFrameModel.addTraceEvents(this._tracingTimelineModel.inspectedTargetEvents(), this._tracingModel.sessionId() || "");
} }
return this._lazyFrameModel; return this._lazyFrameModel;
}, },
/**
* @return {!WebInspector.TracingModel}
*/
_tracingModel: function()
{
if (!this._lazyTracingModel) {
this._lazyTracingModel = new WebInspector.TracingModel(WebInspector.targetManager.activeTarget());
this._lazyTracingModel.addEventListener(WebInspector.TracingModel.Events.BufferUsage, this._onTracingBufferUsage, this);
this._tracingTimelineModel = new WebInspector.TracingTimelineModel(this._lazyTracingModel);
}
return this._lazyTracingModel;
},
/** /**
* @return {!WebInspector.TimelineView} * @return {!WebInspector.TimelineView}
*/ */
...@@ -620,15 +614,12 @@ WebInspector.TimelinePanel.prototype = { ...@@ -620,15 +614,12 @@ WebInspector.TimelinePanel.prototype = {
else else
this._overviewControls.push(new WebInspector.TimelineEventOverview(this._model)); this._overviewControls.push(new WebInspector.TimelineEventOverview(this._model));
var tracingTimelineModel = null; if (WebInspector.experimentsSettings.timelineFlameChart.isEnabled() && this._flameChartEnabledSetting.get()) {
if (WebInspector.experimentsSettings.timelineOnTraceEvents.isEnabled()) { var tracingTimelineModel = WebInspector.experimentsSettings.timelineOnTraceEvents.isEnabled() ? this._tracingTimelineModel : null;
this._tracingModel();
tracingTimelineModel = this._tracingTimelineModel;
}
if (WebInspector.experimentsSettings.timelineFlameChart.isEnabled() && this._flameChartEnabledSetting.get())
this._addModeView(new WebInspector.TimelineFlameChart(this, this._model, tracingTimelineModel, this._frameModel())); this._addModeView(new WebInspector.TimelineFlameChart(this, this._model, tracingTimelineModel, this._frameModel()));
else } else {
this._addModeView(this._timelineView()); this._addModeView(this._timelineView());
}
if (this._captureMemorySetting.get()) { if (this._captureMemorySetting.get()) {
if (!isFrameMode) // Frame mode skews time, don't render aux overviews. if (!isFrameMode) // Frame mode skews time, don't render aux overviews.
...@@ -643,7 +634,7 @@ WebInspector.TimelinePanel.prototype = { ...@@ -643,7 +634,7 @@ WebInspector.TimelinePanel.prototype = {
} }
if (this._captureTracingSetting && this._captureTracingSetting.get()) if (this._captureTracingSetting && this._captureTracingSetting.get())
this._addModeView(new WebInspector.TimelineTracingView(this, this._tracingModel(), this._model)); this._addModeView(new WebInspector.TimelineTracingView(this, this._tracingModel, this._model));
this._timelineView().setFrameModel(isFrameMode ? this._frameModel() : null); this._timelineView().setFrameModel(isFrameMode ? this._frameModel() : null);
this._overviewPane.setOverviewControls(this._overviewControls); this._overviewPane.setOverviewControls(this._overviewControls);
...@@ -660,18 +651,12 @@ WebInspector.TimelinePanel.prototype = { ...@@ -660,18 +651,12 @@ WebInspector.TimelinePanel.prototype = {
{ {
this._userInitiatedRecording = userInitiated; this._userInitiatedRecording = userInitiated;
if (WebInspector.experimentsSettings.timelineOnTraceEvents.isEnabled()) { if (WebInspector.experimentsSettings.timelineOnTraceEvents.isEnabled()) {
var categories = ["disabled-by-default-devtools.timeline", "devtools"];
if (this._captureStacksSetting.get())
categories.push("disabled-by-default-devtools.timeline.stack");
this._model.willStartRecordingTraceEvents(); this._model.willStartRecordingTraceEvents();
this._tracingModel().start(categories.join(","), ""); this._tracingTimelineModel.startRecording(this._captureStacksSetting.get(), this._captureMemorySetting.get());
this._tracingTimelineModel.willStartRecordingTraceEvents();
} else { } else {
this._model.startRecording(this._captureStacksSetting.get(), this._captureMemorySetting.get()); this._model.startRecording(this._captureStacksSetting.get(), this._captureMemorySetting.get());
if (WebInspector.experimentsSettings.timelineTracingMode.isEnabled()) { if (this._captureTracingSetting && this._captureTracingSetting.get())
this._tracingModel().start(WebInspector.TimelinePanel.defaultTracingCategoryFilter, ""); this._tracingTimelineModel.startRecording(this._captureStacksSetting.get(), this._captureMemorySetting.get());
this._tracingTimelineModel.willStartRecordingTraceEvents();
}
} }
if (WebInspector.experimentsSettings.timelineNoLiveUpdate.isEnabled() && this._lazyFrameModel) if (WebInspector.experimentsSettings.timelineNoLiveUpdate.isEnabled() && this._lazyFrameModel)
this._lazyFrameModel.setMergeRecords(false); this._lazyFrameModel.setMergeRecords(false);
...@@ -687,8 +672,8 @@ WebInspector.TimelinePanel.prototype = { ...@@ -687,8 +672,8 @@ WebInspector.TimelinePanel.prototype = {
{ {
this._userInitiatedRecording = false; this._userInitiatedRecording = false;
this._model.stopRecording(); this._model.stopRecording();
if (this._lazyTracingModel) if (this._tracingTimelineModel)
this._lazyTracingModel.stop(this._onTracingComplete.bind(this)); this._tracingTimelineModel.stopRecording()
for (var i = 0; i < this._overviewControls.length; ++i) for (var i = 0; i < this._overviewControls.length; ++i)
this._overviewControls[i].timelineStopped(); this._overviewControls[i].timelineStopped();
...@@ -696,10 +681,9 @@ WebInspector.TimelinePanel.prototype = { ...@@ -696,10 +681,9 @@ WebInspector.TimelinePanel.prototype = {
_onTracingComplete: function() _onTracingComplete: function()
{ {
this._tracingTimelineModel.didStopRecordingTraceEvents();
if (this._lazyFrameModel) { if (this._lazyFrameModel) {
this._lazyFrameModel.reset(); this._lazyFrameModel.reset();
this._lazyFrameModel.addTraceEvents(this._tracingTimelineModel.inspectedTargetEvents(), this._lazyTracingModel.sessionId()); this._lazyFrameModel.addTraceEvents(this._tracingTimelineModel.inspectedTargetEvents(), this._tracingModel.sessionId());
this._overviewPane.update(); this._overviewPane.update();
} }
if (WebInspector.experimentsSettings.timelineOnTraceEvents.isEnabled()) if (WebInspector.experimentsSettings.timelineOnTraceEvents.isEnabled())
......
...@@ -5,9 +5,11 @@ ...@@ -5,9 +5,11 @@
/** /**
* @param {!WebInspector.TracingModel} tracingModel * @param {!WebInspector.TracingModel} tracingModel
* @constructor * @constructor
* @extends {WebInspector.TargetAwareObject}
*/ */
WebInspector.TracingTimelineModel = function(tracingModel) WebInspector.TracingTimelineModel = function(tracingModel)
{ {
WebInspector.TargetAwareObject.call(this, tracingModel.target());
this._tracingModel = tracingModel; this._tracingModel = tracingModel;
this._mainThreadEvents = []; this._mainThreadEvents = [];
this._inspectedTargetEvents = []; this._inspectedTargetEvents = [];
...@@ -88,7 +90,37 @@ WebInspector.TracingTimelineModel.RecordType = { ...@@ -88,7 +90,37 @@ WebInspector.TracingTimelineModel.RecordType = {
LayerTreeHostImplSnapshot: "cc::LayerTreeHostImpl" LayerTreeHostImplSnapshot: "cc::LayerTreeHostImpl"
}; };
WebInspector.TracingTimelineModel.Events = {
TracingComplete: "TracingComplete"
};
WebInspector.TracingTimelineModel.defaultTracingCategoryFilter = "*,disabled-by-default-cc.debug,disabled-by-default-devtools.timeline";
WebInspector.TracingTimelineModel.prototype = { WebInspector.TracingTimelineModel.prototype = {
/**
* @param {boolean} captureStacks
* @param {boolean} captureMemory
*/
startRecording: function(captureStacks, captureMemory)
{
var categories;
if (WebInspector.experimentsSettings.timelineTracingMode.isEnabled()) {
categories = WebInspector.TracingTimelineModel.defaultTracingCategoryFilter;
} else {
var categoriesArray = ["disabled-by-default-devtools.timeline", "devtools"];
if (captureStacks)
categoriesArray.push("disabled-by-default-devtools.timeline.stack");
categories = categoriesArray.join(",");
}
this._tracingModel.start(categories, "");
this.willStartRecordingTraceEvents();
},
stopRecording: function()
{
this._tracingModel.stop(this.didStopRecordingTraceEvents.bind(this));
},
willStartRecordingTraceEvents: function() willStartRecordingTraceEvents: function()
{ {
this._mainThreadEvents = []; this._mainThreadEvents = [];
...@@ -115,6 +147,8 @@ WebInspector.TracingTimelineModel.prototype = { ...@@ -115,6 +147,8 @@ WebInspector.TracingTimelineModel.prototype = {
this._resetProcessingState(); this._resetProcessingState();
this._inspectedTargetEvents.sort(WebInspector.TracingModel.Event.compareStartTime); this._inspectedTargetEvents.sort(WebInspector.TracingModel.Event.compareStartTime);
this.dispatchEventToListeners(WebInspector.TracingTimelineModel.Events.TracingComplete);
}, },
/** /**
...@@ -341,6 +375,7 @@ WebInspector.TracingTimelineModel.prototype = { ...@@ -341,6 +375,7 @@ WebInspector.TracingTimelineModel.prototype = {
return event; return event;
} }
return null; return null;
} },
}
__proto__: WebInspector.TargetAwareObject.prototype
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment