Chromium Code Reviews| Index: third_party/WebKit/Source/devtools/front_end/mobile_throttling/CPUThrottlingManager.js |
| diff --git a/third_party/WebKit/Source/devtools/front_end/mobile_throttling/CPUThrottlingManager.js b/third_party/WebKit/Source/devtools/front_end/mobile_throttling/CPUThrottlingManager.js |
| index 412e9e9fe212a57f4e1bf03cccb92b32a89b965f..b00b809ff4206a6c7c25ed35ddf86ff9d8a3713b 100644 |
| --- a/third_party/WebKit/Source/devtools/front_end/mobile_throttling/CPUThrottlingManager.js |
| +++ b/third_party/WebKit/Source/devtools/front_end/mobile_throttling/CPUThrottlingManager.js |
| @@ -8,18 +8,29 @@ |
| MobileThrottling.CPUThrottlingManager = class extends Common.Object { |
|
dgozman
2017/06/30 00:54:16
Let's rename this one to ThrottlingManager, put in
chenwilliam
2017/06/30 22:01:11
Done.
|
| constructor() { |
| super(); |
| - this._throttlingRate = 1; // No throttling |
| + this._throttlingRate = MobileThrottling.CPUThrottlingRates.NoThrottling; |
| /** @type {!Set<!UI.ToolbarComboBox>} */ |
| this._controls = new Set(); |
| - this._rates = [1, 2, 5, 10, 20]; |
| + this._rates = [ |
| + MobileThrottling.CPUThrottlingRates.NoThrottling, |
| + MobileThrottling.CPUThrottlingRates.MidTierMobile, |
| + MobileThrottling.CPUThrottlingRates.LowEndMobile, |
| + ]; |
| SDK.targetManager.observeModels(SDK.EmulationModel, this); |
| } |
| /** |
| - * @param {number} index |
| + * @return {number} |
| + */ |
| + rate() { |
|
dgozman
2017/06/30 00:54:16
And rename this to cpuThrottlingRate().
chenwilliam
2017/06/30 22:01:11
Done.
|
| + return this._throttlingRate; |
| + } |
| + |
| + /** |
| + * @param {number} rate |
| */ |
| - _setRateIndex(index) { |
| - this._throttlingRate = this._rates[index]; |
| + setRate(rate) { |
| + this._throttlingRate = rate; |
| for (var emulationModel of SDK.targetManager.models(SDK.EmulationModel)) |
| emulationModel.setCPUThrottlingRate(this._throttlingRate); |
| var icon = null; |
| @@ -28,17 +39,11 @@ MobileThrottling.CPUThrottlingManager = class extends Common.Object { |
| icon = UI.Icon.create('smallicon-warning'); |
| icon.title = Common.UIString('CPU throttling is enabled'); |
| } |
| + var index = this._rates.indexOf(this._throttlingRate); |
| for (var control of this._controls) |
| control.setSelectedIndex(index); |
| UI.inspectorView.setPanelIcon('timeline', icon); |
| - this.dispatchEventToListeners(MobileThrottling.CPUThrottlingManager.Events.RateChanged); |
| - } |
| - |
| - /** |
| - * @return {number} |
| - */ |
| - rate() { |
| - return this._throttlingRate; |
| + this.dispatchEventToListeners(MobileThrottling.CPUThrottlingManager.Events.RateChanged, this._throttlingRate); |
| } |
| /** |
| @@ -61,7 +66,7 @@ MobileThrottling.CPUThrottlingManager = class extends Common.Object { |
| * @return {!UI.ToolbarComboBox} |
| */ |
| createControl() { |
| - var control = new UI.ToolbarComboBox(event => this._setRateIndex(event.target.selectedIndex)); |
| + var control = new UI.ToolbarComboBox(event => this.setRate(this._rates[event.target.selectedIndex])); |
| this._controls.add(control); |
| var currentRate = this._throttlingRate; |
| @@ -88,3 +93,6 @@ MobileThrottling.CPUThrottlingManager = class extends Common.Object { |
| MobileThrottling.CPUThrottlingManager.Events = { |
| RateChanged: Symbol('RateChanged') |
| }; |
| + |
| +/** @type {!MobileThrottling.CPUThrottlingManager} */ |
| +MobileThrottling.cpuThrottlingManager; |
|
dgozman
2017/06/30 00:54:16
Let's make this a lazy function to avoid instantia
chenwilliam
2017/06/30 22:01:11
Done.
|