tor-browser

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

throttling.js (783B)


      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
      3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      4 
      5 "use strict";
      6 
      7 const {
      8  CHANGE_NETWORK_THROTTLING,
      9 } = require("resource://devtools/client/shared/components/throttling/actions.js");
     10 
     11 /**
     12 * Network throttling middleware is responsible for
     13 * updating/syncing currently connected backend
     14 * according to user actions.
     15 */
     16 function throttlingMiddleware(connector) {
     17  return () => next => action => {
     18    const res = next(action);
     19    if (action.type === CHANGE_NETWORK_THROTTLING) {
     20      connector.updateNetworkThrottling(action.enabled, action.profile);
     21    }
     22    return res;
     23  };
     24 }
     25 
     26 module.exports = throttlingMiddleware;