зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1536744 - Add nsResProtocolHandler::GetSingleton() r=baku
Differential Revision: https://phabricator.services.mozilla.com/D30692 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
b31eaf52cc
Коммит
ef2b6cf771
|
@ -316,7 +316,7 @@ Classes = [
|
|||
'singleton': True,
|
||||
'type': 'nsResProtocolHandler',
|
||||
'headers': ['/netwerk/protocol/res/nsResProtocolHandler.h'],
|
||||
'init_method': 'Init',
|
||||
'constructor': 'nsResProtocolHandler::GetSingleton',
|
||||
},
|
||||
{
|
||||
'cid': '{9c7ec5d1-23f9-11d5-aea8-8fcc0793e97f}',
|
||||
|
|
|
@ -25,6 +25,20 @@ using mozilla::dom::ContentParent;
|
|||
#define kGRE "gre"
|
||||
#define kAndroid "android"
|
||||
|
||||
mozilla::StaticRefPtr<nsResProtocolHandler> nsResProtocolHandler::sSingleton;
|
||||
|
||||
already_AddRefed<nsResProtocolHandler> nsResProtocolHandler::GetSingleton() {
|
||||
if (!sSingleton) {
|
||||
RefPtr<nsResProtocolHandler> handler = new nsResProtocolHandler();
|
||||
if (NS_WARN_IF(NS_FAILED(handler->Init()))) {
|
||||
return nullptr;
|
||||
}
|
||||
sSingleton = handler;
|
||||
ClearOnShutdown(&sSingleton);
|
||||
}
|
||||
return do_AddRef(sSingleton);
|
||||
}
|
||||
|
||||
nsresult nsResProtocolHandler::Init() {
|
||||
nsresult rv;
|
||||
rv = mozilla::Omnijar::GetURIString(mozilla::Omnijar::APP, mAppURI);
|
||||
|
|
|
@ -23,6 +23,8 @@ class nsResProtocolHandler final
|
|||
NS_DECL_ISUPPORTS_INHERITED
|
||||
NS_DECL_NSIRESPROTOCOLHANDLER
|
||||
|
||||
static already_AddRefed<nsResProtocolHandler> GetSingleton();
|
||||
|
||||
NS_FORWARD_NSIPROTOCOLHANDLER(mozilla::net::SubstitutingProtocolHandler::)
|
||||
|
||||
nsResProtocolHandler()
|
||||
|
@ -32,8 +34,6 @@ class nsResProtocolHandler final
|
|||
URI_IS_POTENTIALLY_TRUSTWORTHY,
|
||||
/* aEnforceFileOrJar = */ false) {}
|
||||
|
||||
MOZ_MUST_USE nsresult Init();
|
||||
|
||||
NS_IMETHOD SetSubstitution(const nsACString& aRoot,
|
||||
nsIURI* aBaseURI) override;
|
||||
NS_IMETHOD SetSubstitutionWithFlags(const nsACString& aRoot, nsIURI* aBaseURI,
|
||||
|
@ -71,6 +71,9 @@ class nsResProtocolHandler final
|
|||
nsACString& aResult) override;
|
||||
|
||||
private:
|
||||
MOZ_MUST_USE nsresult Init();
|
||||
static mozilla::StaticRefPtr<nsResProtocolHandler> sSingleton;
|
||||
|
||||
nsCString mAppURI;
|
||||
nsCString mGREURI;
|
||||
#ifdef ANDROID
|
||||
|
|
Загрузка…
Ссылка в новой задаче