jstracer-trace.js (1185B)
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 class JSTraceWatcher { 8 /** 9 * Start watching for traces for a given target actor. 10 * 11 * @param TargetActor targetActor 12 * The target actor from which we should observe 13 * @param Object options 14 * Dictionary object with following attributes: 15 * - onAvailable: mandatory function 16 * This will be called for each resource. 17 */ 18 async watch(targetActor, { onAvailable }) { 19 this.#onAvailable = onAvailable; 20 } 21 22 #onAvailable; 23 24 /** 25 * Stop watching for traces 26 */ 27 destroy() { 28 // The traces are being emitted by the TracerActor via `emitTraces` method, 29 // we start and stop recording and emitting tracer from this actor. 30 // Watching for JSTRACER_TRACE only allows receiving these trace events. 31 } 32 33 /** 34 * Emit a JSTRACER_TRACE resource. 35 * 36 * This is being called by the Tracer Actor. 37 */ 38 emitTraces(traces) { 39 this.#onAvailable(traces); 40 } 41 } 42 43 module.exports = JSTraceWatcher;