зеркало из https://github.com/mozilla/gecko-dev.git
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:
Родитель
e7bc47985e
Коммит
32014974c0
|
@ -79,7 +79,7 @@
|
||||||
using namespace mozilla;
|
using namespace mozilla;
|
||||||
using namespace mozilla::dom;
|
using namespace mozilla::dom;
|
||||||
|
|
||||||
nsIIOService* nsScriptSecurityManager::sIOService = nullptr;
|
StaticRefPtr<nsIIOService> nsScriptSecurityManager::sIOService;
|
||||||
std::atomic<bool> nsScriptSecurityManager::sStrictFileOriginPolicy = true;
|
std::atomic<bool> nsScriptSecurityManager::sStrictFileOriginPolicy = true;
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
@ -1549,9 +1549,12 @@ nsScriptSecurityManager::nsScriptSecurityManager(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult nsScriptSecurityManager::Init() {
|
nsresult nsScriptSecurityManager::Init() {
|
||||||
nsresult rv = CallGetService(NS_IOSERVICE_CONTRACTID, &sIOService);
|
nsresult rv;
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
RefPtr<nsIIOService> io = mozilla::components::IO::Service(&rv);
|
||||||
|
if (NS_FAILED(rv)) {
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
sIOService = std::move(io);
|
||||||
InitPrefs();
|
InitPrefs();
|
||||||
|
|
||||||
// Create our system principal singleton
|
// Create our system principal singleton
|
||||||
|
@ -1597,7 +1600,7 @@ nsScriptSecurityManager::~nsScriptSecurityManager(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void nsScriptSecurityManager::Shutdown() {
|
void nsScriptSecurityManager::Shutdown() {
|
||||||
NS_IF_RELEASE(sIOService);
|
sIOService = nullptr;
|
||||||
BundleHelper::Shutdown();
|
BundleHelper::Shutdown();
|
||||||
SystemPrincipal::Shutdown();
|
SystemPrincipal::Shutdown();
|
||||||
}
|
}
|
||||||
|
|
|
@ -135,7 +135,7 @@ class nsScriptSecurityManager final : public nsIScriptSecurityManager {
|
||||||
|
|
||||||
static std::atomic<bool> sStrictFileOriginPolicy;
|
static std::atomic<bool> sStrictFileOriginPolicy;
|
||||||
|
|
||||||
static nsIIOService* sIOService;
|
static mozilla::StaticRefPtr<nsIIOService> sIOService;
|
||||||
static nsIStringBundle* sStrBundle;
|
static nsIStringBundle* sStrBundle;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -12496,8 +12496,8 @@ void Document::MaybePreconnect(nsIURI* aOrigURI, mozilla::CORSMode aCORSMode) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsCOMPtr<nsISpeculativeConnect> speculator(
|
nsCOMPtr<nsISpeculativeConnect> speculator =
|
||||||
do_QueryInterface(nsContentUtils::GetIOService()));
|
mozilla::components::IO::Service();
|
||||||
if (!speculator) {
|
if (!speculator) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -3263,10 +3263,11 @@ nsresult Element::PostHandleEventForLinks(EventChainPostVisitor& aVisitor) {
|
||||||
// connection to be sure we have one ready when we open the channel.
|
// connection to be sure we have one ready when we open the channel.
|
||||||
if (nsIDocShell* shell = OwnerDoc()->GetDocShell()) {
|
if (nsIDocShell* shell = OwnerDoc()->GetDocShell()) {
|
||||||
if (nsCOMPtr<nsIURI> absURI = GetHrefURI()) {
|
if (nsCOMPtr<nsIURI> absURI = GetHrefURI()) {
|
||||||
nsCOMPtr<nsISpeculativeConnect> sc =
|
if (nsCOMPtr<nsISpeculativeConnect> sc =
|
||||||
do_QueryInterface(nsContentUtils::GetIOService());
|
mozilla::components::IO::Service()) {
|
||||||
nsCOMPtr<nsIInterfaceRequestor> ir = do_QueryInterface(shell);
|
nsCOMPtr<nsIInterfaceRequestor> ir = do_QueryInterface(shell);
|
||||||
sc->SpeculativeConnect(absURI, NodePrincipal(), ir, false);
|
sc->SpeculativeConnect(absURI, NodePrincipal(), ir, false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -424,7 +424,6 @@ nsIXPConnect* nsContentUtils::sXPConnect;
|
||||||
nsIScriptSecurityManager* nsContentUtils::sSecurityManager;
|
nsIScriptSecurityManager* nsContentUtils::sSecurityManager;
|
||||||
nsIPrincipal* nsContentUtils::sSystemPrincipal;
|
nsIPrincipal* nsContentUtils::sSystemPrincipal;
|
||||||
nsIPrincipal* nsContentUtils::sNullSubjectPrincipal;
|
nsIPrincipal* nsContentUtils::sNullSubjectPrincipal;
|
||||||
nsIIOService* nsContentUtils::sIOService;
|
|
||||||
nsIConsoleService* nsContentUtils::sConsoleService;
|
nsIConsoleService* nsContentUtils::sConsoleService;
|
||||||
|
|
||||||
static nsTHashMap<RefPtr<nsAtom>, EventNameMapping>* sAtomEventTable;
|
static nsTHashMap<RefPtr<nsAtom>, EventNameMapping>* sAtomEventTable;
|
||||||
|
@ -804,13 +803,6 @@ nsresult nsContentUtils::Init() {
|
||||||
|
|
||||||
nullPrincipal.forget(&sNullSubjectPrincipal);
|
nullPrincipal.forget(&sNullSubjectPrincipal);
|
||||||
|
|
||||||
nsresult rv = CallGetService(NS_IOSERVICE_CONTRACTID, &sIOService);
|
|
||||||
if (NS_FAILED(rv)) {
|
|
||||||
// This makes life easier, but we can live without it.
|
|
||||||
|
|
||||||
sIOService = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!InitializeEventTable()) return NS_ERROR_FAILURE;
|
if (!InitializeEventTable()) return NS_ERROR_FAILURE;
|
||||||
|
|
||||||
if (!sEventListenerManagersHash) {
|
if (!sEventListenerManagersHash) {
|
||||||
|
@ -1880,7 +1872,6 @@ void nsContentUtils::Shutdown() {
|
||||||
NS_IF_RELEASE(sSecurityManager);
|
NS_IF_RELEASE(sSecurityManager);
|
||||||
NS_IF_RELEASE(sSystemPrincipal);
|
NS_IF_RELEASE(sSystemPrincipal);
|
||||||
NS_IF_RELEASE(sNullSubjectPrincipal);
|
NS_IF_RELEASE(sNullSubjectPrincipal);
|
||||||
NS_IF_RELEASE(sIOService);
|
|
||||||
|
|
||||||
sBidiKeyboard = nullptr;
|
sBidiKeyboard = nullptr;
|
||||||
|
|
||||||
|
@ -2084,8 +2075,15 @@ bool nsContentUtils::IsAbsoluteURL(const nsACString& aURL) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nsresult rv = NS_OK;
|
||||||
|
nsCOMPtr<nsIIOService> io = mozilla::components::IO::Service(&rv);
|
||||||
|
MOZ_DIAGNOSTIC_ASSERT(NS_SUCCEEDED(rv));
|
||||||
|
if (NS_FAILED(rv)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
uint32_t flags;
|
uint32_t flags;
|
||||||
if (NS_SUCCEEDED(sIOService->GetProtocolFlags(scheme.get(), &flags))) {
|
if (NS_SUCCEEDED(io->GetProtocolFlags(scheme.get(), &flags))) {
|
||||||
return flags & nsIProtocolHandler::URI_NORELATIVE;
|
return flags & nsIProtocolHandler::URI_NORELATIVE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6255,7 +6253,7 @@ bool nsContentUtils::CheckForSubFrameDrop(nsIDragSession* aDragSession,
|
||||||
/* static */
|
/* static */
|
||||||
bool nsContentUtils::URIIsLocalFile(nsIURI* aURI) {
|
bool nsContentUtils::URIIsLocalFile(nsIURI* aURI) {
|
||||||
bool isFile;
|
bool isFile;
|
||||||
nsCOMPtr<nsINetUtil> util = do_QueryInterface(sIOService);
|
nsCOMPtr<nsINetUtil> util = mozilla::components::IO::Service();
|
||||||
|
|
||||||
// Important: we do NOT test the entire URI chain here!
|
// Important: we do NOT test the entire URI chain here!
|
||||||
return util &&
|
return util &&
|
||||||
|
|
|
@ -826,8 +826,6 @@ class nsContentUtils {
|
||||||
// element.
|
// element.
|
||||||
static bool InProlog(nsINode* aNode);
|
static bool InProlog(nsINode* aNode);
|
||||||
|
|
||||||
static nsIIOService* GetIOService() { return sIOService; }
|
|
||||||
|
|
||||||
static nsIBidiKeyboard* GetBidiKeyboard();
|
static nsIBidiKeyboard* GetBidiKeyboard();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -3523,8 +3521,6 @@ class nsContentUtils {
|
||||||
static nsIPrincipal* sSystemPrincipal;
|
static nsIPrincipal* sSystemPrincipal;
|
||||||
static nsIPrincipal* sNullSubjectPrincipal;
|
static nsIPrincipal* sNullSubjectPrincipal;
|
||||||
|
|
||||||
static nsIIOService* sIOService;
|
|
||||||
|
|
||||||
static nsIConsoleService* sConsoleService;
|
static nsIConsoleService* sConsoleService;
|
||||||
|
|
||||||
static nsIStringBundleService* sStringBundleService;
|
static nsIStringBundleService* sStringBundleService;
|
||||||
|
|
|
@ -176,8 +176,10 @@ static bool CanHandleURI(nsIURI* aURI) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsIIOService* ios = nsContentUtils::GetIOService();
|
nsCOMPtr<nsIIOService> ios = mozilla::components::IO::Service();
|
||||||
if (!ios) return false;
|
if (!ios) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
nsCOMPtr<nsIProtocolHandler> handler;
|
nsCOMPtr<nsIProtocolHandler> handler;
|
||||||
ios->GetProtocolHandler(scheme.get(), getter_AddRefs(handler));
|
ios->GetProtocolHandler(scheme.get(), getter_AddRefs(handler));
|
||||||
|
|
Загрузка…
Ссылка в новой задаче