tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

tree-map-display.js (1258B)


      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 * Sets the tree map display as the current display and refreshes the tree map
     13 * census.
     14 */
     15 exports.setTreeMapAndRefresh = function (heapWorker, display) {
     16  return async function ({ dispatch }) {
     17    dispatch(setTreeMap(display));
     18    await dispatch(refresh(heapWorker));
     19  };
     20 };
     21 
     22 /**
     23 * Clears out all cached census data in the snapshots and sets new display data
     24 * for tree maps.
     25 *
     26 * @param {treeMapModel} display
     27 */
     28 const setTreeMap = (exports.setTreeMap = function (display) {
     29  assert(
     30    typeof display === "object" &&
     31      display &&
     32      display.breakdown &&
     33      display.breakdown.by,
     34    "Breakdowns must be an object with a `by` property, attempted to set: " +
     35      JSON.stringify(display)
     36  );
     37 
     38  return {
     39    type: actions.SET_TREE_MAP_DISPLAY,
     40    display,
     41  };
     42 });