tor-browser

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

GeckoViewTelemetry.sys.mjs (1055B)


      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 export var InitializationTracker = {
      6  initialized: false,
      7  onInitialized(profilerTime) {
      8    if (!this.initialized) {
      9      this.initialized = true;
     10      ChromeUtils.addProfilerMarker(
     11        "GeckoView Initialization END",
     12        profilerTime
     13      );
     14    }
     15  },
     16 };
     17 
     18 // A helper for timing_distribution metrics.
     19 export class GleanStopwatch {
     20  constructor(aTimingDistribution) {
     21    this._metric = aTimingDistribution;
     22  }
     23 
     24  isRunning() {
     25    return !!this._timerId;
     26  }
     27 
     28  start() {
     29    if (this.isRunning()) {
     30      this.cancel();
     31    }
     32    this._timerId = this._metric.start();
     33  }
     34 
     35  finish() {
     36    if (this.isRunning()) {
     37      this._metric.stopAndAccumulate(this._timerId);
     38      this._timerId = null;
     39    }
     40  }
     41 
     42  cancel() {
     43    if (this.isRunning()) {
     44      this._metric.cancel(this._timerId);
     45      this._timerId = null;
     46    }
     47  }
     48 }