mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 05:11:16 +00:00
Bug 1275266 - Rename imgLoader::Singleton and imgLoader::PBSingleton to something less misleading, and document them. r=tnikkel
This commit is contained in:
parent
887122b9b7
commit
de83a13903
@ -3056,10 +3056,11 @@ nsContentUtils::GetImgLoaderForDocument(nsIDocument* aDoc)
|
||||
NS_ENSURE_TRUE(!DocumentInactiveForImageLoads(aDoc), nullptr);
|
||||
|
||||
if (!aDoc) {
|
||||
return imgLoader::Singleton();
|
||||
return imgLoader::NormalLoader();
|
||||
}
|
||||
bool isPrivate = IsInPrivateBrowsing(aDoc);
|
||||
return isPrivate ? imgLoader::PBSingleton() : imgLoader::Singleton();
|
||||
return isPrivate ? imgLoader::PrivateBrowsingLoader()
|
||||
: imgLoader::NormalLoader();
|
||||
}
|
||||
|
||||
// static
|
||||
@ -3069,11 +3070,14 @@ nsContentUtils::GetImgLoaderForChannel(nsIChannel* aChannel,
|
||||
{
|
||||
NS_ENSURE_TRUE(!DocumentInactiveForImageLoads(aContext), nullptr);
|
||||
|
||||
if (!aChannel)
|
||||
return imgLoader::Singleton();
|
||||
if (!aChannel) {
|
||||
return imgLoader::NormalLoader();
|
||||
}
|
||||
nsCOMPtr<nsILoadContext> context;
|
||||
NS_QueryNotificationCallbacks(aChannel, context);
|
||||
return context && context->UsePrivateBrowsing() ? imgLoader::PBSingleton() : imgLoader::Singleton();
|
||||
return context && context->UsePrivateBrowsing() ?
|
||||
imgLoader::PrivateBrowsingLoader() :
|
||||
imgLoader::NormalLoader();
|
||||
}
|
||||
|
||||
// static
|
||||
|
@ -296,7 +296,7 @@ nsContextMenuInfo::GetBackgroundImageRequestInternal(nsIDOMNode* aDOMNode,
|
||||
NS_NewURI(getter_AddRefs(bgUri), bgStringValue);
|
||||
NS_ENSURE_TRUE(bgUri, NS_ERROR_FAILURE);
|
||||
|
||||
imgLoader* il = imgLoader::Singleton();
|
||||
imgLoader* il = imgLoader::NormalLoader();
|
||||
NS_ENSURE_TRUE(il, NS_ERROR_FAILURE);
|
||||
|
||||
return il->LoadImage(bgUri, nullptr, nullptr,
|
||||
|
@ -464,8 +464,10 @@ gfxWindowsPlatform::HandleDeviceReset()
|
||||
mCompositorD3D11TextureSharingWorks = false;
|
||||
mDeviceResetReason = DeviceResetReason::OK;
|
||||
|
||||
imgLoader::Singleton()->ClearCache(true);
|
||||
imgLoader::Singleton()->ClearCache(false);
|
||||
imgLoader::Singleton()->NormalLoader(true);
|
||||
imgLoader::Singleton()->NormalLoader(false);
|
||||
imgLoader::Singleton()->PrivateBrowsingLoader(true);
|
||||
imgLoader::Singleton()->PrivateBrowsingLoader(false);
|
||||
gfxAlphaBoxBlur::ShutdownBlurCache();
|
||||
|
||||
InitializeDevices();
|
||||
|
@ -1134,8 +1134,8 @@ imgMemoryReporter* imgLoader::sMemReporter;
|
||||
NS_IMPL_ISUPPORTS(imgLoader, imgILoader, nsIContentSniffer, imgICache,
|
||||
nsISupportsWeakReference, nsIObserver)
|
||||
|
||||
static imgLoader* gSingleton = nullptr;
|
||||
static imgLoader* gPBSingleton = nullptr;
|
||||
static imgLoader* gNormalLoader = nullptr;
|
||||
static imgLoader* gPrivateBrowsingLoader = nullptr;
|
||||
|
||||
/* static */ already_AddRefed<imgLoader>
|
||||
imgLoader::CreateImageLoader()
|
||||
@ -1152,22 +1152,22 @@ imgLoader::CreateImageLoader()
|
||||
}
|
||||
|
||||
imgLoader*
|
||||
imgLoader::Singleton()
|
||||
imgLoader::NormalLoader()
|
||||
{
|
||||
if (!gSingleton) {
|
||||
gSingleton = CreateImageLoader().take();
|
||||
if (!gNormalLoader) {
|
||||
gNormalLoader = CreateImageLoader().take();
|
||||
}
|
||||
return gSingleton;
|
||||
return gNormalLoader;
|
||||
}
|
||||
|
||||
imgLoader*
|
||||
imgLoader::PBSingleton()
|
||||
imgLoader::PrivateBrowsingLoader()
|
||||
{
|
||||
if (!gPBSingleton) {
|
||||
gPBSingleton = CreateImageLoader().take();
|
||||
gPBSingleton->RespectPrivacyNotifications();
|
||||
if (!gPrivateBrowsingLoader) {
|
||||
gPrivateBrowsingLoader = CreateImageLoader().take();
|
||||
gPrivateBrowsingLoader->RespectPrivacyNotifications();
|
||||
}
|
||||
return gPBSingleton;
|
||||
return gPrivateBrowsingLoader;
|
||||
}
|
||||
|
||||
imgLoader::imgLoader()
|
||||
@ -1400,8 +1400,10 @@ imgLoader::ClearCacheForControlledDocument(nsIDocument* aDoc)
|
||||
void
|
||||
imgLoader::Shutdown()
|
||||
{
|
||||
NS_IF_RELEASE(gSingleton);
|
||||
NS_IF_RELEASE(gPBSingleton);
|
||||
NS_IF_RELEASE(gNormalLoader);
|
||||
gNormalLoader = nullptr;
|
||||
NS_IF_RELEASE(gPrivateBrowsingLoader);
|
||||
gPrivateBrowsingLoader = nullptr;
|
||||
}
|
||||
|
||||
nsresult
|
||||
|
@ -246,11 +246,24 @@ public:
|
||||
NS_DECL_IMGICACHE
|
||||
NS_DECL_NSIOBSERVER
|
||||
|
||||
static imgLoader* Singleton();
|
||||
static imgLoader* PBSingleton();
|
||||
/**
|
||||
* Get the normal image loader instance that is used by gecko code, creating
|
||||
* it if necessary.
|
||||
*/
|
||||
static imgLoader* NormalLoader();
|
||||
|
||||
/**
|
||||
* Gecko code should use Singleton() or PBSingleton() to get an image loader.
|
||||
* Get the Private Browsing image loader instance that is used by gecko code,
|
||||
* creating it if necessary.
|
||||
*
|
||||
* The nsIChannel objects that this instance creates are created with the
|
||||
* nsILoadInfo::SEC_FORCE_PRIVATE_BROWSING flag.
|
||||
*/
|
||||
static imgLoader* PrivateBrowsingLoader();
|
||||
|
||||
/**
|
||||
* Gecko code should use NormalLoader() or PrivateBrowsingLoader() to get the
|
||||
* appropriate image loader.
|
||||
*
|
||||
* This constructor is public because the XPCOM module code that creates
|
||||
* instances of "@mozilla.org/image/loader;1" / "@mozilla.org/image/cache;1"
|
||||
|
@ -248,8 +248,8 @@ nsAlertsIconListener::StartRequest(const nsAString & aImageUrl, bool aInPrivateB
|
||||
if (!imageUri)
|
||||
return ShowAlert(nullptr);
|
||||
|
||||
imgLoader* il =
|
||||
aInPrivateBrowsing ? imgLoader::PBSingleton() : imgLoader::Singleton();
|
||||
imgLoader* il = aInPrivateBrowsing ? imgLoader::PrivateBrowsingLoader()
|
||||
: imgLoader::NormalLoader();
|
||||
if (!il)
|
||||
return ShowAlert(nullptr);
|
||||
|
||||
|
@ -391,8 +391,8 @@ OSXNotificationCenter::ShowAlertWithIconData(nsIAlertNotification* aAlert,
|
||||
} else {
|
||||
mPendingAlerts.AppendElement(osxni);
|
||||
osxni->mPendingNotifiction = notification;
|
||||
imgLoader* il =
|
||||
inPrivateBrowsing ? imgLoader::PBSingleton() : imgLoader::Singleton();
|
||||
imgLoader* il = inPrivateBrowsing ? imgLoader::PrivateBrowsingLoader()
|
||||
: imgLoader::NormalLoader();
|
||||
if (il) {
|
||||
nsCOMPtr<nsIURI> imageUri;
|
||||
NS_NewURI(getter_AddRefs(imageUri), imageUrl);
|
||||
|
Loading…
Reference in New Issue
Block a user