2
2
* License, v. 2.0. If a copy of the MPL was not distributed with this
3
3
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4
4
// @ts -check
5
- "use strict" ;
6
5
7
6
/**
8
7
* This file contains all of the background logic for controlling the state and
@@ -122,7 +121,7 @@ const lazy = createLazyLoaders({
122
121
// https://github.com/mozilla-mobile/firefox-android/blob/1d177e7e78d027e8ab32cedf0fc68316787d7454/fenix/app/src/main/java/org/mozilla/fenix/perf/ProfilerUtils.kt
123
122
124
123
/** @type {Presets } */
125
- const presets = {
124
+ export const presets = {
126
125
"web-developer" : {
127
126
entries : 128 * 1024 * 1024 ,
128
127
interval : 1 ,
@@ -311,7 +310,7 @@ const presets = {
311
310
* @param {PageContext } pageContext
312
311
* @return {ProfilerViewMode | undefined }
313
312
*/
314
- function getProfilerViewModeForCurrentPreset ( pageContext ) {
313
+ export function getProfilerViewModeForCurrentPreset ( pageContext ) {
315
314
const prefPostfix = getPrefPostfix ( pageContext ) ;
316
315
const presetName = Services . prefs . getCharPref ( PRESET_PREF + prefPostfix ) ;
317
316
@@ -334,7 +333,7 @@ function getProfilerViewModeForCurrentPreset(pageContext) {
334
333
* @param {PageContext } pageContext
335
334
* @return {Promise<void> }
336
335
*/
337
- async function captureProfile ( pageContext ) {
336
+ export async function captureProfile ( pageContext ) {
338
337
if ( ! Services . profiler . IsActive ( ) ) {
339
338
// The profiler is not active, ignore.
340
339
return ;
@@ -397,7 +396,7 @@ async function captureProfile(pageContext) {
397
396
* popup.
398
397
* @param {PageContext } pageContext
399
398
*/
400
- function startProfiler ( pageContext ) {
399
+ export function startProfiler ( pageContext ) {
401
400
const { entries, interval, features, threads, duration } =
402
401
getRecordingSettings ( pageContext , Services . profiler . GetFeatures ( ) ) ;
403
402
@@ -420,7 +419,7 @@ function startProfiler(pageContext) {
420
419
* using the shortcut keys to capture a profile.
421
420
* @type {() => void }
422
421
*/
423
- function stopProfiler ( ) {
422
+ export function stopProfiler ( ) {
424
423
Services . profiler . StopProfiler ( ) ;
425
424
}
426
425
@@ -430,7 +429,7 @@ function stopProfiler() {
430
429
* @param {PageContext } pageContext
431
430
* @return {void }
432
431
*/
433
- function toggleProfiler ( pageContext ) {
432
+ export function toggleProfiler ( pageContext ) {
434
433
if ( Services . profiler . IsPaused ( ) ) {
435
434
// The profiler is currently paused, which means that the user is already
436
435
// attempting to capture a profile. Ignore this request.
@@ -446,7 +445,7 @@ function toggleProfiler(pageContext) {
446
445
/**
447
446
* @param {PageContext } pageContext
448
447
*/
449
- function restartProfiler ( pageContext ) {
448
+ export function restartProfiler ( pageContext ) {
450
449
stopProfiler ( ) ;
451
450
startProfiler ( pageContext ) ;
452
451
}
@@ -528,7 +527,7 @@ function getObjdirPrefValue() {
528
527
* @param {string[] } supportedFeatures
529
528
* @returns {RecordingSettings }
530
529
*/
531
- function getRecordingSettings ( pageContext , supportedFeatures ) {
530
+ export function getRecordingSettings ( pageContext , supportedFeatures ) {
532
531
const objdirs = getObjdirPrefValue ( ) ;
533
532
const prefPostfix = getPrefPostfix ( pageContext ) ;
534
533
const presetName = Services . prefs . getCharPref ( PRESET_PREF + prefPostfix ) ;
@@ -616,7 +615,7 @@ function getRecordingSettingsFromPrefs(
616
615
* @param {PageContext } pageContext
617
616
* @param {RecordingSettings } prefs
618
617
*/
619
- function setRecordingSettings ( pageContext , prefs ) {
618
+ export function setRecordingSettings ( pageContext , prefs ) {
620
619
const prefPostfix = getPrefPostfix ( pageContext ) ;
621
620
Services . prefs . setCharPref ( PRESET_PREF + prefPostfix , prefs . presetName ) ;
622
621
Services . prefs . setIntPref ( ENTRIES_PREF + prefPostfix , prefs . entries ) ;
@@ -637,13 +636,13 @@ function setRecordingSettings(pageContext, prefs) {
637
636
setObjdirPrefValue ( prefs . objdirs ) ;
638
637
}
639
638
640
- const platform = AppConstants . platform ;
639
+ export const platform = AppConstants . platform ;
641
640
642
641
/**
643
642
* Revert the recording prefs for both local and remote profiling.
644
643
* @return {void }
645
644
*/
646
- function revertRecordingSettings ( ) {
645
+ export function revertRecordingSettings ( ) {
647
646
for ( const prefPostfix of [ "" , ".remote" ] ) {
648
647
Services . prefs . clearUserPref ( PRESET_PREF + prefPostfix ) ;
649
648
Services . prefs . clearUserPref ( ENTRIES_PREF + prefPostfix ) ;
@@ -664,7 +663,7 @@ function revertRecordingSettings() {
664
663
* @param {string[] } supportedFeatures
665
664
* @return {void }
666
665
*/
667
- function changePreset ( pageContext , presetName , supportedFeatures ) {
666
+ export function changePreset ( pageContext , presetName , supportedFeatures ) {
668
667
const prefPostfix = getPrefPostfix ( pageContext ) ;
669
668
const objdirs = getObjdirPrefValue ( ) ;
670
669
let recordingSettings = getRecordingSettingsFromPreset (
@@ -689,7 +688,7 @@ function changePreset(pageContext, presetName, supportedFeatures) {
689
688
* @param {PrefObserver } observer
690
689
* @return {void }
691
690
*/
692
- function addPrefObserver ( observer ) {
691
+ export function addPrefObserver ( observer ) {
693
692
Services . prefs . addObserver ( PREF_PREFIX , observer ) ;
694
693
}
695
694
@@ -698,7 +697,7 @@ function addPrefObserver(observer) {
698
697
* @param {PrefObserver } observer
699
698
* @return {void }
700
699
*/
701
- function removePrefObserver ( observer ) {
700
+ export function removePrefObserver ( observer ) {
702
701
Services . prefs . removeObserver ( PREF_PREFIX , observer ) ;
703
702
}
704
703
@@ -867,7 +866,7 @@ function getSymbolicationServiceForBrowser(browser) {
867
866
* @param {any } message
868
867
* @param {MockedExports.WebChannelTarget } target
869
868
*/
870
- async function handleWebChannelMessage ( channel , id , message , target ) {
869
+ export async function handleWebChannelMessage ( channel , id , message , target ) {
871
870
if ( typeof message !== "object" || typeof message . type !== "string" ) {
872
871
console . error (
873
872
"An malformed message was received by the profiler's WebChannel handler." ,
@@ -918,7 +917,7 @@ async function handleWebChannelMessage(channel, id, message, target) {
918
917
* method should obtain a symbol table for the requested binary and resolve the
919
918
* returned promise with it.
920
919
*/
921
- function registerProfileCaptureForBrowser (
920
+ export function registerProfileCaptureForBrowser (
922
921
browser ,
923
922
profileCaptureResult ,
924
923
symbolicationService
@@ -928,30 +927,3 @@ function registerProfileCaptureForBrowser(
928
927
symbolicationService,
929
928
} ) ;
930
929
}
931
-
932
- // Provide a fake module.exports for the JSM to be properly read by TypeScript.
933
- /** @type {any } */
934
- var module = { exports : { } } ;
935
-
936
- module . exports = {
937
- presets,
938
- captureProfile,
939
- startProfiler,
940
- stopProfiler,
941
- restartProfiler,
942
- toggleProfiler,
943
- platform,
944
- getRecordingSettings,
945
- setRecordingSettings,
946
- revertRecordingSettings,
947
- changePreset,
948
- handleWebChannelMessage,
949
- registerProfileCaptureForBrowser,
950
- addPrefObserver,
951
- removePrefObserver,
952
- getProfilerViewModeForCurrentPreset,
953
- } ;
954
-
955
- // Object.keys() confuses the linting which expects a static array expression.
956
- // eslint-disable-next-line
957
- var EXPORTED_SYMBOLS = Object . keys ( module . exports ) ;
0 commit comments