From 75f5c3800690e0dcc9681fb9c0443bd4b0eff8a0 Mon Sep 17 00:00:00 2001 From: Julien Wajsberg Date: Tue, 22 Oct 2019 08:13:46 +0000 Subject: [PATCH] Bug 1589122 - Rename getDefaultRecordingSettings to getDefaultRecordingPreferences r=canaltinova This also renames various variables from "settings" to "preferences" to make it clearer that the values are about actual preferences stored in the user profile. Differential Revision: https://phabricator.services.mozilla.com/D49641 --HG-- extra : moz-landing-system : lando --- devtools/client/performance-new/browser.js | 14 +++--- .../client/performance-new/initializer.js | 4 +- .../performance-new/popup/background.jsm.js | 43 ++++++++----------- .../performance-new/test/chrome/head.js | 4 +- .../test/xpcshell/test_popup_initial_state.js | 6 +-- 5 files changed, 33 insertions(+), 38 deletions(-) diff --git a/devtools/client/performance-new/browser.js b/devtools/client/performance-new/browser.js index ea6a9c6e1514..53c12f1064b2 100644 --- a/devtools/client/performance-new/browser.js +++ b/devtools/client/performance-new/browser.js @@ -227,34 +227,34 @@ async function _getIntPref(preferenceFront, prefName, defaultValue) { * different features or configurations. * * @param {PreferenceFront} preferenceFront - * @param {RecordingStateFromPreferences} defaultSettings + * @param {RecordingStateFromPreferences} defaultPrefs */ async function getRecordingPreferencesFromDebuggee( preferenceFront, - defaultSettings + defaultPrefs ) { const [entries, interval, features, threads, objdirs] = await Promise.all([ _getIntPref( preferenceFront, `devtools.performance.recording.entries`, - defaultSettings.entries + defaultPrefs.entries ), _getIntPref( preferenceFront, `devtools.performance.recording.interval`, - defaultSettings.interval + defaultPrefs.interval ), _getArrayOfStringsPref( preferenceFront, `devtools.performance.recording.features`, - defaultSettings.features + defaultPrefs.features ), _getArrayOfStringsPref( preferenceFront, `devtools.performance.recording.threads`, - defaultSettings.threads + defaultPrefs.threads ), - _getArrayOfStringsHostPref(OBJDIRS_PREF, defaultSettings.objdirs), + _getArrayOfStringsHostPref(OBJDIRS_PREF, defaultPrefs.objdirs), ]); // The pref stores the value in usec. diff --git a/devtools/client/performance-new/initializer.js b/devtools/client/performance-new/initializer.js index 3dd213ded248..caf268df419f 100644 --- a/devtools/client/performance-new/initializer.js +++ b/devtools/client/performance-new/initializer.js @@ -32,7 +32,7 @@ const { createMultiModalGetSymbolTableFn, } = require("devtools/client/performance-new/browser"); -const { getDefaultRecordingSettings } = ChromeUtils.import( +const { getDefaultRecordingPreferences } = ChromeUtils.import( "resource://devtools/client/performance-new/popup/background.jsm.js" ); @@ -63,7 +63,7 @@ async function gInit(perfFront, preferenceFront) { // might want to tweak the settings. recordingSettingsFromPreferences: await getRecordingPreferencesFromDebuggee( preferenceFront, - getDefaultRecordingSettings() + getDefaultRecordingPreferences() ), // Go ahead and hide the implementation details for the component on how the diff --git a/devtools/client/performance-new/popup/background.jsm.js b/devtools/client/performance-new/popup/background.jsm.js index 4aec643bb349..2ec80909e2ac 100644 --- a/devtools/client/performance-new/popup/background.jsm.js +++ b/devtools/client/performance-new/popup/background.jsm.js @@ -249,18 +249,19 @@ function _getArrayOfStringsHostPref(prefName, defaultValue) { } /** - * A simple cache for the recording settings. + * A simple cache for the default recording preferences. * @type {RecordingStateFromPreferences} */ -let _defaultSettings; +let _defaultPrefs; /** - * This function contains the canonical defaults for both the popup and panel's - * recording settings. + * This function contains the canonical defaults for the data store in the + * preferences in the user profile. They represent the default values for both + * the popup and panel's recording settings. */ -function getDefaultRecordingSettings() { - if (!_defaultSettings) { - _defaultSettings = { +function getDefaultRecordingPreferences() { + if (!_defaultPrefs) { + _defaultPrefs = { entries: 10000000, // ~80mb, // Do not expire markers, let them roll off naturally from the circular buffer. duration: 0, @@ -272,39 +273,33 @@ function getDefaultRecordingSettings() { if (AppConstants.platform === "android") { // Java profiling is only meaningful on android. - _defaultSettings.features.push("java"); + _defaultPrefs.features.push("java"); } } - return _defaultSettings; + return _defaultPrefs; } /** * @returns {RecordingStateFromPreferences} */ function getRecordingPreferencesFromBrowser() { - const defaultSettings = getDefaultRecordingSettings(); + const defaultPrefs = getDefaultRecordingPreferences(); - const entries = Services.prefs.getIntPref( - ENTRIES_PREF, - defaultSettings.entries - ); + const entries = Services.prefs.getIntPref(ENTRIES_PREF, defaultPrefs.entries); const interval = Services.prefs.getIntPref( INTERVAL_PREF, - defaultSettings.interval + defaultPrefs.interval ); - const features = _getArrayOfStringsPref( - FEATURES_PREF, - defaultSettings.features - ); - const threads = _getArrayOfStringsPref(THREADS_PREF, defaultSettings.threads); + const features = _getArrayOfStringsPref(FEATURES_PREF, defaultPrefs.features); + const threads = _getArrayOfStringsPref(THREADS_PREF, defaultPrefs.threads); const objdirs = _getArrayOfStringsHostPref( OBJDIRS_PREF, - defaultSettings.objdirs + defaultPrefs.objdirs ); const duration = Services.prefs.getIntPref( DURATION_PREF, - defaultSettings.duration + defaultPrefs.duration ); const supportedFeatures = new Set(Services.profiler.GetFeatures()); @@ -339,7 +334,7 @@ const platform = AppConstants.platform; * @type {() => void} */ function revertRecordingPreferences() { - setRecordingPreferencesOnBrowser(getDefaultRecordingSettings()); + setRecordingPreferencesOnBrowser(getDefaultRecordingPreferences()); } var EXPORTED_SYMBOLS = [ @@ -350,7 +345,7 @@ var EXPORTED_SYMBOLS = [ "toggleProfiler", "platform", "getSymbolsFromThisBrowser", - "getDefaultRecordingSettings", + "getDefaultRecordingPreferences", "getRecordingPreferencesFromBrowser", "setRecordingPreferencesOnBrowser", "revertRecordingPreferences", diff --git a/devtools/client/performance-new/test/chrome/head.js b/devtools/client/performance-new/test/chrome/head.js index 37952f5f0576..f8c17aca9509 100644 --- a/devtools/client/performance-new/test/chrome/head.js +++ b/devtools/client/performance-new/test/chrome/head.js @@ -187,7 +187,7 @@ function createPerfComponent() { const reducers = require("devtools/client/performance-new/store/reducers"); const actions = require("devtools/client/performance-new/store/actions"); const selectors = require("devtools/client/performance-new/store/selectors"); - const { getDefaultRecordingSettings } = ChromeUtils.import( + const { getDefaultRecordingPreferences } = ChromeUtils.import( "resource://devtools/client/performance-new/popup/background.jsm.js" ); @@ -212,7 +212,7 @@ function createPerfComponent() { actions.initializeStore({ perfFront: perfFrontMock, receiveProfile: receiveProfileMock, - recordingSettingsFromPreferences: getDefaultRecordingSettings(), + recordingSettingsFromPreferences: getDefaultRecordingPreferences(), setRecordingPreferences: recordingPreferencesMock, getSymbolTableGetter: () => noop, }) diff --git a/devtools/client/performance-new/test/xpcshell/test_popup_initial_state.js b/devtools/client/performance-new/test/xpcshell/test_popup_initial_state.js index f8d0684ebe29..598b7761e30a 100644 --- a/devtools/client/performance-new/test/xpcshell/test_popup_initial_state.js +++ b/devtools/client/performance-new/test/xpcshell/test_popup_initial_state.js @@ -18,17 +18,17 @@ add_task(function test() { const { getRecordingPreferencesFromBrowser, revertRecordingPreferences, - getDefaultRecordingSettings, + getDefaultRecordingPreferences, } = setupBackgroundJsm(); Assert.equal( getRecordingPreferencesFromBrowser().buffersize, - getDefaultRecordingSettings().buffersize, + getDefaultRecordingPreferences().buffersize, "The initial state has the default buffersize." ); Assert.equal( getRecordingPreferencesFromBrowser().features.includes("stackwalk"), - getDefaultRecordingSettings().features.includes("stackwalk"), + getDefaultRecordingPreferences().features.includes("stackwalk"), "The stackwalk feature is initialized to the default." ); revertRecordingPreferences();