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

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

Issue 1285183006: DevTools: WI.Throttler goes promisified. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@cc
Patch Set: remove dependent patchset Created 5 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/Throttler.js
diff --git a/Source/devtools/front_end/common/Throttler.js b/Source/devtools/front_end/common/Throttler.js
index f6a8998783af7d4554e053e1f823b53e2937ea3d..284f47e321ee8c04af82a43e97bcb43e4dd2d625 100644
--- a/Source/devtools/front_end/common/Throttler.js
+++ b/Source/devtools/front_end/common/Throttler.js
@@ -11,18 +11,13 @@ WebInspector.Throttler = function(timeout)
this._timeout = timeout;
this._isRunningProcess = false;
this._asSoonAsPossible = false;
- /** @type {?function(!WebInspector.Throttler.FinishCallback)} */
+ /** @type {?function():(!Promise.<?>)} */
this._process = null;
}
WebInspector.Throttler.prototype = {
- /**
- * @param {!Error=} error
- */
- _processCompleted: function(error)
+ _processCompleted: function()
{
- if (error)
- console.error(error);
this._isRunningProcess = false;
if (this._process)
this._innerSchedule(false);
@@ -40,20 +35,15 @@ WebInspector.Throttler.prototype = {
this._asSoonAsPossible = false;
this._isRunningProcess = true;
- // Process might issue synchronous calls to this throttler.
- var process = this._process;
+ Promise.resolve()
+ .then(this._process)
+ .catch(console.error.bind(console))
+ .then(this._processCompleted.bind(this));
this._process = null;
- try {
- process(this._processCompleted.bind(this));
- } catch (e) {
- // Process might have called completed() and threw exception later.
- if (this._isRunningProcess)
- this._processCompleted(e);
- }
},
/**
- * @param {function(!WebInspector.Throttler.FinishCallback)} process
+ * @param {function():(!Promise.<?>)} process
* @param {boolean=} asSoonAsPossible
*/
schedule: function(process, asSoonAsPossible)
« no previous file with comments | « Source/devtools/front_end/bindings/WorkspaceController.js ('k') | Source/devtools/front_end/console/ConsoleView.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698