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

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

Issue 1947143003: DevTools: make throttler with timeout respect the timeout. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: tests fixed Created 4 years, 7 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
« no previous file with comments | « third_party/WebKit/LayoutTests/inspector/extensions/extensions-panel.html ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/devtools/front_end/common/Throttler.js
diff --git a/third_party/WebKit/Source/devtools/front_end/common/Throttler.js b/third_party/WebKit/Source/devtools/front_end/common/Throttler.js
index 284f47e321ee8c04af82a43e97bcb43e4dd2d625..5465df5a4429ddc02808f9c973bbf6f86fae987a 100644
--- a/third_party/WebKit/Source/devtools/front_end/common/Throttler.js
+++ b/third_party/WebKit/Source/devtools/front_end/common/Throttler.js
@@ -13,11 +13,13 @@ WebInspector.Throttler = function(timeout)
this._asSoonAsPossible = false;
/** @type {?function():(!Promise.<?>)} */
this._process = null;
+ this._lastCompleteTime = 0;
}
WebInspector.Throttler.prototype = {
_processCompleted: function()
{
+ this._lastCompleteTime = window.performance.now();
this._isRunningProcess = false;
if (this._process)
this._innerSchedule(false);
@@ -53,7 +55,8 @@ WebInspector.Throttler.prototype = {
// Run the first scheduled task instantly.
var hasScheduledTasks = !!this._processTimeout || this._isRunningProcess;
- asSoonAsPossible = !!asSoonAsPossible || !hasScheduledTasks;
+ var okToFire = window.performance.now() - this._lastCompleteTime > this._timeout;
+ asSoonAsPossible = !!asSoonAsPossible || (!hasScheduledTasks && okToFire);
var forceTimerUpdate = asSoonAsPossible && !this._asSoonAsPossible;
this._asSoonAsPossible = this._asSoonAsPossible || asSoonAsPossible;
@@ -61,6 +64,12 @@ WebInspector.Throttler.prototype = {
this._innerSchedule(forceTimerUpdate);
},
+ flush: function()
+ {
+ if (this._process)
+ this._onTimeout();
+ },
+
/**
* @param {boolean} forceTimerUpdate
*/
« no previous file with comments | « third_party/WebKit/LayoutTests/inspector/extensions/extensions-panel.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698