зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1897452 - Interrupt all the relevancy store IO ops via a shutdown blocker r=bdk
Differential Revision: https://phabricator.services.mozilla.com/D211134
This commit is contained in:
Родитель
3d5936348b
Коммит
4a8c40e350
|
@ -9,6 +9,7 @@ const lazy = {};
|
|||
ChromeUtils.defineESModuleGetters(lazy, {
|
||||
getFrecentRecentCombinedUrls:
|
||||
"resource://gre/modules/contentrelevancy/private/InputUtils.sys.mjs",
|
||||
AsyncShutdown: "resource://gre/modules/AsyncShutdown.sys.mjs",
|
||||
NimbusFeatures: "resource://nimbus/ExperimentAPI.sys.mjs",
|
||||
RelevancyStore: "resource://gre/modules/RustRelevancy.sys.mjs",
|
||||
InterestVector: "resource://gre/modules/RustRelevancy.sys.mjs",
|
||||
|
@ -165,6 +166,14 @@ class RelevancyManager {
|
|||
}
|
||||
}
|
||||
|
||||
this._shutdownBlocker = () => this.interrupt();
|
||||
// Interrupt sooner prior to the `profile-before-change` phase to allow
|
||||
// all the in-progress IOs to exit.
|
||||
lazy.AsyncShutdown.profileChangeTeardown.addBlocker(
|
||||
"ContentRelevancyManager: Interrupt IO operations on relevancy store",
|
||||
this._shutdownBlocker
|
||||
);
|
||||
|
||||
this.#startUpTimer();
|
||||
}
|
||||
|
||||
|
@ -178,6 +187,13 @@ class RelevancyManager {
|
|||
this.#_store.close();
|
||||
this.#_store = null;
|
||||
}
|
||||
|
||||
if (this._shutdownBlocker) {
|
||||
lazy.AsyncShutdown.profileChangeTeardown.removeBlocker(
|
||||
this._shutdownBlocker
|
||||
);
|
||||
this._shutdownBlocker = null;
|
||||
}
|
||||
lazy.timerManager.unregisterTimer(TIMER_ID);
|
||||
}
|
||||
|
||||
|
@ -286,6 +302,22 @@ class RelevancyManager {
|
|||
lazy.log.info("Finished interest classification");
|
||||
}
|
||||
|
||||
/**
|
||||
* Interrupt all the IO operations on the relevancy store.
|
||||
*/
|
||||
interrupt() {
|
||||
if (this.#_store) {
|
||||
try {
|
||||
lazy.log.debug(
|
||||
"Interrupting all the IO operations on the relevancy store"
|
||||
);
|
||||
this.#_store.interrupt();
|
||||
} catch (error) {
|
||||
lazy.log.error("Interrupt error: " + (error.reason ?? error));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Exposed for testing.
|
||||
*/
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
"use strict";
|
||||
|
||||
ChromeUtils.defineESModuleGetters(this, {
|
||||
AsyncShutdown: "resource://gre/modules/AsyncShutdown.sys.mjs",
|
||||
ContentRelevancyManager:
|
||||
"resource://gre/modules/ContentRelevancyManager.sys.mjs",
|
||||
TestUtils: "resource://testing-common/TestUtils.sys.mjs",
|
||||
|
@ -100,6 +101,26 @@ add_task(async function test_call_disable_twice() {
|
|||
Services.prefs.clearUserPref(PREF_CONTENT_RELEVANCY_ENABLED);
|
||||
});
|
||||
|
||||
add_task(async function test_shutdown_blocker() {
|
||||
Services.prefs.setBoolPref(PREF_CONTENT_RELEVANCY_ENABLED, true);
|
||||
await TestUtils.waitForTick();
|
||||
|
||||
gSandbox.spy(ContentRelevancyManager, "interrupt");
|
||||
|
||||
// Simulate shutdown.
|
||||
Services.prefs.setBoolPref("toolkit.asyncshutdown.testing", true);
|
||||
AsyncShutdown.profileChangeTeardown._trigger();
|
||||
|
||||
await TestUtils.waitForCondition(
|
||||
() => ContentRelevancyManager.interrupt.calledOnce,
|
||||
"The interrupt shutdown blocker should be called"
|
||||
);
|
||||
|
||||
Services.prefs.clearUserPref("toolkit.asyncshutdown.testing");
|
||||
Services.prefs.clearUserPref(PREF_CONTENT_RELEVANCY_ENABLED);
|
||||
gSandbox.restore();
|
||||
});
|
||||
|
||||
/**
|
||||
* Sets up the update timer manager for testing: makes it fire more often,
|
||||
* removes all existing timers, and initializes it for testing. The body of this
|
||||
|
|
Загрузка…
Ссылка в новой задаче