| 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 * @extends {WebInspector.Widget} | 7 * @extends {WebInspector.View} |
| 8 * @param {string} title |
| 8 * @param {boolean=} isWebComponent | 9 * @param {boolean=} isWebComponent |
| 9 */ | 10 */ |
| 10 WebInspector.ThrottledWidget = function(isWebComponent) | 11 WebInspector.ThrottledView = function(title, isWebComponent) |
| 11 { | 12 { |
| 12 WebInspector.Widget.call(this, isWebComponent); | 13 WebInspector.View.call(this, title, isWebComponent); |
| 13 this._updateThrottler = new WebInspector.Throttler(100); | 14 this._updateThrottler = new WebInspector.Throttler(100); |
| 14 this._updateWhenVisible = false; | 15 this._updateWhenVisible = false; |
| 15 } | 16 } |
| 16 | 17 |
| 17 WebInspector.ThrottledWidget.prototype = { | 18 WebInspector.ThrottledView.prototype = { |
| 18 /** | 19 /** |
| 19 * @protected | 20 * @protected |
| 20 * @return {!Promise.<?>} | 21 * @return {!Promise.<?>} |
| 21 */ | 22 */ |
| 22 doUpdate: function() | 23 doUpdate: function() |
| 23 { | 24 { |
| 24 return Promise.resolve(); | 25 return Promise.resolve(); |
| 25 }, | 26 }, |
| 26 | 27 |
| 27 update: function() | 28 update: function() |
| 28 { | 29 { |
| 29 this._updateWhenVisible = !this.isShowing(); | 30 this._updateWhenVisible = !this.isShowing(); |
| 30 if (this._updateWhenVisible) | 31 if (this._updateWhenVisible) |
| 31 return; | 32 return; |
| 32 this._updateThrottler.schedule(innerUpdate.bind(this)); | 33 this._updateThrottler.schedule(innerUpdate.bind(this)); |
| 33 | 34 |
| 34 /** | 35 /** |
| 35 * @this {WebInspector.ThrottledWidget} | 36 * @this {WebInspector.ThrottledView} |
| 36 * @return {!Promise.<?>} | 37 * @return {!Promise.<?>} |
| 37 */ | 38 */ |
| 38 function innerUpdate() | 39 function innerUpdate() |
| 39 { | 40 { |
| 40 if (this.isShowing()) { | 41 if (this.isShowing()) { |
| 41 return this.doUpdate(); | 42 return this.doUpdate(); |
| 42 } else { | 43 } else { |
| 43 this._updateWhenVisible = true; | 44 this._updateWhenVisible = true; |
| 44 return Promise.resolve(); | 45 return Promise.resolve(); |
| 45 } | 46 } |
| 46 } | 47 } |
| 47 }, | 48 }, |
| 48 | 49 |
| 49 /** | 50 /** |
| 50 * @override | 51 * @override |
| 51 */ | 52 */ |
| 52 wasShown: function() | 53 wasShown: function() |
| 53 { | 54 { |
| 54 WebInspector.Widget.prototype.wasShown.call(this); | 55 WebInspector.View.prototype.wasShown.call(this); |
| 55 if (this._updateWhenVisible) | 56 if (this._updateWhenVisible) |
| 56 this.update(); | 57 this.update(); |
| 57 }, | 58 }, |
| 58 | 59 |
| 59 __proto__: WebInspector.Widget.prototype | 60 __proto__: WebInspector.View.prototype |
| 60 } | 61 } |
| OLD | NEW |