Chromium Code Reviews| Index: third_party/WebKit/Source/devtools/front_end/timeline/TimelinePanel.js |
| diff --git a/third_party/WebKit/Source/devtools/front_end/timeline/TimelinePanel.js b/third_party/WebKit/Source/devtools/front_end/timeline/TimelinePanel.js |
| index ea13f19990dc01b1d2a46d05f1eb9fbbfeac0563..bd5c08cc6e8eb004432cf4dc38ebb8f658bf9df0 100644 |
| --- a/third_party/WebKit/Source/devtools/front_end/timeline/TimelinePanel.js |
| +++ b/third_party/WebKit/Source/devtools/front_end/timeline/TimelinePanel.js |
| @@ -71,7 +71,7 @@ Timeline.TimelinePanel = class extends UI.Panel { |
| this._irModel = new TimelineModel.TimelineIRModel(); |
| /** @type {!Array<!{title: string, model: !SDK.TracingModel}>} */ |
| this._extensionTracingModels = []; |
| - this._cpuThrottlingManager = new Timeline.CPUThrottlingManager(); |
| + this._cpuThrottlingManager = new Components.CPUThrottlingManager(); |
| /** @type {!Array<!Timeline.TimelineModeView>} */ |
| this._currentViews = []; |
| @@ -129,8 +129,10 @@ Timeline.TimelinePanel = class extends UI.Panel { |
| this._configureThrottlingSetting, 'largeicon-settings-gear', Common.UIString('Configure throttling')); |
| SDK.multitargetNetworkManager.addEventListener( |
| SDK.MultitargetNetworkManager.Events.ConditionsChanged, this._updateConfigureThrottlingButton.bind(this)); |
| + this._cpuThrottlingManager.addEventListener( |
| + Components.CPUThrottlingManager.Events.RateChanged, this._updateConfigureThrottlingButton.bind(this)); |
| this._throttlingToolbar = new UI.Toolbar('', this.element); |
| - this._cpuThrottlingCombobox = new UI.ToolbarComboBox(this._onCPUThrottlingChanged.bind(this)); |
| + this._cpuThrottlingCombobox = this._cpuThrottlingManager.createControl(); |
|
caseq
2017/01/12 02:59:12
nit: make it local
|
| this._throttlingToolbar.appendText(Common.UIString('Network:')); |
| this._throttlingToolbar.appendToolbarItem(this._createNetworkConditionsSelect()); |
| this._throttlingToolbar.appendSeparator(); |
| @@ -140,7 +142,6 @@ Timeline.TimelinePanel = class extends UI.Panel { |
| var hideToolbarItem = new UI.ToolbarButton(Common.UIString('Close'), 'largeicon-delete'); |
| hideToolbarItem.addEventListener(UI.ToolbarButton.Events.Click, () => this._configureThrottlingSetting.set(false)); |
| this._throttlingToolbar.appendToolbarItem(hideToolbarItem); |
| - this._populateCPUThrottingCombobox(); |
| this._configureThrottlingSetting.addChangeListener(this._updateThrottlingToolbarVisibility.bind(this)); |
| this._updateThrottlingToolbarVisibility(); |
| @@ -369,28 +370,6 @@ Timeline.TimelinePanel = class extends UI.Panel { |
| return toolbarItem; |
| } |
| - _populateCPUThrottingCombobox() { |
| - var cpuThrottlingCombobox = this._cpuThrottlingCombobox; |
| - cpuThrottlingCombobox.removeOptions(); |
| - var currentRate = this._cpuThrottlingManager.rate(); |
| - var hasSelection = false; |
| - /** |
| - * @param {string} name |
| - * @param {number} value |
| - */ |
| - function addOption(name, value) { |
| - var option = cpuThrottlingCombobox.createOption(name, '', String(value)); |
| - cpuThrottlingCombobox.addOption(option); |
| - if (hasSelection || (value && value !== currentRate)) |
| - return; |
| - cpuThrottlingCombobox.select(option); |
| - hasSelection = true; |
| - } |
| - addOption(Common.UIString('No throttling'), 1); |
| - for (const rate of [2, 5, 10, 20]) |
| - addOption(Common.UIString('%d\xD7 slowdown', rate), rate); |
| - } |
| - |
| _prepareToLoadTimeline() { |
| console.assert(this._state === Timeline.TimelinePanel.State.Idle); |
| this._setState(Timeline.TimelinePanel.State.Loading); |
| @@ -505,14 +484,6 @@ Timeline.TimelinePanel = class extends UI.Panel { |
| this.select(null); |
| } |
| - _onCPUThrottlingChanged() { |
| - if (!this._cpuThrottlingManager) |
| - return; |
| - var text = this._cpuThrottlingCombobox.selectedOption().value; |
| - this._cpuThrottlingManager.setRate(Number.parseFloat(text)); |
| - this._updateConfigureThrottlingButton(); |
| - } |
| - |
| _updateThrottlingToolbarVisibility() { |
| this._throttlingToolbar.element.classList.toggle('hidden', !this._configureThrottlingSetting.get()); |
| } |
| @@ -1878,54 +1849,3 @@ Timeline.TimelineFilters.Events = { |
| }; |
| Timeline.TimelineFilters._durationFilterPresetsMs = [0, 1, 15]; |
| - |
| -/** |
| - * @implements {SDK.TargetManager.Observer} |
| - * @unrestricted |
| - */ |
| -Timeline.CPUThrottlingManager = class extends Common.Object { |
| - constructor() { |
| - super(); |
| - this._targets = []; |
| - this._throttlingRate = 1.; // No throttling |
| - SDK.targetManager.observeTargets(this, SDK.Target.Capability.Browser); |
| - } |
| - |
| - /** |
| - * @param {number} value |
| - */ |
| - setRate(value) { |
| - this._throttlingRate = value; |
| - this._targets.forEach(target => target.emulationAgent().setCPUThrottlingRate(value)); |
| - var icon = null; |
| - if (value !== 1) { |
| - icon = UI.Icon.create('smallicon-warning'); |
| - icon.title = Common.UIString('CPU throttling is enabled'); |
| - } |
| - UI.inspectorView.setPanelIcon('timeline', icon); |
| - } |
| - |
| - /** |
| - * @return {number} |
| - */ |
| - rate() { |
| - return this._throttlingRate; |
| - } |
| - |
| - /** |
| - * @override |
| - * @param {!SDK.Target} target |
| - */ |
| - targetAdded(target) { |
| - this._targets.push(target); |
| - target.emulationAgent().setCPUThrottlingRate(this._throttlingRate); |
| - } |
| - |
| - /** |
| - * @override |
| - * @param {!SDK.Target} target |
| - */ |
| - targetRemoved(target) { |
| - this._targets.remove(target, true); |
| - } |
| -}; |