OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 * @implements {SDK.SDKModelObserver<!SDK.EmulationModel>} | 6 * @implements {SDK.SDKModelObserver<!SDK.EmulationModel>} |
7 */ | 7 */ |
8 Components.CPUThrottlingManager = class extends Common.Object { | 8 MobileThrottling.CPUThrottlingManager = class extends Common.Object { |
9 constructor() { | 9 constructor() { |
10 super(); | 10 super(); |
11 this._throttlingRate = 1; // No throttling | 11 this._throttlingRate = 1; // No throttling |
12 /** @type {!Set<!UI.ToolbarComboBox>} */ | 12 /** @type {!Set<!UI.ToolbarComboBox>} */ |
13 this._controls = new Set(); | 13 this._controls = new Set(); |
14 this._rates = [1, 2, 5, 10, 20]; | 14 this._rates = [1, 2, 5, 10, 20]; |
15 SDK.targetManager.observeModels(SDK.EmulationModel, this); | 15 SDK.targetManager.observeModels(SDK.EmulationModel, this); |
16 } | 16 } |
17 | 17 |
18 /** | 18 /** |
19 * @param {number} index | 19 * @param {number} index |
20 */ | 20 */ |
21 _setRateIndex(index) { | 21 _setRateIndex(index) { |
22 this._throttlingRate = this._rates[index]; | 22 this._throttlingRate = this._rates[index]; |
23 for (var emulationModel of SDK.targetManager.models(SDK.EmulationModel)) | 23 for (var emulationModel of SDK.targetManager.models(SDK.EmulationModel)) |
24 emulationModel.setCPUThrottlingRate(this._throttlingRate); | 24 emulationModel.setCPUThrottlingRate(this._throttlingRate); |
25 var icon = null; | 25 var icon = null; |
26 if (this._throttlingRate !== 1) { | 26 if (this._throttlingRate !== 1) { |
27 Host.userMetrics.actionTaken(Host.UserMetrics.Action.CpuThrottlingEnabled)
; | 27 Host.userMetrics.actionTaken(Host.UserMetrics.Action.CpuThrottlingEnabled)
; |
28 icon = UI.Icon.create('smallicon-warning'); | 28 icon = UI.Icon.create('smallicon-warning'); |
29 icon.title = Common.UIString('CPU throttling is enabled'); | 29 icon.title = Common.UIString('CPU throttling is enabled'); |
30 } | 30 } |
31 for (var control of this._controls) | 31 for (var control of this._controls) |
32 control.setSelectedIndex(index); | 32 control.setSelectedIndex(index); |
33 UI.inspectorView.setPanelIcon('timeline', icon); | 33 UI.inspectorView.setPanelIcon('timeline', icon); |
34 this.dispatchEventToListeners(Components.CPUThrottlingManager.Events.RateCha
nged); | 34 this.dispatchEventToListeners(MobileThrottling.CPUThrottlingManager.Events.R
ateChanged); |
35 } | 35 } |
36 | 36 |
37 /** | 37 /** |
38 * @return {number} | 38 * @return {number} |
39 */ | 39 */ |
40 rate() { | 40 rate() { |
41 return this._throttlingRate; | 41 return this._throttlingRate; |
42 } | 42 } |
43 | 43 |
44 /** | 44 /** |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 | 78 |
79 /** | 79 /** |
80 * @param {!UI.ToolbarComboBox} control | 80 * @param {!UI.ToolbarComboBox} control |
81 */ | 81 */ |
82 disposeControl(control) { | 82 disposeControl(control) { |
83 this._controls.delete(control); | 83 this._controls.delete(control); |
84 } | 84 } |
85 }; | 85 }; |
86 | 86 |
87 /** @enum {symbol} */ | 87 /** @enum {symbol} */ |
88 Components.CPUThrottlingManager.Events = { | 88 MobileThrottling.CPUThrottlingManager.Events = { |
89 RateChanged: Symbol('RateChanged') | 89 RateChanged: Symbol('RateChanged') |
90 }; | 90 }; |
OLD | NEW |