mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 848344 - Clear media cache along with network cache when storage policy is set to STORE_ANYWHERE. r=michal
This commit is contained in:
parent
fbd56e66c5
commit
de0e5072f0
@ -98,6 +98,7 @@ void MediaCacheFlusher::Init()
|
|||||||
mozilla::services::GetObserverService();
|
mozilla::services::GetObserverService();
|
||||||
if (observerService) {
|
if (observerService) {
|
||||||
observerService->AddObserver(gMediaCacheFlusher, "last-pb-context-exited", true);
|
observerService->AddObserver(gMediaCacheFlusher, "last-pb-context-exited", true);
|
||||||
|
observerService->AddObserver(gMediaCacheFlusher, "network-clear-cache-stored-anywhere", true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -353,6 +354,9 @@ MediaCacheFlusher::Observe(nsISupports *aSubject, char const *aTopic, PRUnichar
|
|||||||
if (strcmp(aTopic, "last-pb-context-exited") == 0) {
|
if (strcmp(aTopic, "last-pb-context-exited") == 0) {
|
||||||
MediaCache::Flush();
|
MediaCache::Flush();
|
||||||
}
|
}
|
||||||
|
if (strcmp(aTopic, "network-clear-cache-stored-anywhere") == 0) {
|
||||||
|
MediaCache::Flush();
|
||||||
|
}
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
24
netwerk/cache/nsCacheService.cpp
vendored
24
netwerk/cache/nsCacheService.cpp
vendored
@ -5,6 +5,7 @@
|
|||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
#include "mozilla/Attributes.h"
|
#include "mozilla/Attributes.h"
|
||||||
|
#include "mozilla/Assertions.h"
|
||||||
#include "mozilla/DebugOnly.h"
|
#include "mozilla/DebugOnly.h"
|
||||||
#include "mozilla/Util.h"
|
#include "mozilla/Util.h"
|
||||||
|
|
||||||
@ -1496,10 +1497,31 @@ NS_IMETHODIMP nsCacheService::VisitEntries(nsICacheVisitor *visitor)
|
|||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void nsCacheService::FireClearNetworkCacheStoredAnywhereNotification()
|
||||||
|
{
|
||||||
|
MOZ_ASSERT(NS_IsMainThread());
|
||||||
|
nsCOMPtr<nsIObserverService> obsvc = mozilla::services::GetObserverService();
|
||||||
|
if (obsvc) {
|
||||||
|
obsvc->NotifyObservers(nullptr,
|
||||||
|
"network-clear-cache-stored-anywhere",
|
||||||
|
nullptr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP nsCacheService::EvictEntries(nsCacheStoragePolicy storagePolicy)
|
NS_IMETHODIMP nsCacheService::EvictEntries(nsCacheStoragePolicy storagePolicy)
|
||||||
{
|
{
|
||||||
return EvictEntriesForClient(nullptr, storagePolicy);
|
if (storagePolicy == nsICache::STORE_ANYWHERE) {
|
||||||
|
// if not called on main thread, dispatch the notification to the main thread to notify observers
|
||||||
|
if (!NS_IsMainThread()) {
|
||||||
|
nsCOMPtr<nsIRunnable> event = NS_NewRunnableMethod(this,
|
||||||
|
&nsCacheService::FireClearNetworkCacheStoredAnywhereNotification);
|
||||||
|
NS_DispatchToMainThread(event, NS_DISPATCH_NORMAL);
|
||||||
|
} else {
|
||||||
|
// else you're already on main thread - notify observers
|
||||||
|
FireClearNetworkCacheStoredAnywhereNotification();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return EvictEntriesForClient(nullptr, storagePolicy);
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP nsCacheService::GetCacheIOTarget(nsIEventTarget * *aCacheIOTarget)
|
NS_IMETHODIMP nsCacheService::GetCacheIOTarget(nsIEventTarget * *aCacheIOTarget)
|
||||||
|
1
netwerk/cache/nsCacheService.h
vendored
1
netwerk/cache/nsCacheService.h
vendored
@ -292,6 +292,7 @@ private:
|
|||||||
void ClearDoomList(void);
|
void ClearDoomList(void);
|
||||||
void DoomActiveEntries(DoomCheckFn check);
|
void DoomActiveEntries(DoomCheckFn check);
|
||||||
void CloseAllStreams();
|
void CloseAllStreams();
|
||||||
|
void FireClearNetworkCacheStoredAnywhereNotification();
|
||||||
|
|
||||||
static
|
static
|
||||||
PLDHashOperator GetActiveEntries(PLDHashTable * table,
|
PLDHashOperator GetActiveEntries(PLDHashTable * table,
|
||||||
|
Loading…
Reference in New Issue
Block a user