Commit a7ac986b authored by yurys@chromium.org's avatar yurys@chromium.org

DevTools: show progress when retrieving recorded trace events

The progress is estimated as event count divided by total buffer size.

BUG=426117

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

git-svn-id: svn://svn.chromium.org/blink/trunk@185440 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent e5165997
...@@ -13,10 +13,13 @@ WebInspector.TracingManager = function() ...@@ -13,10 +13,13 @@ WebInspector.TracingManager = function()
{ {
WebInspector.Object.call(this); WebInspector.Object.call(this);
this._active = false; this._active = false;
this._eventBufferSize = 0;
this._eventsRetrieved = 0;
WebInspector.targetManager.observeTargets(this); WebInspector.targetManager.observeTargets(this);
} }
WebInspector.TracingManager.Events = { WebInspector.TracingManager.Events = {
"RetrieveEventsProgress": "RetrieveEventsProgress",
"BufferUsage": "BufferUsage", "BufferUsage": "BufferUsage",
"TracingStarted": "TracingStarted", "TracingStarted": "TracingStarted",
"EventsCollected": "EventsCollected", "EventsCollected": "EventsCollected",
...@@ -70,11 +73,14 @@ WebInspector.TracingManager.prototype = { ...@@ -70,11 +73,14 @@ WebInspector.TracingManager.prototype = {
}, },
/** /**
* @param {number} usage * @param {number=} usage
* @param {number=} eventCount
* @param {number=} percentFull
*/ */
_bufferUsage: function(usage) _bufferUsage: function(usage, eventCount, percentFull)
{ {
this.dispatchEventToListeners(WebInspector.TracingManager.Events.BufferUsage, usage); this._eventBufferSize = eventCount;
this.dispatchEventToListeners(WebInspector.TracingManager.Events.BufferUsage, usage || percentFull);
}, },
/** /**
...@@ -83,10 +89,18 @@ WebInspector.TracingManager.prototype = { ...@@ -83,10 +89,18 @@ WebInspector.TracingManager.prototype = {
_eventsCollected: function(events) _eventsCollected: function(events)
{ {
this.dispatchEventToListeners(WebInspector.TracingManager.Events.EventsCollected, events); this.dispatchEventToListeners(WebInspector.TracingManager.Events.EventsCollected, events);
this._eventsRetrieved += events.length;
if (!this._eventBufferSize)
return;
if (this._eventsRetrieved > this._eventBufferSize)
this._eventsRetrieved = this._eventBufferSize;
this.dispatchEventToListeners(WebInspector.TracingManager.Events.RetrieveEventsProgress, this._eventsRetrieved / this._eventBufferSize);
}, },
_tracingComplete: function() _tracingComplete: function()
{ {
this._eventBufferSize = 0;
this._eventsRetrieved = 0;
this.dispatchEventToListeners(WebInspector.TracingManager.Events.TracingComplete); this.dispatchEventToListeners(WebInspector.TracingManager.Events.TracingComplete);
}, },
...@@ -137,11 +151,13 @@ WebInspector.TracingDispatcher = function(tracingManager) ...@@ -137,11 +151,13 @@ WebInspector.TracingDispatcher = function(tracingManager)
WebInspector.TracingDispatcher.prototype = { WebInspector.TracingDispatcher.prototype = {
/** /**
* @param {number} usage * @param {number=} usage
* @param {number=} eventCount
* @param {number=} percentFull
*/ */
bufferUsage: function(usage) bufferUsage: function(usage, eventCount, percentFull)
{ {
this._tracingManager._bufferUsage(usage); this._tracingManager._bufferUsage(usage, eventCount, percentFull);
}, },
/** /**
......
...@@ -49,6 +49,7 @@ WebInspector.TimelinePanel = function() ...@@ -49,6 +49,7 @@ WebInspector.TimelinePanel = function()
// Create model. // Create model.
this._tracingManager = new WebInspector.TracingManager(); this._tracingManager = new WebInspector.TracingManager();
this._tracingManager.addEventListener(WebInspector.TracingManager.Events.BufferUsage, this._onTracingBufferUsage, this); this._tracingManager.addEventListener(WebInspector.TracingManager.Events.BufferUsage, this._onTracingBufferUsage, this);
this._tracingManager.addEventListener(WebInspector.TracingManager.Events.RetrieveEventsProgress, this._onRetrieveEventsProgress, this);
this._tracingModel = new WebInspector.TracingModel(); this._tracingModel = new WebInspector.TracingModel();
this._model = new WebInspector.TimelineModel(this._tracingManager, this._tracingModel, WebInspector.TimelineUIUtils.hiddenRecordsFilter()); this._model = new WebInspector.TimelineModel(this._tracingManager, this._tracingModel, WebInspector.TimelineUIUtils.hiddenRecordsFilter());
...@@ -757,6 +758,15 @@ WebInspector.TimelinePanel.prototype = { ...@@ -757,6 +758,15 @@ WebInspector.TimelinePanel.prototype = {
this._updateProgress(WebInspector.UIString("Buffer usage %d%", Math.round(usage * 100))); this._updateProgress(WebInspector.UIString("Buffer usage %d%", Math.round(usage * 100)));
}, },
/**
* @param {!WebInspector.Event} event
*/
_onRetrieveEventsProgress: function(event)
{
var progress = /** @type {number} */ (event.data);
this._updateProgress(WebInspector.UIString("Retrieving events\u2026 %d%", Math.round(progress * 100)));
},
/** /**
* @param {string} progressMessage * @param {string} progressMessage
*/ */
......
...@@ -4378,7 +4378,9 @@ ...@@ -4378,7 +4378,9 @@
{ {
"name": "bufferUsage", "name": "bufferUsage",
"parameters": [ "parameters": [
{ "name": "value", "type": "number", "description": "A number in range [0..1] that indicates the used size of event buffer as a fraction of its total size." } { "name": "percentFull", "type": "number", "optional": true, "description": "A number in range [0..1] that indicates the used size of event buffer as a fraction of its total size." },
{ "name": "eventCount", "type": "number", "optional": true, "description": "An approximate number of events in the trace log." },
{ "name": "value", "type": "number", "optional": true, "description": "A number in range [0..1] that indicates the used size of event buffer as a fraction of its total size." }
], ],
"handlers": ["browser"] "handlers": ["browser"]
} }
......
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