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

Unified Diff: third_party/WebKit/Source/devtools/front_end/components/CPUThrottlingManager.js

Issue 2843763004: [DevTools] Introduce EmulationModel which will encapsulate emulation (Closed)
Patch Set: +throttling Created 3 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/devtools/front_end/components/CPUThrottlingManager.js
diff --git a/third_party/WebKit/Source/devtools/front_end/components/CPUThrottlingManager.js b/third_party/WebKit/Source/devtools/front_end/components/CPUThrottlingManager.js
index 8b5d156e0601d4ca544c83d873c15dae98abfe25..40a91109947fa4aaf0857a740674416ffa4c7b9c 100644
--- a/third_party/WebKit/Source/devtools/front_end/components/CPUThrottlingManager.js
+++ b/third_party/WebKit/Source/devtools/front_end/components/CPUThrottlingManager.js
@@ -3,16 +3,16 @@
// found in the LICENSE file.
/**
- * @implements {SDK.TargetManager.Observer}
+ * @implements {SDK.SDKModelObserver<!SDK.EmulationModel>}
*/
Components.CPUThrottlingManager = class extends Common.Object {
constructor() {
super();
this._throttlingRate = 1; // No throttling
- SDK.targetManager.observeTargets(this, SDK.Target.Capability.Browser);
/** @type {!Set<!UI.ToolbarComboBox>} */
this._controls = new Set();
this._rates = [1, 2, 5, 10, 20];
+ SDK.targetManager.observeModels(SDK.EmulationModel, this);
}
/**
@@ -20,7 +20,8 @@ Components.CPUThrottlingManager = class extends Common.Object {
*/
_setRateIndex(index) {
this._throttlingRate = this._rates[index];
- SDK.targetManager.targets().forEach(target => target.emulationAgent().setCPUThrottlingRate(this._throttlingRate));
+ for (var emulationModel of SDK.targetManager.models(SDK.EmulationModel))
+ emulationModel.setCPUThrottlingRate(this._throttlingRate);
var icon = null;
if (this._throttlingRate !== 1) {
Host.userMetrics.actionTaken(Host.UserMetrics.Action.CpuThrottlingEnabled);
@@ -42,18 +43,18 @@ Components.CPUThrottlingManager = class extends Common.Object {
/**
* @override
- * @param {!SDK.Target} target
+ * @param {!SDK.EmulationModel} emulationModel
*/
- targetAdded(target) {
+ modelAdded(emulationModel) {
if (this._throttlingRate !== 1)
- target.emulationAgent().setCPUThrottlingRate(this._throttlingRate);
+ emulationModel.setCPUThrottlingRate(this._throttlingRate);
}
/**
* @override
- * @param {!SDK.Target} target
+ * @param {!SDK.EmulationModel} emulationModel
*/
- targetRemoved(target) {
+ modelRemoved(emulationModel) {
}
/**
« no previous file with comments | « third_party/WebKit/Source/devtools/BUILD.gn ('k') | third_party/WebKit/Source/devtools/front_end/emulation/DeviceModeModel.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698