tor-browser

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

memory.js (3128B)


      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 "use strict";
      5 
      6 const {
      7  Arg,
      8  RetVal,
      9  types,
     10  generateActorSpec,
     11 } = require("resource://devtools/shared/protocol.js");
     12 
     13 types.addDictType("AllocationsRecordingOptions", {
     14  // The probability we sample any given allocation when recording
     15  // allocations. Must be between 0.0 and 1.0. Defaults to 1.0, or sampling
     16  // every allocation.
     17  probability: "number",
     18 
     19  // The maximum number of of allocation events to keep in the allocations
     20  // log. If new allocations arrive, when we are already at capacity, the oldest
     21  // allocation event is lost. This number must fit in a 32 bit signed integer.
     22  maxLogLength: "number",
     23 });
     24 
     25 const memorySpec = generateActorSpec({
     26  typeName: "memory",
     27 
     28  /**
     29   * The set of unsolicited events the MemoryActor emits that will be sent over
     30   * the RDP (by protocol.js).
     31   */
     32  events: {
     33    // Same format as the data passed to the
     34    // `Debugger.Memory.prototype.onGarbageCollection` hook. See
     35    // `js/src/doc/Debugger/Debugger.Memory.md` for documentation.
     36    "garbage-collection": {
     37      type: "garbage-collection",
     38      data: Arg(0, "json"),
     39    },
     40 
     41    // Same data as the data from `getAllocations` -- only fired if
     42    // `autoDrain` set during `startRecordingAllocations`.
     43    allocations: {
     44      type: "allocations",
     45      data: Arg(0, "json"),
     46    },
     47  },
     48 
     49  methods: {
     50    attach: {
     51      request: {},
     52      response: {
     53        type: RetVal("string"),
     54      },
     55    },
     56    detach: {
     57      request: {},
     58      response: {
     59        type: RetVal("string"),
     60      },
     61    },
     62    getState: {
     63      response: {
     64        state: RetVal(0, "string"),
     65      },
     66    },
     67    takeCensus: {
     68      request: {},
     69      response: RetVal("json"),
     70    },
     71    startRecordingAllocations: {
     72      request: {
     73        options: Arg(0, "nullable:AllocationsRecordingOptions"),
     74      },
     75      response: {
     76        // Accept `nullable` in the case of server Gecko <= 37, handled on the front
     77        value: RetVal(0, "nullable:number"),
     78      },
     79    },
     80    stopRecordingAllocations: {
     81      request: {},
     82      response: {
     83        // Accept `nullable` in the case of server Gecko <= 37, handled on the front
     84        value: RetVal(0, "nullable:number"),
     85      },
     86    },
     87    getAllocationsSettings: {
     88      request: {},
     89      response: {
     90        options: RetVal(0, "json"),
     91      },
     92    },
     93    getAllocations: {
     94      request: {},
     95      response: RetVal("json"),
     96    },
     97    forceGarbageCollection: {
     98      request: {},
     99      response: {},
    100    },
    101    forceCycleCollection: {
    102      request: {},
    103      response: {},
    104    },
    105    measure: {
    106      request: {},
    107      response: RetVal("json"),
    108    },
    109    residentUnique: {
    110      request: {},
    111      response: { value: RetVal("number") },
    112    },
    113    saveHeapSnapshot: {
    114      request: {
    115        boundaries: Arg(0, "nullable:json"),
    116      },
    117      response: {
    118        snapshotId: RetVal("string"),
    119      },
    120    },
    121  },
    122 });
    123 
    124 exports.memorySpec = memorySpec;