Skip to content

Commit

Permalink
Bug 1733485 - Lazy load modules in GMPUtils.jsm, UpdateUtils.jsm, GMP…
Browse files Browse the repository at this point in the history
…Provider.jsm to avoid loading earlier than necessary. r=bytesized

Differential Revision: https://phabricator.services.mozilla.com/D127171
  • Loading branch information
Standard8 committed Oct 1, 2021
1 parent 7ee3993 commit aec46f6
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 42 deletions.
14 changes: 11 additions & 3 deletions toolkit/modules/GMPUtils.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,19 @@ var EXPORTED_SYMBOLS = [
"WIDEVINE_ID",
];

const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
const { AppConstants } = ChromeUtils.import(
ChromeUtils.defineModuleGetter(
this,
"Services",
"resource://gre/modules/Services.jsm"
);
ChromeUtils.defineModuleGetter(
this,
"AppConstants",
"resource://gre/modules/AppConstants.jsm"
);
const { UpdateUtils } = ChromeUtils.import(
ChromeUtils.defineModuleGetter(
this,
"UpdateUtils",
"resource://gre/modules/UpdateUtils.jsm"
);

Expand Down
32 changes: 12 additions & 20 deletions toolkit/modules/UpdateUtils.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,22 @@

var EXPORTED_SYMBOLS = ["UpdateUtils"];

const { AppConstants } = ChromeUtils.import(
"resource://gre/modules/AppConstants.jsm"
);
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
const { XPCOMUtils } = ChromeUtils.import(
"resource://gre/modules/XPCOMUtils.jsm"
);
const { FileUtils } = ChromeUtils.import(
"resource://gre/modules/FileUtils.jsm"
);
const { OS } = ChromeUtils.import("resource://gre/modules/osfile.jsm");
const { ctypes } = ChromeUtils.import("resource://gre/modules/ctypes.jsm");
ChromeUtils.defineModuleGetter(
this,
"WindowsVersionInfo",
"resource://gre/modules/components-utils/WindowsVersionInfo.jsm"
);
XPCOMUtils.defineLazyGlobalGetters(this, ["fetch"]); /* globals fetch */

ChromeUtils.defineModuleGetter(
this,
"WindowsRegistry",
"resource://gre/modules/WindowsRegistry.jsm"
);
XPCOMUtils.defineLazyModuleGetters(this, {
AppConstants: "resource://gre/modules/AppConstants.jsm",
ctypes: "resource://gre/modules/ctypes.jsm",
FileUtils: "resource://gre/modules/FileUtils.jsm",
OS: "resource://gre/modules/osfile.jsm",
Services: "resource://gre/modules/Services.jsm",
WindowsRegistry: "resource://gre/modules/WindowsRegistry.jsm",
WindowsVersionInfo:
"resource://gre/modules/components-utils/WindowsVersionInfo.jsm",
});

XPCOMUtils.defineLazyGlobalGetters(this, ["fetch"]);

const PER_INSTALLATION_PREFS_PLATFORMS = ["win"];

Expand Down
30 changes: 11 additions & 19 deletions toolkit/mozapps/extensions/internal/GMPProvider.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -9,30 +9,22 @@ var EXPORTED_SYMBOLS = [];
const { XPCOMUtils } = ChromeUtils.import(
"resource://gre/modules/XPCOMUtils.jsm"
);
const { AddonManager, AddonManagerPrivate } = ChromeUtils.import(
"resource://gre/modules/AddonManager.jsm"
);
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
const { Log } = ChromeUtils.import("resource://gre/modules/Log.jsm");

XPCOMUtils.defineLazyModuleGetters(this, {
AddonManager: "resource://gre/modules/AddonManager.jsm",
AddonManagerPrivate: "resource://gre/modules/AddonManager.jsm",
AppConstants: "resource://gre/modules/AppConstants.jsm",
Log: "resource://gre/modules/Log.jsm",
GMPInstallManager: "resource://gre/modules/GMPInstallManager.jsm",
Services: "resource://gre/modules/Services.jsm",
setTimeout: "resource://gre/modules/Timer.jsm",
});

// These symbols are, unfortunately, accessed via the module global from
// tests, and therefore cannot be lexical definitions.
var { GMPPrefs, GMPUtils, OPEN_H264_ID, WIDEVINE_ID } = ChromeUtils.import(
"resource://gre/modules/GMPUtils.jsm"
);
const { AppConstants } = ChromeUtils.import(
"resource://gre/modules/AppConstants.jsm"
);

ChromeUtils.defineModuleGetter(
this,
"GMPInstallManager",
"resource://gre/modules/GMPInstallManager.jsm"
);
ChromeUtils.defineModuleGetter(
this,
"setTimeout",
"resource://gre/modules/Timer.jsm"
);

const URI_EXTENSION_STRINGS =
"chrome://mozapps/locale/extensions/extensions.properties";
Expand Down

0 comments on commit aec46f6

Please sign in to comment.