Skip to content
Permalink
Browse files
2010-11-19 Darin Adler <darin@apple.com>
        Reviewed by Sam Weinig.

        Need a way to clear disk cache from WebContext
        https://bugs.webkit.org/show_bug.cgi?id=49820

        * UIProcess/API/C/WKContext.cpp:
        (WKContextClearResourceCaches): Added.
        (WKContextClearApplicationCache): Added.
        * UIProcess/API/C/WKContext.h:
        * UIProcess/WebContext.cpp:
        (WebKit::WebContext::clearResourceCaches): Added.
        (WebKit::WebContext::clearApplicationCache): Added.
        * UIProcess/WebContext.h:
        * WebProcess/WebProcess.cpp:
        (WebKit::WebProcess::clearResourceCaches): Added.
        (WebKit::WebProcess::clearApplicationCache): Added.
        * WebProcess/WebProcess.h:
        * WebProcess/WebProcess.messages.in: Added messages.
        * WebProcess/mac/WebProcessMac.mm:
        (WebKit::WebProcess::platformClearResourceCaches): Added.
        * WebProcess/qt/WebProcessQt.cpp:
        (WebKit::WebProcess::platformClearResourceCaches): Added.
        * WebProcess/win/WebProcessWin.cpp:
        (WebKit::WebProcess::platformClearResourceCaches): Added.


Canonical link: https://commits.webkit.org/62902@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@72440 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
darinadler committed Nov 19, 2010
1 parent bc96e49 commit 47d9d702650782bd0c4dfd3c3262d895ee3ee6a8
@@ -1,3 +1,30 @@
2010-11-19 Darin Adler <darin@apple.com>

Reviewed by Sam Weinig.

Need a way to clear disk cache from WebContext
https://bugs.webkit.org/show_bug.cgi?id=49820

* UIProcess/API/C/WKContext.cpp:
(WKContextClearResourceCaches): Added.
(WKContextClearApplicationCache): Added.
* UIProcess/API/C/WKContext.h:
* UIProcess/WebContext.cpp:
(WebKit::WebContext::clearResourceCaches): Added.
(WebKit::WebContext::clearApplicationCache): Added.
* UIProcess/WebContext.h:
* WebProcess/WebProcess.cpp:
(WebKit::WebProcess::clearResourceCaches): Added.
(WebKit::WebProcess::clearApplicationCache): Added.
* WebProcess/WebProcess.h:
* WebProcess/WebProcess.messages.in: Added messages.
* WebProcess/mac/WebProcessMac.mm:
(WebKit::WebProcess::platformClearResourceCaches): Added.
* WebProcess/qt/WebProcessQt.cpp:
(WebKit::WebProcess::platformClearResourceCaches): Added.
* WebProcess/win/WebProcessWin.cpp:
(WebKit::WebProcess::platformClearResourceCaches): Added.

2010-11-19 Anders Carlsson <andersca@apple.com>

Reviewed by Sam Weinig.
@@ -142,3 +142,13 @@ void WKContextSetDomainRelaxationForbiddenForURLScheme(WKContextRef contextRef,
{
toImpl(contextRef)->setDomainRelaxationForbiddenForURLScheme(toImpl(urlScheme)->string());
}

void WKContextClearResourceCaches(WKContextRef contextRef)
{
toImpl(contextRef)->clearResourceCaches();
}

void WKContextClearApplicationCache(WKContextRef contextRef)
{
toImpl(contextRef)->clearApplicationCache();
}
@@ -112,6 +112,9 @@ WK_EXPORT void WKContextAddVisitedLink(WKContextRef context, WKStringRef visited
WK_EXPORT void WKContextSetCacheModel(WKContextRef context, WKCacheModel cacheModel);
WK_EXPORT WKCacheModel WKContextGetCacheModel(WKContextRef context);

WK_EXPORT void WKContextClearResourceCaches(WKContextRef context);
WK_EXPORT void WKContextClearApplicationCache(WKContextRef context);

#ifdef __cplusplus
}
#endif
@@ -490,4 +490,14 @@ CoreIPC::SyncReplyMode WebContext::didReceiveSyncMessage(CoreIPC::Connection* co
return CoreIPC::AutomaticReply;
}

void WebContext::clearResourceCaches()
{
m_process->send(Messages::WebProcess::ClearResourceCaches(), 0);
}

void WebContext::clearApplicationCache()
{
m_process->send(Messages::WebProcess::ClearApplicationCache(), 0);
}

} // namespace WebKit
@@ -114,6 +114,8 @@ class WebContext : public APIObject {

void setCacheModel(CacheModel);
CacheModel cacheModel() const { return m_cacheModel; }
void clearResourceCaches();
void clearApplicationCache();

#if PLATFORM(WIN)
void setShouldPaintNativeControls(bool);
@@ -41,6 +41,7 @@
#include "WebProcessMessages.h"
#include "WebProcessProxyMessages.h"
#include <WebCore/ApplicationCacheStorage.h>
#include <WebCore/CrossOriginPreflightResultCache.h>
#include <WebCore/Language.h>
#include <WebCore/Page.h>
#include <WebCore/PageGroup.h>
@@ -525,4 +526,26 @@ void WebProcess::removeWebFrame(uint64_t frameID)
m_connection->send(Messages::WebProcessProxy::DidDestroyFrame(frameID), 0);
}

void WebProcess::clearResourceCaches()
{
platformClearResourceCaches();

// Toggling the cache model like this forces the cache to evict all its in-memory resources.
// FIXME: We need a better way to do this.
CacheModel cacheModel = m_cacheModel;
setCacheModel(CacheModelDocumentViewer);
setCacheModel(cacheModel);

// Empty the cross-origin preflight cache.
CrossOriginPreflightResultCache::shared().empty();
}

void WebProcess::clearApplicationCache()
{
#if ENABLE(OFFLINE_WEB_APPLICATIONS)
// Empty the application cache.
cacheStorage().empty();
#endif
}

} // namespace WebKit
@@ -108,6 +108,9 @@ class WebProcess : ChildProcess {
static void calculateCacheSizes(CacheModel cacheModel, uint64_t memorySize, uint64_t diskFreeSize,
unsigned& cacheTotalCapacity, unsigned& cacheMinDeadCapacity, unsigned& cacheMaxDeadCapacity, double& deadDecodedDataDeletionInterval,
unsigned& pageCacheCapacity, unsigned long& urlCacheMemoryCapacity, unsigned long& urlCacheDiskCapacity);
void clearResourceCaches();
void platformClearResourceCaches();
void clearApplicationCache();

// CoreIPC::Connection::Client
void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*);
@@ -42,4 +42,7 @@ messages -> WebProcess {
#if PLATFORM(WIN)
SetShouldPaintNativeControls(bool shouldPaintNativeControls)
#endif

ClearResourceCaches();
ClearApplicationCache();
}
@@ -96,4 +96,9 @@ static uint64_t volumeFreeSize(NSString *path)
[nsurlCache setDiskCapacity:max<unsigned long>(urlCacheDiskCapacity, [nsurlCache diskCapacity])]; // Don't shrink a big disk cache, since that would cause churn.
}

void WebProcess::platformClearResourceCaches()
{
[[NSURLCache sharedURLCache] removeAllCachedResponses];
}

} // namespace WebKit
@@ -27,9 +27,13 @@

namespace WebKit {

void WebProcess::platformSetCacheModel(CacheModel cacheModel)
void WebProcess::platformSetCacheModel(CacheModel)
{
// FIXME: Implement.
}

void WebProcess::platformClearResourceCaches()
{
}

} // namespace WebKit
@@ -95,4 +95,11 @@ void WebProcess::platformSetCacheModel(CacheModel cacheModel)
#endif
}

void WebProcess::platformClearResourceCaches()
{
#if USE(CFNETWORK)
CFURLCacheRemoveAllCachedResponses(RetainPtr<CFURLCacheRef>(AdoptCF, CFURLCacheCopySharedURLCache()).get());
#endif
}

} // namespace WebKit

0 comments on commit 47d9d70

Please sign in to comment.