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()
{
WebInspector.Object.call(this);
this._active = false;
this._eventBufferSize = 0;
this._eventsRetrieved = 0;
WebInspector.targetManager.observeTargets(this);
}
WebInspector.TracingManager.Events = {
"RetrieveEventsProgress": "RetrieveEventsProgress",
"BufferUsage": "BufferUsage",
"TracingStarted": "TracingStarted",
"EventsCollected": "EventsCollected",
......@@ -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 = {
_eventsCollected: function(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()
{
this._eventBufferSize = 0;
this._eventsRetrieved = 0;
this.dispatchEventToListeners(WebInspector.TracingManager.Events.TracingComplete);
},
......@@ -137,11 +151,13 @@ WebInspector.TracingDispatcher = function(tracingManager)
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()
// Create model.
this._tracingManager = new WebInspector.TracingManager();
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._model = new WebInspector.TimelineModel(this._tracingManager, this._tracingModel, WebInspector.TimelineUIUtils.hiddenRecordsFilter());
......@@ -757,6 +758,15 @@ WebInspector.TimelinePanel.prototype = {
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
*/
......
......@@ -4378,7 +4378,9 @@
{
"name": "bufferUsage",
"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"]
}
......
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