Bug 1848694 - Remove/avoid global references to nsIIOService r=mccr8,necko-reviewers,kershaw

This patch removes the static pointer to nsIIOService in nsContentUtils,
replacing it to calls to mozilla::components::IO::Service.

It also makes nsScriptSecurityManager::sIOService a StaticRefPtr.

Differential Revision: https://phabricator.services.mozilla.com/D188714
This commit is contained in:
Valentin Gosu
2023-09-22 12:49:44 +00:00
parent 84f393f171
commit cdd5195292
7 changed files with 30 additions and 29 deletions

View File

@@ -79,7 +79,7 @@
using namespace mozilla;
using namespace mozilla::dom;
nsIIOService* nsScriptSecurityManager::sIOService = nullptr;
StaticRefPtr<nsIIOService> nsScriptSecurityManager::sIOService;
std::atomic<bool> nsScriptSecurityManager::sStrictFileOriginPolicy = true;
namespace {
@@ -1549,9 +1549,12 @@ nsScriptSecurityManager::nsScriptSecurityManager(void)
}
nsresult nsScriptSecurityManager::Init() {
nsresult rv = CallGetService(NS_IOSERVICE_CONTRACTID, &sIOService);
NS_ENSURE_SUCCESS(rv, rv);
nsresult rv;
RefPtr<nsIIOService> io = mozilla::components::IO::Service(&rv);
if (NS_FAILED(rv)) {
return rv;
}
sIOService = std::move(io);
InitPrefs();
// Create our system principal singleton
@@ -1597,7 +1600,7 @@ nsScriptSecurityManager::~nsScriptSecurityManager(void) {
}
void nsScriptSecurityManager::Shutdown() {
NS_IF_RELEASE(sIOService);
sIOService = nullptr;
BundleHelper::Shutdown();
SystemPrincipal::Shutdown();
}