Bug 1522930, delay GMP initialization until after first point to improve perceived performance. r=mconley

Differential Revision: https://phabricator.services.mozilla.com/D67165

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Emma Malysz 2020-03-18 22:33:01 +00:00
Родитель edf4e23c7d
Коммит 0faecc91b5
2 изменённых файлов: 28 добавлений и 10 удалений

Просмотреть файл

@ -48,6 +48,8 @@ const NS_GRE_DIR = "GreD";
const CLEARKEY_PLUGIN_ID = "gmp-clearkey";
const CLEARKEY_VERSION = "0.1";
const FIRST_CONTENT_PROCESS_TOPIC = "ipc:first-content-process-created";
const GMP_LICENSE_INFO = "gmp_license_info";
const GMP_PRIVACY_INFO = "gmp_privacy_info";
const GMP_LEARN_MORE = "learn_more_label";
@ -880,9 +882,10 @@ var GMPProvider = {
}
}
},
};
AddonManagerPrivate.registerProvider(GMPProvider, [
observe(subject, topic, data) {
if (topic == FIRST_CONTENT_PROCESS_TOPIC) {
AddonManagerPrivate.registerProvider(GMPProvider, [
new AddonManagerPrivate.AddonType(
"plugin",
URI_EXTENSION_STRINGS,
@ -891,4 +894,14 @@ AddonManagerPrivate.registerProvider(GMPProvider, [
6000,
AddonManager.TYPE_SUPPORTS_ASK_TO_ACTIVATE
),
]);
]);
Services.obs.removeObserver(this, FIRST_CONTENT_PROCESS_TOPIC);
}
},
addObserver() {
Services.obs.addObserver(this, FIRST_CONTENT_PROCESS_TOPIC);
},
};
GMPProvider.addObserver();

Просмотреть файл

@ -58,6 +58,11 @@ MockGMPInstallManager.prototype = {
add_task(async function setup() {
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2");
// The GMPProvider does not register until the first content process
// is launched, so we simulate that by firing this notification.
Services.obs.notifyObservers(null, "ipc:first-content-process-created");
await promiseStartupManager();
gPrefs.setBoolPref(GMPScope.GMPPrefs.KEY_LOGGING_DUMP, true);