| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 /** | 5 /** |
| 6 * @constructor | 6 * @constructor |
| 7 * @param {number} timeout | 7 * @param {number} timeout |
| 8 */ | 8 */ |
| 9 WebInspector.Throttler = function(timeout) | 9 WebInspector.Throttler = function(timeout) |
| 10 { | 10 { |
| 11 this._timeout = timeout; | 11 this._timeout = timeout; |
| 12 this._isRunningProcess = false; | 12 this._isRunningProcess = false; |
| 13 this._asSoonAsPossible = false; | 13 this._asSoonAsPossible = false; |
| 14 /** @type {?function():(!Promise.<?>)} */ | 14 /** @type {?function():(!Promise.<?>)} */ |
| 15 this._process = null; | 15 this._process = null; |
| 16 this._lastCompleteTime = 0; | 16 this._lastCompleteTime = 0; |
| 17 } | 17 }; |
| 18 | 18 |
| 19 WebInspector.Throttler.prototype = { | 19 WebInspector.Throttler.prototype = { |
| 20 _processCompleted: function() | 20 _processCompleted: function() |
| 21 { | 21 { |
| 22 this._lastCompleteTime = window.performance.now(); | 22 this._lastCompleteTime = window.performance.now(); |
| 23 this._isRunningProcess = false; | 23 this._isRunningProcess = false; |
| 24 if (this._process) | 24 if (this._process) |
| 25 this._innerSchedule(false); | 25 this._innerSchedule(false); |
| 26 this._processCompletedForTests(); | 26 this._processCompletedForTests(); |
| 27 }, | 27 }, |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 | 96 |
| 97 /** | 97 /** |
| 98 * @param {function()} operation | 98 * @param {function()} operation |
| 99 * @param {number} timeout | 99 * @param {number} timeout |
| 100 * @return {number} | 100 * @return {number} |
| 101 */ | 101 */ |
| 102 _setTimeout: function(operation, timeout) | 102 _setTimeout: function(operation, timeout) |
| 103 { | 103 { |
| 104 return setTimeout(operation, timeout); | 104 return setTimeout(operation, timeout); |
| 105 } | 105 } |
| 106 } | 106 }; |
| 107 | 107 |
| 108 /** @typedef {function(!Error=)} */ | 108 /** @typedef {function(!Error=)} */ |
| 109 WebInspector.Throttler.FinishCallback; | 109 WebInspector.Throttler.FinishCallback; |
| OLD | NEW |