allocations.js (1161B)
1 /* This Source Code Form is subject to the terms of the Mozilla Public 2 * License, v. 2.0. If a copy of the MPL was not distributed with this file, 3 * You can obtain one at http://mozilla.org/MPL/2.0/. */ 4 "use strict"; 5 6 const { 7 actions, 8 ALLOCATION_RECORDING_OPTIONS, 9 } = require("resource://devtools/client/memory/constants.js"); 10 11 exports.toggleRecordingAllocationStacks = function (commands) { 12 return async function ({ dispatch, getState }) { 13 dispatch({ type: actions.TOGGLE_RECORD_ALLOCATION_STACKS_START }); 14 15 if (commands.targetCommand.hasTargetWatcherSupport()) { 16 await commands.targetConfigurationCommand.updateConfiguration({ 17 recordAllocations: getState().recordingAllocationStacks 18 ? null 19 : ALLOCATION_RECORDING_OPTIONS, 20 }); 21 } else { 22 const front = await commands.targetCommand.targetFront.getFront("memory"); 23 if (getState().recordingAllocationStacks) { 24 await front.stopRecordingAllocations(); 25 } else { 26 await front.startRecordingAllocations(ALLOCATION_RECORDING_OPTIONS); 27 } 28 } 29 30 dispatch({ type: actions.TOGGLE_RECORD_ALLOCATION_STACKS_END }); 31 }; 32 };