Changeset 117241 in webkit


Ignore:
Timestamp:
May 16, 2012 2:26:19 AM (12 years ago)
Author:
yurys@chromium.org
Message:

Web Inspector: exception when switching to heap profiler comparison view
https://bugs.webkit.org/show_bug.cgi?id=86224

Reviewed by Pavel Feldman.

Make sure the messages are dispatched in the same order as they are sent in
case a fake worker is used for heap snapshot processing.

  • inspector/front-end/HeapSnapshotProxy.js:

(WebInspector.AsyncTaskQueue):
(WebInspector.AsyncTaskQueue.prototype.addTask):
(WebInspector.AsyncTaskQueue.prototype._onTimeout):
(WebInspector.AsyncTaskQueue.prototype._scheduleTimer):
(WebInspector.HeapSnapshotFakeWorker):
(WebInspector.HeapSnapshotFakeWorker.prototype.postMessage):
(WebInspector.HeapSnapshotFakeWorker.prototype._postMessageFromWorker):

Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r117238 r117241  
     12012-05-16  Yury Semikhatsky  <yurys@chromium.org>
     2
     3        Web Inspector: exception when switching to heap profiler comparison view
     4        https://bugs.webkit.org/show_bug.cgi?id=86224
     5
     6        Reviewed by Pavel Feldman.
     7
     8        Make sure the messages are dispatched in the same order as they are sent in
     9        case a fake worker is used for heap snapshot processing.
     10
     11        * inspector/front-end/HeapSnapshotProxy.js:
     12        (WebInspector.AsyncTaskQueue):
     13        (WebInspector.AsyncTaskQueue.prototype.addTask):
     14        (WebInspector.AsyncTaskQueue.prototype._onTimeout):
     15        (WebInspector.AsyncTaskQueue.prototype._scheduleTimer):
     16        (WebInspector.HeapSnapshotFakeWorker):
     17        (WebInspector.HeapSnapshotFakeWorker.prototype.postMessage):
     18        (WebInspector.HeapSnapshotFakeWorker.prototype._postMessageFromWorker):
     19
    1202012-05-16  Mikhail Pozdnyakov  <mikhail.pozdnyakov@intel.com>
    221
  • trunk/Source/WebCore/inspector/front-end/HeapSnapshotProxy.js

    r117234 r117241  
    7979/**
    8080 * @constructor
     81 */
     82WebInspector.AsyncTaskQueue = function()
     83{
     84    this._queue = [];
     85    this._isTimerSheduled = false;
     86}
     87
     88WebInspector.AsyncTaskQueue.prototype = {
     89    /**
     90     * @param {function()} task
     91     */
     92    addTask: function(task)
     93    {
     94        this._queue.push(task);
     95        this._scheduleTimer();
     96    },
     97
     98    _onTimeout: function()
     99    {
     100        this._isTimerSheduled = false;
     101        var queue = this._queue;
     102        this._queue = [];
     103        for (var i = 0; i < queue.length; i++) {
     104            try {
     105                queue[i]();
     106            } catch (e) {
     107                console.error("Exception while running task: " + e.stack);
     108            }
     109        }
     110        this._scheduleTimer();
     111    },
     112
     113    _scheduleTimer: function()
     114    {
     115        if (this._queue.length && !this._isTimerSheduled) {
     116            setTimeout(this._onTimeout.bind(this), 0);
     117            this._isTimerSheduled = true;
     118        }
     119    }
     120}
     121
     122/**
     123 * @constructor
    81124 * @extends {WebInspector.HeapSnapshotWorkerWrapper}
    82125 */
     
    84127{
    85128    this._dispatcher = new WebInspector.HeapSnapshotWorkerDispatcher(window, this._postMessageFromWorker.bind(this));
     129    this._asyncTaskQueue = new WebInspector.AsyncTaskQueue();
    86130}
    87131
     
    94138                this._dispatcher.dispatchMessage({data: message});
    95139        }
    96         setTimeout(dispatch.bind(this), 0);
     140        this._asyncTaskQueue.addTask(dispatch.bind(this));
    97141    },
    98142
     
    108152            this.dispatchEventToListeners("message", message);
    109153        }
    110         setTimeout(send.bind(this), 0);
     154        this._asyncTaskQueue.addTask(send.bind(this));
    111155    }
    112156};
Note: See TracChangeset for help on using the changeset viewer.