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

Side by Side Diff: Source/devtools/front_end/ui/ThrottledWidget.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 unified diff | Download patch
OLDNEW
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.Widget}
8 */ 8 */
9 WebInspector.ThrottledWidget = function() 9 WebInspector.ThrottledWidget = function()
10 { 10 {
11 WebInspector.Widget.call(this); 11 WebInspector.Widget.call(this);
12 this._updateThrottler = new WebInspector.Throttler(100); 12 this._updateThrottler = new WebInspector.Throttler(100);
13 this._updateWhenVisible = false; 13 this._updateWhenVisible = false;
14 } 14 }
15 15
16 WebInspector.ThrottledWidget.prototype = { 16 WebInspector.ThrottledWidget.prototype = {
17 /** 17 /**
18 * @param {!WebInspector.Throttler.FinishCallback} finishedCallback
19 * @protected 18 * @protected
19 * @return {!Promise.<?>}
20 */ 20 */
21 doUpdate: function(finishedCallback) 21 doUpdate: function()
22 { 22 {
23 finishedCallback(); 23 return Promise.resolve();
24 }, 24 },
25 25
26 update: function() 26 update: function()
27 { 27 {
28 this._updateWhenVisible = !this.isShowing(); 28 this._updateWhenVisible = !this.isShowing();
29 if (this._updateWhenVisible) 29 if (this._updateWhenVisible)
30 return; 30 return;
31 this._updateThrottler.schedule(innerUpdate.bind(this)); 31 this._updateThrottler.schedule(innerUpdate.bind(this));
32 32
33 /** 33 /**
34 * @param {!WebInspector.Throttler.FinishCallback} finishedCallback
35 * @this {WebInspector.ThrottledWidget} 34 * @this {WebInspector.ThrottledWidget}
35 * @return {!Promise.<?>}
36 */ 36 */
37 function innerUpdate(finishedCallback) 37 function innerUpdate()
38 { 38 {
39 if (this.isShowing()) { 39 if (this.isShowing()) {
40 this.doUpdate(finishedCallback); 40 return this.doUpdate();
41 } else { 41 } else {
42 this._updateWhenVisible = true; 42 this._updateWhenVisible = true;
43 finishedCallback(); 43 return Promise.resolve();
44 } 44 }
45 } 45 }
46 }, 46 },
47 47
48 /** 48 /**
49 * @override 49 * @override
50 */ 50 */
51 wasShown: function() 51 wasShown: function()
52 { 52 {
53 WebInspector.Widget.prototype.wasShown.call(this); 53 WebInspector.Widget.prototype.wasShown.call(this);
54 if (this._updateWhenVisible) 54 if (this._updateWhenVisible)
55 this.update(); 55 this.update();
56 }, 56 },
57 57
58 __proto__: WebInspector.Widget.prototype 58 __proto__: WebInspector.Widget.prototype
59 } 59 }
OLDNEW
« no previous file with comments | « Source/devtools/front_end/profiler/HeapSnapshotView.js ('k') | Source/devtools/front_end/ui_lazy/TimelineOverviewPane.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698