Title: [117050] trunk/Source/WebCore
Revision
117050
Author
[email protected]
Date
2012-05-15 04:10:22 -0700 (Tue, 15 May 2012)

Log 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.TimerQueue):
(WebInspector.TimerQueue.prototype.addTask):
(WebInspector.TimerQueue.prototype._onTimeout):
(WebInspector.TimerQueue.prototype._scheduleTimer):
(WebInspector.HeapSnapshotFakeWorker):
(WebInspector.HeapSnapshotFakeWorker.prototype.postMessage):
(WebInspector.HeapSnapshotFakeWorker.prototype._postMessageFromWorker):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (117049 => 117050)


--- trunk/Source/WebCore/ChangeLog	2012-05-15 10:16:35 UTC (rev 117049)
+++ trunk/Source/WebCore/ChangeLog	2012-05-15 11:10:22 UTC (rev 117050)
@@ -1,3 +1,22 @@
+2012-05-15  Yury Semikhatsky  <[email protected]>
+
+        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.TimerQueue):
+        (WebInspector.TimerQueue.prototype.addTask):
+        (WebInspector.TimerQueue.prototype._onTimeout):
+        (WebInspector.TimerQueue.prototype._scheduleTimer):
+        (WebInspector.HeapSnapshotFakeWorker):
+        (WebInspector.HeapSnapshotFakeWorker.prototype.postMessage):
+        (WebInspector.HeapSnapshotFakeWorker.prototype._postMessageFromWorker):
+
 2012-05-15  Zoltan Herczeg  <[email protected]>
 
         The ARM NEON optimized filters does not compile on THUMB2

Modified: trunk/Source/WebCore/inspector/front-end/HeapSnapshotProxy.js (117049 => 117050)


--- trunk/Source/WebCore/inspector/front-end/HeapSnapshotProxy.js	2012-05-15 10:16:35 UTC (rev 117049)
+++ trunk/Source/WebCore/inspector/front-end/HeapSnapshotProxy.js	2012-05-15 11:10:22 UTC (rev 117050)
@@ -78,11 +78,51 @@
 
 /**
  * @constructor
+ */
+WebInspector.AsyncTaskQueue = function()
+{
+    this._queue = [];
+    this._isTimerSheduled = false;
+}
+
+WebInspector.AsyncTaskQueue.prototype = {
+    /**
+     * @param {function()} task
+     */
+    addTask: function(task)
+    {
+        this._queue.push(task);
+        this._scheduleTimer();
+    },
+
+    _onTimeout: function()
+    {
+        this._isTimerSheduled = false;
+        var task = this._queue.shift();
+        try {
+            task();
+        } finally {
+            this._scheduleTimer();
+        }
+    },
+
+    _scheduleTimer: function()
+    {
+        if (this._queue.length && !this._isTimerSheduled) {
+            setTimeout(this._onTimeout.bind(this), 0);
+            this._isTimerSheduled = true;
+        }
+    }
+}
+
+/**
+ * @constructor
  * @extends {WebInspector.HeapSnapshotWorkerWrapper}
  */
 WebInspector.HeapSnapshotFakeWorker = function()
 {
     this._dispatcher = new WebInspector.HeapSnapshotWorkerDispatcher(window, this._postMessageFromWorker.bind(this));
+    this._asyncTaskQueue = new WebInspector.AsyncTaskQueue();
 }
 
 WebInspector.HeapSnapshotFakeWorker.prototype = {
@@ -93,7 +133,7 @@
             if (this._dispatcher)
                 this._dispatcher.dispatchMessage({data: message});
         }
-        setTimeout(dispatch.bind(this), 0);
+        this._asyncTaskQueue.addTask(dispatch.bind(this));
     },
 
     terminate: function()
@@ -107,7 +147,7 @@
         {
             this.dispatchEventToListeners("message", message);
         }
-        setTimeout(send.bind(this), 0);
+        this._asyncTaskQueue.addTask(send.bind(this));
     }
 };
 
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to