diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 14:29:10 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 14:29:10 +0000 |
commit | 2aa4a82499d4becd2284cdb482213d541b8804dd (patch) | |
tree | b80bf8bf13c3766139fbacc530efd0dd9d54394c /toolkit/components/telemetry/app/TelemetryController.jsm | |
parent | Initial commit. (diff) | |
download | firefox-2aa4a82499d4becd2284cdb482213d541b8804dd.tar.xz firefox-2aa4a82499d4becd2284cdb482213d541b8804dd.zip |
Adding upstream version 86.0.1.upstream/86.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | toolkit/components/telemetry/app/TelemetryController.jsm | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/toolkit/components/telemetry/app/TelemetryController.jsm b/toolkit/components/telemetry/app/TelemetryController.jsm new file mode 100644 index 0000000000..7d0dcd3b76 --- /dev/null +++ b/toolkit/components/telemetry/app/TelemetryController.jsm @@ -0,0 +1,45 @@ +/* -*- js-indent-level: 2; indent-tabs-mode: nil -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +"use strict"; + +/** + * This module chooses the correct telemetry controller module to load + * based on the process: + * + * - TelemetryControllerParent is loaded only in the parent process, and + * contains code specific to the parent. + * - TelemetryControllerContent is loaded only in content processes, and + * contains code specific to them. + * + * Both the parent and the content modules load TelemetryControllerBase, + * which contains code which is common to all processes. + * + * This division is important for content process memory usage and + * startup time. The parent-specific code occupies tens of KB of memory + * which, multiplied by the number of content processes we have, adds up + * fast. + */ + +var EXPORTED_SYMBOLS = ["TelemetryController"]; + +// We can't use Services.appinfo here because tests stub out the appinfo +// service, and if we touch Services.appinfo now, the built-in version +// will be cached in place of the stub. +const isParentProcess = + // eslint-disable-next-line mozilla/use-services + Cc["@mozilla.org/xre/app-info;1"].getService(Ci.nsIXULRuntime).processType === + Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT; + +var TelemetryController; +if (isParentProcess) { + ({ TelemetryController } = ChromeUtils.import( + "resource://gre/modules/TelemetryControllerParent.jsm" + )); +} else { + ({ TelemetryController } = ChromeUtils.import( + "resource://gre/modules/TelemetryControllerContent.jsm" + )); +} |