tor-browser

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

label-display.js (1308B)


      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 /**
     13 * Change the display we use for labeling individual nodes and refresh the
     14 * current data.
     15 */
     16 exports.setLabelDisplayAndRefresh = function (heapWorker, display) {
     17  return async function ({ dispatch }) {
     18    // Clears out all stored census data and sets the display.
     19    dispatch(setLabelDisplay(display));
     20    await dispatch(refresh(heapWorker));
     21  };
     22 };
     23 
     24 /**
     25 * Change the display we use for labeling individual nodes.
     26 *
     27 * @param {labelDisplayModel} display
     28 */
     29 const setLabelDisplay = (exports.setLabelDisplay = function (display) {
     30  assert(
     31    typeof display === "object" &&
     32      display &&
     33      display.breakdown &&
     34      display.breakdown.by,
     35    "Breakdowns must be an object with a `by` property, attempted to set: " +
     36      JSON.stringify(display)
     37  );
     38 
     39  return {
     40    type: actions.SET_LABEL_DISPLAY,
     41    display,
     42  };
     43 });