Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(891)

Unified Diff: Source/devtools/front_end/common/utilities.js

Issue 438333003: DevTools: use setImmediate instead of setTimeout for dispatching messages on devtools frontend in d… (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/devtools/front_end/common/utilities.js
diff --git a/Source/devtools/front_end/common/utilities.js b/Source/devtools/front_end/common/utilities.js
index 32d56cc2b87e085fd4e98071d1d20e6ac4c1adeb..67ce668c7b113460a8ebe3ea31991faf5208bfce 100644
--- a/Source/devtools/front_end/common/utilities.js
+++ b/Source/devtools/front_end/common/utilities.js
@@ -1803,3 +1803,24 @@ WeakReference.prototype = {
}
};
+/**
+ * @param {function()} callback
+ */
+window.setImmediate = (function() {
+ var dummy = { foo: 0 };
+ var callbacks = [];
+ Object.observe(dummy, dummyChanged);
yurys 2014/08/07 17:02:13 Wouldn't it be more straightforward with Promise b
+
+ function dummyChanged()
+ {
+ var cbList = callbacks.slice();
+ callbacks.length = 0;
+ cbList.forEach(function(callback) { callback(); });
+ };
+
+ return function setImmediate(callback) {
+ if (!callbacks.length)
+ dummy.foo++;
+ callbacks.push(callback);
+ };
+})();
« no previous file with comments | « no previous file | Source/devtools/front_end/externs.js » ('j') | Source/devtools/front_end/sources/SourcesPanel.js » ('J')

Powered by Google App Engine
This is Rietveld 408576698