зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1597378 - Change location of the presets; r=julienw
The presets in recording-utils.js couldn't be shared via the ChromeUtils.import mechanism. When they were in recording-utils.js they could only be loaded in via the DevTools require() loader. This commit changes it so that they are stored in a jsm, and are also injected to each UI interface where the ChromeUtils.import function is available (only in the initializers). Differential Revision: https://phabricator.services.mozilla.com/D62912 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
7d0881e8e8
Коммит
7b53ec6841
|
@ -210,6 +210,8 @@ export interface InitializedValues {
|
|||
receiveProfile: ReceiveProfile;
|
||||
// A function to set the recording settings.
|
||||
setRecordingPreferences: SetRecordingPreferences;
|
||||
// The current list of presets, loaded in from a JSM.
|
||||
presets: Presets;
|
||||
// Determine the current page context.
|
||||
pageContext: PageContext;
|
||||
// The popup and devtools panel use different codepaths for getting symbol tables.
|
||||
|
@ -264,6 +266,7 @@ export type Action =
|
|||
perfFront: PerfFront;
|
||||
receiveProfile: ReceiveProfile;
|
||||
setRecordingPreferences: SetRecordingPreferences;
|
||||
presets: Presets;
|
||||
pageContext: PageContext;
|
||||
recordingSettingsFromPreferences: RecordingStateFromPreferences;
|
||||
getSymbolTableGetter: (profile: object) => GetSymbolTableCallback;
|
||||
|
@ -279,6 +282,7 @@ export interface InitializeStoreValues {
|
|||
perfFront: PerfFront;
|
||||
receiveProfile: ReceiveProfile;
|
||||
setRecordingPreferences: SetRecordingPreferences;
|
||||
presets: Presets;
|
||||
pageContext: PageContext;
|
||||
recordingPreferences: RecordingStateFromPreferences;
|
||||
supportedFeatures: string[] | null;
|
||||
|
@ -399,7 +403,7 @@ export interface PresetDefinition {
|
|||
duration: number;
|
||||
}
|
||||
|
||||
export interface PresetDefinitions {
|
||||
export interface Presets {
|
||||
[presetName: string]: PresetDefinition;
|
||||
}
|
||||
|
||||
|
|
|
@ -45,6 +45,7 @@ const {
|
|||
getRecordingPreferencesFromBrowser,
|
||||
setRecordingPreferencesOnBrowser,
|
||||
getSymbolsFromThisBrowser,
|
||||
presets,
|
||||
} = ChromeUtils.import(
|
||||
"resource://devtools/client/performance-new/popup/background.jsm.js"
|
||||
);
|
||||
|
@ -83,6 +84,7 @@ document.addEventListener("DOMContentLoaded", async () => {
|
|||
perfFront: perfFrontInterface,
|
||||
receiveProfile,
|
||||
supportedFeatures,
|
||||
presets,
|
||||
// Get the preferences from the current browser
|
||||
recordingPreferences: getRecordingPreferencesFromBrowser(),
|
||||
// In the popup, the preferences are stored directly on the current browser.
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
/**
|
||||
* @typedef {Object} StateProps
|
||||
* @property {string} presetName
|
||||
* @property {import("../@types/perf").Presets} presets
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@ -34,7 +35,7 @@ const {
|
|||
const selectors = require("devtools/client/performance-new/store/selectors");
|
||||
const actions = require("devtools/client/performance-new/store/actions");
|
||||
const { connect } = require("devtools/client/shared/vendor/react-redux");
|
||||
const { presets } = require("devtools/shared/performance-new/recording-utils");
|
||||
|
||||
/**
|
||||
* Switch between various profiler presets, which will override the individualized
|
||||
* settings for the profiler.
|
||||
|
@ -53,7 +54,8 @@ class Presets extends PureComponent {
|
|||
* @param {React.ChangeEvent<HTMLInputElement>} event
|
||||
*/
|
||||
onChange(event) {
|
||||
this.props.changePreset(event.target.value);
|
||||
const { presets } = this.props;
|
||||
this.props.changePreset(presets, event.target.value);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -61,7 +63,7 @@ class Presets extends PureComponent {
|
|||
* @returns {React.ReactNode}
|
||||
*/
|
||||
renderPreset(presetName) {
|
||||
const preset = presets[presetName];
|
||||
const preset = this.props.presets[presetName];
|
||||
let labelText, description;
|
||||
if (preset) {
|
||||
labelText = preset.label;
|
||||
|
@ -110,6 +112,7 @@ class Presets extends PureComponent {
|
|||
function mapStateToProps(state) {
|
||||
return {
|
||||
presetName: selectors.getPresetName(state),
|
||||
presets: selectors.getPresets(state),
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -53,7 +53,10 @@ const {
|
|||
createMultiModalGetSymbolTableFn,
|
||||
} = require("devtools/client/performance-new/browser");
|
||||
|
||||
const { getDefaultRecordingPreferencesForOlderFirefox } = ChromeUtils.import(
|
||||
const {
|
||||
getDefaultRecordingPreferencesForOlderFirefox,
|
||||
presets,
|
||||
} = ChromeUtils.import(
|
||||
"resource://devtools/client/performance-new/popup/background.jsm.js"
|
||||
);
|
||||
|
||||
|
@ -100,6 +103,7 @@ async function gInit(perfFront, preferenceFront) {
|
|||
perfFront,
|
||||
receiveProfile,
|
||||
recordingPreferences,
|
||||
presets,
|
||||
supportedFeatures,
|
||||
pageContext: "devtools",
|
||||
|
||||
|
|
|
@ -25,9 +25,9 @@ const { AppConstants } = ChromeUtils.import(
|
|||
* @typedef {import("../@types/perf").PopupBackgroundFeatures} PopupBackgroundFeatures
|
||||
* @typedef {import("../@types/perf").SymbolTableAsTuple} SymbolTableAsTuple
|
||||
* @typedef {import("../@types/perf").PerformancePref} PerformancePref
|
||||
* @typedef {import("../@types/perf").PresetDefinitions} PresetDefinitions
|
||||
* @typedef {import("../@types/perf").ProfilerWebChannel} ProfilerWebChannel
|
||||
* @typedef {import("../@types/perf").MessageFromFrontend} MessageFromFrontend
|
||||
* @typedef {import("../@types/perf").Presets} Presets
|
||||
*/
|
||||
|
||||
/** @type {PerformancePref["Entries"]} */
|
||||
|
@ -115,6 +115,38 @@ const lazyProfilerMenuButton = requireLazy(() =>
|
|||
))
|
||||
);
|
||||
|
||||
/** @type {Presets} */
|
||||
const presets = {
|
||||
"web-developer": {
|
||||
label: "Web Developer",
|
||||
description:
|
||||
"Recommended preset for most web app debugging, with low overhead.",
|
||||
entries: 10000000,
|
||||
interval: 1,
|
||||
features: ["js"],
|
||||
threads: ["GeckoMain", "Compositor", "Renderer", "DOM Worker"],
|
||||
duration: 0,
|
||||
},
|
||||
"firefox-platform": {
|
||||
label: "Firefox Platform",
|
||||
description: "Recommended preset for internal Firefox platform debugging.",
|
||||
entries: 10000000,
|
||||
interval: 1,
|
||||
features: ["js", "leaf", "stackwalk"],
|
||||
threads: ["GeckoMain", "Compositor", "Renderer"],
|
||||
duration: 0,
|
||||
},
|
||||
"firefox-front-end": {
|
||||
label: "Firefox Front-End",
|
||||
description: "Recommended preset for internal Firefox front-end debugging.",
|
||||
entries: 10000000,
|
||||
interval: 1,
|
||||
features: ["js", "leaf", "stackwalk"],
|
||||
threads: ["GeckoMain", "Compositor", "Renderer", "DOM Worker"],
|
||||
duration: 0,
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* This Map caches the symbols from the shared libraries.
|
||||
* @type {Map<string, { path: string, debugPath: string }>}
|
||||
|
@ -310,8 +342,6 @@ function getRecordingPreferencesFromBrowser() {
|
|||
* @return {RecordingStateFromPreferences | null}
|
||||
*/
|
||||
function getRecordingPrefsFromPreset(presetName, objdirs) {
|
||||
const { presets } = lazyRecordingUtils();
|
||||
|
||||
if (presetName === "custom") {
|
||||
return null;
|
||||
}
|
||||
|
@ -400,6 +430,8 @@ let _defaultPrefsForOlderFirefox;
|
|||
* NOTE: We don't need that function anymore, because have recording default
|
||||
* values in the all.js file since Firefox 72. But we still keep this to support
|
||||
* older Firefox versions. See Bug 1603415.
|
||||
*
|
||||
* @return {RecordingStateFromPreferences}
|
||||
*/
|
||||
function getDefaultRecordingPreferencesForOlderFirefox() {
|
||||
if (!_defaultPrefsForOlderFirefox) {
|
||||
|
@ -492,6 +524,7 @@ function handleWebChannelMessage(channel, id, message, target) {
|
|||
/** @type {any} */ (this).module = { exports: {} };
|
||||
|
||||
module.exports = {
|
||||
presets,
|
||||
captureProfile,
|
||||
startProfiler,
|
||||
stopProfiler,
|
||||
|
|
|
@ -12,7 +12,6 @@ const {
|
|||
const {
|
||||
getEnvironmentVariable,
|
||||
} = require("devtools/client/performance-new/browser");
|
||||
const { presets } = require("devtools/shared/performance-new/recording-utils");
|
||||
|
||||
/**
|
||||
* @typedef {import("../@types/perf").Action} Action
|
||||
|
@ -21,6 +20,7 @@ const { presets } = require("devtools/shared/performance-new/recording-utils");
|
|||
* @typedef {import("../@types/perf").SymbolTableAsTuple} SymbolTableAsTuple
|
||||
* @typedef {import("../@types/perf").RecordingState} RecordingState
|
||||
* @typedef {import("../@types/perf").InitializeStoreValues} InitializeStoreValues
|
||||
* @typedef {import("../@types/perf").Presets} Presets
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@ -142,10 +142,11 @@ exports.changeThreads = threads =>
|
|||
|
||||
/**
|
||||
* Change the preset.
|
||||
* @param {Presets} presets
|
||||
* @param {string} presetName
|
||||
* @return {ThunkAction<void>}
|
||||
*/
|
||||
exports.changePreset = presetName =>
|
||||
exports.changePreset = (presets, presetName) =>
|
||||
_dispatchAndUpdatePreferences({
|
||||
type: "CHANGE_PRESET",
|
||||
presetName,
|
||||
|
|
|
@ -181,6 +181,7 @@ function initializedValues(state = null, action) {
|
|||
perfFront: action.perfFront,
|
||||
receiveProfile: action.receiveProfile,
|
||||
setRecordingPreferences: action.setRecordingPreferences,
|
||||
presets: action.presets,
|
||||
pageContext: action.pageContext,
|
||||
getSymbolTableGetter: action.getSymbolTableGetter,
|
||||
supportedFeatures: action.supportedFeatures,
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
// @ts-check
|
||||
"use strict";
|
||||
const { presets } = require("devtools/shared/performance-new/recording-utils");
|
||||
|
||||
/**
|
||||
* @typedef {import("../@types/perf").RecordingState} RecordingState
|
||||
|
@ -16,6 +15,7 @@ const { presets } = require("devtools/shared/performance-new/recording-utils");
|
|||
* @typedef {import("../@types/perf").RestartBrowserWithEnvironmentVariable} RestartBrowserWithEnvironmentVariable
|
||||
* @typedef {import("../@types/perf").GetEnvironmentVariable} GetEnvironmentVariable
|
||||
* @typedef {import("../@types/perf").PageContext} PageContext
|
||||
* @typedef {import("../@types/perf").Presets} Presets
|
||||
*/
|
||||
/**
|
||||
* @template S
|
||||
|
@ -50,6 +50,9 @@ const getThreadsString = state => getThreads(state).join(",");
|
|||
/** @type {Selector<string[]>} */
|
||||
const getObjdirs = state => state.objdirs;
|
||||
|
||||
/** @type {Selector<Presets>} */
|
||||
const getPresets = state => getInitializedValues(state).presets;
|
||||
|
||||
/** @type {Selector<string>} */
|
||||
const getPresetName = state => state.presetName;
|
||||
|
||||
|
@ -60,6 +63,7 @@ const getPresetName = state => state.presetName;
|
|||
* @type {Selector<RecordingStateFromPreferences>}
|
||||
*/
|
||||
const getRecordingSettings = state => {
|
||||
const presets = getPresets(state);
|
||||
const presetName = getPresetName(state);
|
||||
const preset = presets[presetName];
|
||||
if (preset) {
|
||||
|
@ -132,6 +136,7 @@ module.exports = {
|
|||
getThreads,
|
||||
getThreadsString,
|
||||
getObjdirs,
|
||||
getPresets,
|
||||
getPresetName,
|
||||
getRecordingSettings,
|
||||
getInitializedValues,
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
|
||||
/**
|
||||
* @typedef {import("../../client/performance-new/@types/perf").GetActiveBrowsingContextID} GetActiveBrowsingContextID
|
||||
* @typedef {import("../../client/performance-new/@types/perf").PresetDefinitions} PresetDefinitions
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@ -65,39 +64,6 @@ function getActiveBrowsingContextID() {
|
|||
return 0;
|
||||
}
|
||||
|
||||
/** @type {PresetDefinitions} */
|
||||
const presets = {
|
||||
"web-developer": {
|
||||
label: "Web Developer",
|
||||
description:
|
||||
"Recommended preset for most web app debuggging, with low overhead.",
|
||||
entries: 10000000,
|
||||
interval: 1,
|
||||
features: ["js"],
|
||||
threads: ["GeckoMain", "Compositor", "Renderer", "DOM Worker"],
|
||||
duration: 0,
|
||||
},
|
||||
"firefox-platform": {
|
||||
label: "Firefox Platform",
|
||||
description: "Recommended preset for internal Firefox platform debugging.",
|
||||
entries: 10000000,
|
||||
interval: 1,
|
||||
features: ["js", "leaf", "stackwalk"],
|
||||
threads: ["GeckoMain", "Compositor", "Renderer"],
|
||||
duration: 0,
|
||||
},
|
||||
"firefox-front-end": {
|
||||
label: "Firefox Front-End",
|
||||
description: "Recommended preset for internal Firefox front-end debugging.",
|
||||
entries: 10000000,
|
||||
interval: 1,
|
||||
features: ["js", "leaf", "stackwalk"],
|
||||
threads: ["GeckoMain", "Compositor", "Renderer", "DOM Worker"],
|
||||
duration: 0,
|
||||
},
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
getActiveBrowsingContextID,
|
||||
presets,
|
||||
};
|
||||
|
|
Загрузка…
Ссылка в новой задаче