Bug 1523609 - avoid triggering nsChromeRegistryChrome::CheckForNewChrome (which does main thread I/O) during shutdown of system add-ons, r=kmag.

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Florian Quèze 2019-03-22 14:19:59 +00:00
Родитель d65d068e74
Коммит dbd7ac1015
5 изменённых файлов: 24 добавлений и 5 удалений

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

@ -130,7 +130,11 @@ this.formautofill = class extends ExtensionAPI {
Services.mm.loadFrameScript("chrome://formautofill/content/FormAutofillFrameScript.js", true, true); Services.mm.loadFrameScript("chrome://formautofill/content/FormAutofillFrameScript.js", true, true);
} }
onShutdown() { onShutdown(reason) {
if (reason == "APP_SHUTDOWN") {
return;
}
resProto.setSubstitution(RESOURCE_HOST, null); resProto.setSubstitution(RESOURCE_HOST, null);
this.chromeHandle.destruct(); this.chromeHandle.destruct();

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

@ -17,7 +17,7 @@ let l10nManifest;
this.l10n = class extends ExtensionAPI { this.l10n = class extends ExtensionAPI {
onShutdown(reason) { onShutdown(reason) {
if (l10nManifest) { if (reason !== "APP_SHUTDOWN" && l10nManifest) {
Components.manager.removeBootstrappedManifestLocation(l10nManifest); Components.manager.removeBootstrappedManifestLocation(l10nManifest);
} }
} }

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

@ -28,6 +28,7 @@
#include "mozilla/Unused.h" #include "mozilla/Unused.h"
#include "mozilla/intl/LocaleService.h" #include "mozilla/intl/LocaleService.h"
#include "nsIAppStartup.h"
#include "nsIObserverService.h" #include "nsIObserverService.h"
#include "nsIPrefBranch.h" #include "nsIPrefBranch.h"
#include "nsIPrefService.h" #include "nsIPrefService.h"
@ -273,6 +274,12 @@ nsChromeRegistryChrome::Observe(nsISupports* aSubject, const char* aTopic,
NS_IMETHODIMP NS_IMETHODIMP
nsChromeRegistryChrome::CheckForNewChrome() { nsChromeRegistryChrome::CheckForNewChrome() {
nsCOMPtr<nsIAppStartup> appStartup = components::AppStartup::Service();
if (appStartup->GetShuttingDown()) {
MOZ_ASSERT(false, "checking for new chrome during shutdown");
return NS_ERROR_UNEXPECTED;
}
mPackagesHash.Clear(); mPackagesHash.Clear();
mOverrideTable.Clear(); mOverrideTable.Clear();

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

@ -7,8 +7,7 @@
interface nsIToolkitProfile; interface nsIToolkitProfile;
[scriptable, uuid(6621f6d5-6c04-4a0e-9e74-447db221484e)] [scriptable, builtinclass, uuid(6621f6d5-6c04-4a0e-9e74-447db221484e)]
interface nsIAppStartup : nsISupports interface nsIAppStartup : nsISupports
{ {
/** /**
@ -142,7 +141,7 @@ interface nsIAppStartup : nsISupports
/** /**
* True if the application is in the process of shutting down. * True if the application is in the process of shutting down.
*/ */
readonly attribute boolean shuttingDown; [infallible] readonly attribute boolean shuttingDown;
/** /**
* True if the application is in the process of starting up. * True if the application is in the process of starting up.

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

@ -15,6 +15,7 @@
#include "mozilla/ClearOnShutdown.h" #include "mozilla/ClearOnShutdown.h"
#include "mozilla/EndianUtils.h" #include "mozilla/EndianUtils.h"
#include "mozilla/Components.h"
#include "mozilla/Compression.h" #include "mozilla/Compression.h"
#include "mozilla/LinkedList.h" #include "mozilla/LinkedList.h"
#include "mozilla/Preferences.h" #include "mozilla/Preferences.h"
@ -30,6 +31,7 @@
#include "nsAppRunner.h" #include "nsAppRunner.h"
#include "nsContentUtils.h" #include "nsContentUtils.h"
#include "nsChromeRegistry.h" #include "nsChromeRegistry.h"
#include "nsIAppStartup.h"
#include "nsIDOMWindowUtils.h" // for nsIJSRAIIHelper #include "nsIDOMWindowUtils.h" // for nsIJSRAIIHelper
#include "nsIFileURL.h" #include "nsIFileURL.h"
#include "nsIIOService.h" #include "nsIIOService.h"
@ -692,6 +694,13 @@ RegistryEntries::Destruct() {
if (isInList()) { if (isInList()) {
remove(); remove();
// No point in doing I/O to check for new chrome during shutdown, return
// early in that case.
nsCOMPtr<nsIAppStartup> appStartup = components::AppStartup::Service();
if (!appStartup || appStartup->GetShuttingDown()) {
return NS_OK;
}
// When we remove dynamic entries from the registry, we need to rebuild it // When we remove dynamic entries from the registry, we need to rebuild it
// in order to ensure a consistent state. See comments in Observe(). // in order to ensure a consistent state. See comments in Observe().
RefPtr<nsChromeRegistry> cr = nsChromeRegistry::GetSingleton(); RefPtr<nsChromeRegistry> cr = nsChromeRegistry::GetSingleton();