census-display.js (1188B)
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 { assert } = require("resource://devtools/shared/DevToolsUtils.js"); 7 const { actions } = require("resource://devtools/client/memory/constants.js"); 8 const { 9 refresh, 10 } = require("resource://devtools/client/memory/actions/refresh.js"); 11 12 exports.setCensusDisplayAndRefresh = function (heapWorker, display) { 13 return async function ({ dispatch }) { 14 dispatch(setCensusDisplay(display)); 15 await dispatch(refresh(heapWorker)); 16 }; 17 }; 18 19 /** 20 * Clears out all cached census data in the snapshots and sets new display data 21 * for censuses. 22 * 23 * @param {censusDisplayModel} display 24 */ 25 const setCensusDisplay = (exports.setCensusDisplay = function (display) { 26 assert( 27 typeof display === "object" && 28 display && 29 display.breakdown && 30 display.breakdown.by, 31 "Breakdowns must be an object with a `by` property, attempted to set: " + 32 JSON.stringify(display) 33 ); 34 35 return { 36 type: actions.SET_CENSUS_DISPLAY, 37 display, 38 }; 39 });