| 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(!WebInspector.Throttler.FinishCallback)} */ | 14 /** @type {?function(!WebInspector.Throttler.FinishCallback)} */ |
| 15 this._process = null; | 15 this._process = null; |
| 16 } | 16 } |
| 17 | 17 |
| 18 WebInspector.Throttler.prototype = { | 18 WebInspector.Throttler.prototype = { |
| 19 _processCompleted: function() | 19 _processCompleted: function() |
| 20 { | 20 { |
| 21 this._isRunningProcess = false; | 21 this._isRunningProcess = false; |
| 22 if (this._process) | 22 if (this._process) |
| 23 this._innerSchedule(false); | 23 this._innerSchedule(false); |
| 24 this._processCompletedForTests(); |
| 25 }, |
| 26 |
| 27 _processCompletedForTests: function() |
| 28 { |
| 29 // For sniffing in tests. |
| 24 }, | 30 }, |
| 25 | 31 |
| 26 _onTimeout: function() | 32 _onTimeout: function() |
| 27 { | 33 { |
| 28 delete this._processTimeout; | 34 delete this._processTimeout; |
| 29 this._asSoonAsPossible = false; | 35 this._asSoonAsPossible = false; |
| 30 this._isRunningProcess = true; | 36 this._isRunningProcess = true; |
| 31 | 37 |
| 32 // Process might issue synchronous calls to this throttler. | 38 // Process might issue synchronous calls to this throttler. |
| 33 var process = this._process; | 39 var process = this._process; |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 * @return {number} | 85 * @return {number} |
| 80 */ | 86 */ |
| 81 _setTimeout: function(operation, timeout) | 87 _setTimeout: function(operation, timeout) |
| 82 { | 88 { |
| 83 return setTimeout(operation, timeout); | 89 return setTimeout(operation, timeout); |
| 84 } | 90 } |
| 85 } | 91 } |
| 86 | 92 |
| 87 /** @typedef {function()} */ | 93 /** @typedef {function()} */ |
| 88 WebInspector.Throttler.FinishCallback; | 94 WebInspector.Throttler.FinishCallback; |
| OLD | NEW |