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

Unified Diff: third_party/WebKit/Source/devtools/front_end/mobile_throttling/ThrottlingSettingsTab.js

Issue 2938503002: DevTools: unify Network & CPU throttling (Closed)
Patch Set: fmt Created 3 years, 6 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/mobile_throttling/ThrottlingSettingsTab.js
diff --git a/third_party/WebKit/Source/devtools/front_end/mobile_throttling/NetworkConditionsSettingsTab.js b/third_party/WebKit/Source/devtools/front_end/mobile_throttling/ThrottlingSettingsTab.js
similarity index 74%
rename from third_party/WebKit/Source/devtools/front_end/mobile_throttling/NetworkConditionsSettingsTab.js
rename to third_party/WebKit/Source/devtools/front_end/mobile_throttling/ThrottlingSettingsTab.js
index a8a86fc1f8d3037c24f22353b394fa0665ec037b..8ee430c3306a87bc049dacfbb923a8764d03d3c1 100644
--- a/third_party/WebKit/Source/devtools/front_end/mobile_throttling/NetworkConditionsSettingsTab.js
+++ b/third_party/WebKit/Source/devtools/front_end/mobile_throttling/ThrottlingSettingsTab.js
@@ -6,12 +6,12 @@
* @implements {UI.ListWidget.Delegate}
* @unrestricted
*/
-MobileThrottling.NetworkConditionsSettingsTab = class extends UI.VBox {
+MobileThrottling.ThrottlingSettingsTab = class extends UI.VBox {
constructor() {
super(true);
- this.registerRequiredCSS('mobile_throttling/networkConditionsSettingsTab.css');
+ this.registerRequiredCSS('mobile_throttling/throttlingSettingsTab.css');
- this.contentElement.createChild('div', 'header').textContent = Common.UIString('Network Throttling Profiles');
+ this.contentElement.createChild('div', 'header').textContent = Common.UIString('Mobile Throttling Profiles');
var addButton = UI.createTextButton(
Common.UIString('Add custom profile...'), this._addButtonClicked.bind(this), 'add-conditions-button');
@@ -19,10 +19,10 @@ MobileThrottling.NetworkConditionsSettingsTab = class extends UI.VBox {
this._list = new UI.ListWidget(this);
this._list.element.classList.add('conditions-list');
- this._list.registerRequiredCSS('mobile_throttling/networkConditionsSettingsTab.css');
+ this._list.registerRequiredCSS('mobile_throttling/throttlingSettingsTab.css');
this._list.show(this.contentElement);
- this._customSetting = Common.moduleSetting('customNetworkConditions');
+ this._customSetting = Common.moduleSetting('customThrottlingConditions');
this._customSetting.addChangeListener(this._conditionsUpdated, this);
this.setDefaultFocusedElement(addButton);
@@ -48,7 +48,8 @@ MobileThrottling.NetworkConditionsSettingsTab = class extends UI.VBox {
}
_addButtonClicked() {
- this._list.addNewItem(this._customSetting.get().length, {title: '', download: -1, upload: -1, latency: 0});
+ this._list.addNewItem(
+ this._customSetting.get().length, {title: '', download: -1, upload: -1, latency: 0, cpuThrottlingRate: 0});
}
/**
@@ -58,7 +59,7 @@ MobileThrottling.NetworkConditionsSettingsTab = class extends UI.VBox {
* @return {!Element}
*/
renderItem(item, editable) {
- var conditions = /** @type {!SDK.NetworkManager.Conditions} */ (item);
+ var conditions = /** @type {!SDK.MobileThrottling.Conditions} */ (item);
var element = createElementWithClass('div', 'conditions-list-item');
var title = element.createChild('div', 'conditions-list-text conditions-list-title');
var titleText = title.createChild('div', 'conditions-list-title-text');
@@ -66,12 +67,15 @@ MobileThrottling.NetworkConditionsSettingsTab = class extends UI.VBox {
titleText.title = conditions.title;
element.createChild('div', 'conditions-list-separator');
element.createChild('div', 'conditions-list-text').textContent =
- MobileThrottling.NetworkConditionsSelector.throughputText(conditions.download);
+ MobileThrottling.ThrottlingSelector.throughputText(conditions.download);
element.createChild('div', 'conditions-list-separator');
element.createChild('div', 'conditions-list-text').textContent =
- MobileThrottling.NetworkConditionsSelector.throughputText(conditions.upload);
+ MobileThrottling.ThrottlingSelector.throughputText(conditions.upload);
element.createChild('div', 'conditions-list-separator');
element.createChild('div', 'conditions-list-text').textContent = Common.UIString('%dms', conditions.latency);
+ element.createChild('div', 'conditions-list-separator');
+ element.createChild('div', 'conditions-list-text').textContent =
+ Common.UIString('%d\xD7', conditions.cpuThrottlingRate);
dgozman 2017/06/13 01:47:08 '%d times' maybe? 'x' looks strange.
chenwilliam 2017/06/13 21:54:51 Yeah looks a bit weird. Done.
return element;
}
@@ -93,7 +97,7 @@ MobileThrottling.NetworkConditionsSettingsTab = class extends UI.VBox {
* @param {boolean} isNew
*/
commitEdit(item, editor, isNew) {
- var conditions = /** @type {?SDK.NetworkManager.Conditions} */ (item);
+ var conditions = /** @type {?SDK.MobileThrottling.Conditions} */ (item);
conditions.title = editor.control('title').value.trim();
var download = editor.control('download').value.trim();
conditions.download = download ? parseInt(download, 10) * (1024 / 8) : -1;
@@ -101,6 +105,8 @@ MobileThrottling.NetworkConditionsSettingsTab = class extends UI.VBox {
conditions.upload = upload ? parseInt(upload, 10) * (1024 / 8) : -1;
var latency = editor.control('latency').value.trim();
conditions.latency = latency ? parseInt(latency, 10) : 0;
+ var cpuThrottlingRate = editor.control('cpuThrottlingRate').value.trim();
+ conditions.cpuThrottlingRate = cpuThrottlingRate ? parseInt(cpuThrottlingRate, 10) : 1;
var list = this._customSetting.get();
if (isNew)
@@ -114,12 +120,14 @@ MobileThrottling.NetworkConditionsSettingsTab = class extends UI.VBox {
* @return {!UI.ListWidget.Editor}
*/
beginEdit(item) {
- var conditions = /** @type {?SDK.NetworkManager.Conditions} */ (item);
+ var conditions = /** @type {?SDK.MobileThrottling.Conditions} */ (item);
var editor = this._createEditor();
editor.control('title').value = conditions.title;
editor.control('download').value = conditions.download <= 0 ? '' : String(conditions.download / (1024 / 8));
editor.control('upload').value = conditions.upload <= 0 ? '' : String(conditions.upload / (1024 / 8));
editor.control('latency').value = conditions.latency ? String(conditions.latency) : '';
+ editor.control('cpuThrottlingRate').value =
+ conditions.cpuThrottlingRate ? String(conditions.cpuThrottlingRate) : '';
return editor;
}
@@ -134,7 +142,7 @@ MobileThrottling.NetworkConditionsSettingsTab = class extends UI.VBox {
this._editor = editor;
var content = editor.contentElement();
- var titles = content.createChild('div', 'conditions-edit-row');
+ var titles = content.createChild('div', 'conditions-header-row');
titles.createChild('div', 'conditions-list-text conditions-list-title').textContent =
Common.UIString('Profile Name');
titles.createChild('div', 'conditions-list-separator conditions-list-separator-invisible');
@@ -143,6 +151,8 @@ MobileThrottling.NetworkConditionsSettingsTab = class extends UI.VBox {
titles.createChild('div', 'conditions-list-text').textContent = Common.UIString('Upload');
titles.createChild('div', 'conditions-list-separator conditions-list-separator-invisible');
titles.createChild('div', 'conditions-list-text').textContent = Common.UIString('Latency');
+ titles.createChild('div', 'conditions-list-separator conditions-list-separator-invisible');
+ titles.createChild('div', 'conditions-list-text').textContent = Common.UIString('CPU Slowdown');
var fields = content.createChild('div', 'conditions-edit-row');
fields.createChild('div', 'conditions-list-text conditions-list-title')
@@ -162,6 +172,12 @@ MobileThrottling.NetworkConditionsSettingsTab = class extends UI.VBox {
cell = fields.createChild('div', 'conditions-list-text');
cell.appendChild(editor.createInput('latency', 'text', Common.UIString('ms'), latencyValidator));
cell.createChild('div', 'conditions-edit-optional').textContent = Common.UIString('optional');
+ fields.createChild('div', 'conditions-list-separator conditions-list-separator-invisible');
+
+ cell = fields.createChild('div', 'conditions-list-text');
+ cell.appendChild(
+ editor.createInput('cpuThrottlingRate', 'text', Common.UIString('\xD7'), cpuThrottlingRateValidator));
+ cell.createChild('div', 'conditions-edit-optional').textContent = Common.UIString('optional');
return editor;
@@ -197,5 +213,16 @@ MobileThrottling.NetworkConditionsSettingsTab = class extends UI.VBox {
var value = input.value.trim();
return !value || (/^[\d]+$/.test(value) && value >= 0 && value <= 1000000);
}
+
+ /**
+ * @param {*} item
+ * @param {number} index
+ * @param {!HTMLInputElement|!HTMLSelectElement} input
+ * @return {boolean}
+ */
+ function cpuThrottlingRateValidator(item, index, input) {
+ var value = input.value.trim();
+ return !value || (/^[\d]+$/.test(value) && value >= 1 && value <= 1000000);
+ }
}
};

Powered by Google App Engine
This is Rietveld 408576698