[module.json extensions] perf_ui
Bug: 1134103
Change-Id: I61ecd89c7bc702b4fafefa4cdc706ab3dddd4d3d
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2656122
Commit-Queue: Andres Olivares <[email protected]>
Reviewed-by: Tim van der Lippe <[email protected]>
diff --git a/devtools_grd_files.gni b/devtools_grd_files.gni
index b132419..97467f7 100644
--- a/devtools_grd_files.gni
+++ b/devtools_grd_files.gni
@@ -319,6 +319,7 @@
"front_end/object_ui/object_ui.js",
"front_end/object_ui/object_ui_module.js",
"front_end/perf_ui/perf_ui-legacy.js",
+ "front_end/perf_ui/perf_ui-meta.js",
"front_end/perf_ui/perf_ui.js",
"front_end/perf_ui/perf_ui_module.js",
"front_end/performance_monitor/performance_monitor-legacy.js",
diff --git a/devtools_module_entrypoints.gni b/devtools_module_entrypoints.gni
index 5963f52..4b8a8a5 100644
--- a/devtools_module_entrypoints.gni
+++ b/devtools_module_entrypoints.gni
@@ -130,6 +130,7 @@
"object_ui/object_ui-legacy.js",
"object_ui/object_ui.js",
"perf_ui/perf_ui-legacy.js",
+ "perf_ui/perf_ui-meta.js",
"perf_ui/perf_ui.js",
"performance_monitor/performance_monitor-legacy.js",
"performance_monitor/performance_monitor-meta.js",
diff --git a/front_end/BUILD.gn b/front_end/BUILD.gn
index e5a2b2e..12566b7 100644
--- a/front_end/BUILD.gn
+++ b/front_end/BUILD.gn
@@ -45,7 +45,6 @@
"js_main:bundle",
"lighthouse_worker:bundle",
"object_ui:bundle",
- "perf_ui:bundle",
"protocol_client:bundle",
"quick_open:bundle",
"recorder:bundle",
@@ -216,6 +215,7 @@
"input:meta",
"linear_memory_inspector:meta",
"main:meta",
+ "perf_ui:meta",
"persistence:legacy",
"persistence:meta",
"profiler:meta",
diff --git a/front_end/i18n/locales/en-US.json b/front_end/i18n/locales/en-US.json
index af778f2..cc197b8 100644
--- a/front_end/i18n/locales/en-US.json
+++ b/front_end/i18n/locales/en-US.json
@@ -2348,33 +2348,6 @@
"perf_ui/LineLevelProfile.js | ms": {
"message": "ms"
},
- "perf_ui/ModuleUIStrings.js | collectGarbage": {
- "message": "Collect garbage"
- },
- "perf_ui/ModuleUIStrings.js | flamechartMouseWheelAction": {
- "message": "Flamechart mouse wheel action:"
- },
- "perf_ui/ModuleUIStrings.js | hideLiveMemoryAllocation": {
- "message": "Hide live memory allocation annotations"
- },
- "perf_ui/ModuleUIStrings.js | liveMemoryAllocationAnnotations": {
- "message": "Live memory allocation annotations"
- },
- "perf_ui/ModuleUIStrings.js | memory": {
- "message": "Memory"
- },
- "perf_ui/ModuleUIStrings.js | performance": {
- "message": "Performance"
- },
- "perf_ui/ModuleUIStrings.js | scroll": {
- "message": "Scroll"
- },
- "perf_ui/ModuleUIStrings.js | showLiveMemoryAllocation": {
- "message": "Show live memory allocation annotations"
- },
- "perf_ui/ModuleUIStrings.js | zoom": {
- "message": "Zoom"
- },
"perf_ui/NetworkPriorities.js | high": {
"message": "High"
},
@@ -2399,6 +2372,27 @@
"perf_ui/OverviewGrid.js | rightResizer": {
"message": "Right Resizer"
},
+ "perf_ui/perf_ui-meta.ts | collectGarbage": {
+ "message": "Collect garbage"
+ },
+ "perf_ui/perf_ui-meta.ts | flamechartMouseWheelAction": {
+ "message": "Flamechart mouse wheel action:"
+ },
+ "perf_ui/perf_ui-meta.ts | hideLiveMemoryAllocation": {
+ "message": "Hide live memory allocation annotations"
+ },
+ "perf_ui/perf_ui-meta.ts | liveMemoryAllocationAnnotations": {
+ "message": "Live memory allocation annotations"
+ },
+ "perf_ui/perf_ui-meta.ts | scroll": {
+ "message": "Scroll"
+ },
+ "perf_ui/perf_ui-meta.ts | showLiveMemoryAllocation": {
+ "message": "Show live memory allocation annotations"
+ },
+ "perf_ui/perf_ui-meta.ts | zoom": {
+ "message": "Zoom"
+ },
"perf_ui/PieChart.ts | total": {
"message": "Total"
},
diff --git a/front_end/perf_ui/BUILD.gn b/front_end/perf_ui/BUILD.gn
index ca5be5e..0b67cea 100644
--- a/front_end/perf_ui/BUILD.gn
+++ b/front_end/perf_ui/BUILD.gn
@@ -54,3 +54,9 @@
deps = [ ":bundle" ]
}
+
+devtools_entrypoint("meta") {
+ entrypoint = "perf_ui-meta.ts"
+
+ deps = [ ":bundle" ]
+}
diff --git a/front_end/perf_ui/GCActionDelegate.js b/front_end/perf_ui/GCActionDelegate.js
index 9531a0b..e178006 100644
--- a/front_end/perf_ui/GCActionDelegate.js
+++ b/front_end/perf_ui/GCActionDelegate.js
@@ -5,11 +5,27 @@
import * as SDK from '../sdk/sdk.js';
import * as UI from '../ui/ui.js'; // eslint-disable-line no-unused-vars
+/** @type {!GCActionDelegate} */
+let gCActionDelegateInstance;
+
+
/**
* @implements {UI.ActionRegistration.ActionDelegate}
*/
export class GCActionDelegate {
/**
+ * @param {{forceNew: ?boolean}} opts
+ */
+ static instance(opts = {forceNew: null}) {
+ const {forceNew} = opts;
+ if (!gCActionDelegateInstance || forceNew) {
+ gCActionDelegateInstance = new GCActionDelegate();
+ }
+
+ return gCActionDelegateInstance;
+ }
+
+ /**
* @override
* @param {!UI.Context.Context} context
* @param {string} actionId
diff --git a/front_end/perf_ui/ModuleUIStrings.js b/front_end/perf_ui/ModuleUIStrings.js
index 2d359f1..57b2457 100644
--- a/front_end/perf_ui/ModuleUIStrings.js
+++ b/front_end/perf_ui/ModuleUIStrings.js
@@ -3,42 +3,5 @@
// found in the LICENSE file.
import * as i18n from '../i18n/i18n.js';
-export const UIStrings = {
- /**
- *@description Text for the performance of something
- */
- performance: 'Performance',
- /**
- *@description Title of a setting under the Performance category in Settings
- */
- flamechartMouseWheelAction: 'Flamechart mouse wheel action:',
- /**
- *@description The action to scroll
- */
- scroll: 'Scroll',
- /**
- *@description Text for zooming in
- */
- zoom: 'Zoom',
- /**
- *@description Text for the memory of the page
- */
- memory: 'Memory',
- /**
- *@description Title of a setting under the Memory category in Settings
- */
- liveMemoryAllocationAnnotations: 'Live memory allocation annotations',
- /**
- *@description Title of a setting under the Memory category that can be invoked through the Command Menu
- */
- showLiveMemoryAllocation: 'Show live memory allocation annotations',
- /**
- *@description Title of a setting under the Memory category that can be invoked through the Command Menu
- */
- hideLiveMemoryAllocation: 'Hide live memory allocation annotations',
- /**
- *@description Title of an action in the components tool to collect garbage
- */
- collectGarbage: 'Collect garbage',
-};
+export const UIStrings = {};
i18n.i18n.registerUIStrings('perf_ui/ModuleUIStrings.js', UIStrings);
diff --git a/front_end/perf_ui/module.json b/front_end/perf_ui/module.json
index 0ca588c..4ec477d 100644
--- a/front_end/perf_ui/module.json
+++ b/front_end/perf_ui/module.json
@@ -15,53 +15,6 @@
"type": "@SourceFrame.LineDecorator",
"className": "PerfUI.LineLevelProfile.LineDecorator",
"decoratorType": "memory"
- },
- {
- "type": "setting",
- "category": "Performance",
- "title": "Flamechart mouse wheel action:",
- "settingName": "flamechartMouseWheelAction",
- "settingType": "enum",
- "defaultValue": "zoom",
- "options": [
- {
- "title": "Scroll",
- "text": "Scroll",
- "value": "scroll"
- },
- {
- "title": "Zoom",
- "text": "Zoom",
- "value": "zoom"
- }
- ]
- },
- {
- "type": "setting",
- "category": "Memory",
- "experiment": "liveHeapProfile",
- "title": "Live memory allocation annotations",
- "settingName": "memoryLiveHeapProfile",
- "settingType": "boolean",
- "defaultValue": false,
- "options": [
- {
- "value": true,
- "title": "Show live memory allocation annotations"
- },
- {
- "value": false,
- "title": "Hide live memory allocation annotations"
- }
- ]
- },
- {
- "type": "action",
- "actionId": "components.collect-garbage",
- "category": "Performance",
- "title": "Collect garbage",
- "iconClass": "largeicon-trash-bin",
- "className": "PerfUI.GCActionDelegate"
}
],
"dependencies": [
diff --git a/front_end/perf_ui/perf_ui-meta.ts b/front_end/perf_ui/perf_ui-meta.ts
new file mode 100644
index 0000000..14bf8c4
--- /dev/null
+++ b/front_end/perf_ui/perf_ui-meta.ts
@@ -0,0 +1,106 @@
+// Copyright 2021 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+import * as Common from '../common/common.js';
+import * as i18n from '../i18n/i18n.js';
+import * as Root from '../root/root.js';
+import * as UI from '../ui/ui.js';
+
+// eslint-disable-next-line rulesdir/es_modules_import
+import type * as PerfUI from './perf_ui.js';
+
+export const UIStrings = {
+ /**
+ *@description Title of a setting under the Performance category in Settings
+ */
+ flamechartMouseWheelAction: 'Flamechart mouse wheel action:',
+ /**
+ *@description The action to scroll
+ */
+ scroll: 'Scroll',
+ /**
+ *@description Text for zooming in
+ */
+ zoom: 'Zoom',
+ /**
+ *@description Title of a setting under the Memory category in Settings
+ */
+ liveMemoryAllocationAnnotations: 'Live memory allocation annotations',
+ /**
+ *@description Title of a setting under the Memory category that can be invoked through the Command Menu
+ */
+ showLiveMemoryAllocation: 'Show live memory allocation annotations',
+ /**
+ *@description Title of a setting under the Memory category that can be invoked through the Command Menu
+ */
+ hideLiveMemoryAllocation: 'Hide live memory allocation annotations',
+ /**
+ *@description Title of an action in the components tool to collect garbage
+ */
+ collectGarbage: 'Collect garbage',
+};
+
+const str_ = i18n.i18n.registerUIStrings('perf_ui/perf_ui-meta.ts', UIStrings);
+const i18nString = i18n.i18n.getLazilyComputedLocalizedString.bind(undefined, str_);
+
+let loadedPerfUIModule: (typeof PerfUI|undefined);
+
+async function loadPerfUIModule(): Promise<typeof PerfUI> {
+ if (!loadedPerfUIModule) {
+ // Side-effect import resources in module.json
+ await Root.Runtime.Runtime.instance().loadModulePromise('perf_ui');
+ loadedPerfUIModule = await import('./perf_ui.js');
+ }
+ return loadedPerfUIModule;
+}
+
+UI.ActionRegistration.registerActionExtension({
+ actionId: 'components.collect-garbage',
+ category: UI.ActionRegistration.ActionCategory.PERFORMANCE,
+ title: i18nString(UIStrings.collectGarbage),
+ iconClass: UI.ActionRegistration.IconClass.LARGEICON_TRASH_BIN,
+ async loadActionDelegate() {
+ const PerfUI = await loadPerfUIModule();
+ return PerfUI.GCActionDelegate.GCActionDelegate.instance();
+ },
+});
+
+Common.Settings.registerSettingExtension({
+ category: Common.Settings.SettingCategoryObject.PERFORMANCE,
+ title: i18nString(UIStrings.flamechartMouseWheelAction),
+ settingName: 'flamechartMouseWheelAction',
+ settingType: Common.Settings.SettingTypeObject.ENUM,
+ defaultValue: 'zoom',
+ options: [
+ {
+ title: i18nString(UIStrings.scroll),
+ text: i18nString(UIStrings.scroll),
+ value: 'scroll',
+ },
+ {
+ title: i18nString(UIStrings.zoom),
+ text: i18nString(UIStrings.zoom),
+ value: 'zoom',
+ },
+ ],
+});
+
+Common.Settings.registerSettingExtension({
+ category: Common.Settings.SettingCategoryObject.MEMORY,
+ experiment: Root.Runtime.ExperimentName.LIVE_HEAP_PROFILE,
+ title: i18nString(UIStrings.liveMemoryAllocationAnnotations),
+ settingName: 'memoryLiveHeapProfile',
+ settingType: Common.Settings.SettingTypeObject.BOOLEAN,
+ defaultValue: false,
+ options: [
+ {
+ value: true,
+ title: i18nString(UIStrings.showLiveMemoryAllocation),
+ },
+ {
+ value: false,
+ title: i18nString(UIStrings.hideLiveMemoryAllocation),
+ },
+ ],
+});
diff --git a/front_end/shell.js b/front_end/shell.js
index 2156817..371990b 100644
--- a/front_end/shell.js
+++ b/front_end/shell.js
@@ -28,4 +28,5 @@
import './persistence/persistence-meta.js';
import './browser_sdk/browser_sdk-meta.js';
import './main/main-meta.js';
+import './perf_ui/perf_ui-meta.js';
// We generate the descriptors in this file, which depend on the runtime.
diff --git a/front_end/ui/ActionRegistration.ts b/front_end/ui/ActionRegistration.ts
index 8e6a612..01d9609 100644
--- a/front_end/ui/ActionRegistration.ts
+++ b/front_end/ui/ActionRegistration.ts
@@ -351,6 +351,7 @@
LARGEICON_PLAY = 'largeicon-play',
LARGEICON_PAUSE = 'largeicon-pause',
LARGEICON_RESUME = 'largeicon-resume',
+ LARGEICON_TRASH_BIN = 'largeicon-trash-bin',
}
export const enum KeybindSet {