зеркало из https://github.com/mozilla/gecko-dev.git
Bug 576621 - clearing cache does NOT clear cached images.r=joe,gavin
This commit is contained in:
Родитель
599142a072
Коммит
57fe00ab9a
|
@ -122,6 +122,12 @@ Sanitizer.prototype = {
|
||||||
// facility for timespan-based eviction. Wipe it.
|
// facility for timespan-based eviction. Wipe it.
|
||||||
cacheService.evictEntries(Ci.nsICache.STORE_ANYWHERE);
|
cacheService.evictEntries(Ci.nsICache.STORE_ANYWHERE);
|
||||||
} catch(er) {}
|
} catch(er) {}
|
||||||
|
|
||||||
|
var imageCache = Cc["@mozilla.org/image/cache;1"].
|
||||||
|
getService(Ci.imgICache);
|
||||||
|
try {
|
||||||
|
imageCache.clearCache(false); // true=chrome, false=content
|
||||||
|
} catch(er) {}
|
||||||
},
|
},
|
||||||
|
|
||||||
get canClear()
|
get canClear()
|
||||||
|
|
|
@ -571,6 +571,17 @@ PrivateBrowsingService.prototype = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Image Cache
|
||||||
|
let (imageCache = Cc["@mozilla.org/image/cache;1"].
|
||||||
|
getService(Ci.imgICache)) {
|
||||||
|
try {
|
||||||
|
imageCache.clearCache(false); // true=chrome, false=content
|
||||||
|
} catch (ex) {
|
||||||
|
Cu.reportError("Exception thrown while clearing the image cache: " +
|
||||||
|
ex.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Cookies
|
// Cookies
|
||||||
let (cm = Cc["@mozilla.org/cookiemanager;1"].
|
let (cm = Cc["@mozilla.org/cookiemanager;1"].
|
||||||
getService(Ci.nsICookieManager2)) {
|
getService(Ci.nsICookieManager2)) {
|
||||||
|
|
|
@ -78,6 +78,7 @@
|
||||||
#include "nsIApplicationCacheContainer.h"
|
#include "nsIApplicationCacheContainer.h"
|
||||||
|
|
||||||
#include "nsIMemoryReporter.h"
|
#include "nsIMemoryReporter.h"
|
||||||
|
#include "nsIPrivateBrowsingService.h"
|
||||||
|
|
||||||
// we want to explore making the document own the load group
|
// we want to explore making the document own the load group
|
||||||
// so we can associate the document URI with the load group.
|
// so we can associate the document URI with the load group.
|
||||||
|
@ -874,19 +875,36 @@ nsresult imgLoader::Init()
|
||||||
|
|
||||||
prefs->AddObserver("image.http.accept", this, PR_TRUE);
|
prefs->AddObserver("image.http.accept", this, PR_TRUE);
|
||||||
|
|
||||||
|
// Listen for when we leave private browsing mode
|
||||||
|
nsCOMPtr<nsIObserverService> obService = mozilla::services::GetObserverService();
|
||||||
|
if (obService)
|
||||||
|
obService->AddObserver(this, NS_PRIVATE_BROWSING_SWITCH_TOPIC, PR_TRUE);
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
imgLoader::Observe(nsISupports* aSubject, const char* aTopic, const PRUnichar* aData)
|
imgLoader::Observe(nsISupports* aSubject, const char* aTopic, const PRUnichar* aData)
|
||||||
{
|
{
|
||||||
NS_ASSERTION(strcmp(aTopic, NS_PREFBRANCH_PREFCHANGE_TOPIC_ID) == 0,
|
// We listen for pref change notifications...
|
||||||
"invalid topic received");
|
if (!strcmp(aTopic, NS_PREFBRANCH_PREFCHANGE_TOPIC_ID)) {
|
||||||
|
if (!strcmp(NS_ConvertUTF16toUTF8(aData).get(), "image.http.accept")) {
|
||||||
if (strcmp(NS_ConvertUTF16toUTF8(aData).get(), "image.http.accept") == 0) {
|
|
||||||
nsCOMPtr<nsIPrefBranch> prefs = do_QueryInterface(aSubject);
|
nsCOMPtr<nsIPrefBranch> prefs = do_QueryInterface(aSubject);
|
||||||
ReadAcceptHeaderPref(prefs);
|
ReadAcceptHeaderPref(prefs);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ...and exits from private browsing.
|
||||||
|
else if (!strcmp(aTopic, NS_PRIVATE_BROWSING_SWITCH_TOPIC)) {
|
||||||
|
if (NS_LITERAL_STRING(NS_PRIVATE_BROWSING_LEAVE).Equals(aData))
|
||||||
|
ClearImageCache();
|
||||||
|
}
|
||||||
|
|
||||||
|
// (Nothing else should bring us here)
|
||||||
|
else {
|
||||||
|
NS_ABORT_IF_FALSE(0, "Invalid topic received");
|
||||||
|
}
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче