WebKit2: Need a way to manage the WebCore Cache
authorbweinstein@apple.com <bweinstein@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 17 Feb 2011 19:28:36 +0000 (19:28 +0000)
committerbweinstein@apple.com <bweinstein@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 17 Feb 2011 19:28:36 +0000 (19:28 +0000)
commit90810f03899acbbf7c16dae147c1e8daebe72667
tree4df336c356948c690d64558b6acc86d393a8e338
parentd279a6f96e553e3fca1dade99ab4e2b06e585ca3
WebKit2: Need a way to manage the WebCore Cache
https://bugs.webkit.org/show_bug.cgi?id=54501

Reviewed by Brady Eidson.

Source/WebCore:

Add a way to get a set of all of the origins that have entries in the
WebCore memory cache, and a method to remove all resources from the memory
cache from a given security origin.

No change in behavior.

* WebCore.exp.in: Add functions that need to be exported.
* loader/cache/MemoryCache.cpp:
(WebCore::MemoryCache::removeResourcesWithOrigin):
(WebCore::MemoryCache::getOriginsWithCache):
* loader/cache/MemoryCache.h:

Source/WebKit2:

Implement a WebKit2 API to manage the WebCore memory cache. This API exposes three functions:

1) A method to get a list of all security origins that have entries in the WebCore memory cache.
2) A method to remove all entries in the WebCore memory cache from a SecurityOrigin.
3) A method to remove all entries from the WebCore memory cache.

* Platform/CoreIPC/MessageID.h: Add two new MessageClasses.
* Shared/API/c/WKBase.h:
* Shared/APIObject.h: Add a CacheManager type.
* Shared/WebSecurityOrigin.h: Typedef WKCacheManagerRef.
(WebKit::WebSecurityOrigin::createFromString): Creates a WebCore::SecurityOrigin using
    SecurityOrigin::createFromString.
(WebKit::WebSecurityOrigin::toString): Calls through to SecurityOrigin::toString.
* UIProcess/API/C/WKAPICast.h:

* UIProcess/API/C/WKCacheManager.cpp: Added.
(WKCacheManagerGetTypeID): Returns the WebResourceCacheManagerProxy type.
(WKCacheManagerGetCacheOrigins): Calls through to WebResourceCacheManagerProxy::getCacheOrigins.
(callGetCacheOriginsBlockBlockAndDispose):
(WKCacheManagerGetCacheOrigins_b):
(WKCacheManagerDeleteCacheForOrigin): Calls through to WebResourceCacheManagerProxy::deleteCacheForOrigin.
(WKCacheManagerDeleteAllCache): Calls through to WebResourceCacheManagerProxy::deleteAllCache.
* UIProcess/API/C/WKCacheManager.h: Added.

* UIProcess/API/C/WKContext.cpp:
(WKContextGetCacheManager): Calls to get the WebResourceCacheManagerProxy.
* UIProcess/API/C/WKContext.h:

* UIProcess/WebResourceCacheManagerProxy.cpp: Added.
(WebKit::WebResourceCacheManagerProxy::create): Calls through to the constructor.
(WebKit::WebResourceCacheManagerProxy::WebResourceCacheManagerProxy): Initialize the m_webContext variable.
(WebKit::WebResourceCacheManagerProxy::~WebResourceCacheManagerProxy):
(WebKit::WebResourceCacheManagerProxy::invalidate): Invalidate the callback map.
(WebKit::WebResourceCacheManagerProxy::getCacheOrigins): Call through to the web process to get the cache
    origins.
(WebKit::WebResourceCacheManagerProxy::didGetCacheOrigins): Call the callback.
(WebKit::WebResourceCacheManagerProxy::deleteCacheForOrigin): Call through to the web process to delete cache
    for the given origin.
(WebKit::WebResourceCacheManagerProxy::deleteAllCache): Call through to the web process to delete all of the cache.
* UIProcess/WebResourceCacheManagerProxy.h: Added.
(WebKit::WebResourceCacheManagerProxy::clearContext):
(WebKit::WebResourceCacheManagerProxy::type):
* UIProcess/WebResourceCacheManagerProxy.messages.in: Added.

* UIProcess/WebContext.cpp:
(WebKit::WebContext::WebContext): Initialize new member variable.
(WebKit::WebContext::~WebContext):  Invalidates new member variable.
(WebKit::WebContext::didReceiveMessage): Passes cache messages to the cache manager.
* UIProcess/WebContext.h:
(WebKit::WebContext::cacheManagerProxy):
* UIProcess/WebProcessProxy.cpp:
(WebKit::WebProcessProxy::didReceiveMessage): Add a new message class.

* WebProcess/MemoryCache/WebResourceCacheManager.cpp: Added.
(WebKit::WebResourceCacheManager::shared):
(WebKit::WebResourceCacheManager::WebResourceCacheManager):
(WebKit::WebResourceCacheManager::~WebResourceCacheManager):
(WebKit::WebResourceCacheManager::didReceiveMessage): Calls through to didReceiveWebResourceCacheManagerMessage.
(WebKit::WebResourceCacheManager::getCacheOrigins): Gets a list of origins with cache entries from the memory
    cache, and puts them into a vector to send to the UI process.
(WebKit::WebResourceCacheManager::deleteCacheForOrigin): Calls through to memoryCache to delete all cache entries
    from a given origin.
(WebKit::WebResourceCacheManager::deleteAllCache):
* WebProcess/MemoryCache/WebResourceCacheManager.h: Added.
* WebProcess/MemoryCache/WebResourceCacheManager.messages.in: Added.

* WebProcess/WebProcess.cpp:
(WebKit::WebProcess::didReceiveMessage):
(WebKit::WebProcess::clearResourceCaches): Tell the memory cache to evict its resources. This was done on WebKit1,
    but not WebKit2.
* WebProcess/WebProcess.h:

* WebKit2.xcodeproj/project.pbxproj: Added new files.
* win/WebKit2.vcproj: Ditto.
* win/WebKit2Common.vsprops: Added new include directory.
* win/WebKit2Generated.make: Added new header.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@78848 268f45cc-cd09-0410-ab3c-d52691b4dbfc
33 files changed:
Source/WebCore/ChangeLog
Source/WebCore/WebCore.exp.in
Source/WebCore/loader/cache/MemoryCache.cpp
Source/WebCore/loader/cache/MemoryCache.h
Source/WebKit2/ChangeLog
Source/WebKit2/DerivedSources.make
Source/WebKit2/DerivedSources.pro
Source/WebKit2/Platform/CoreIPC/MessageID.h
Source/WebKit2/Shared/API/c/WKBase.h
Source/WebKit2/Shared/APIObject.h
Source/WebKit2/Shared/SecurityOriginData.cpp [new file with mode: 0644]
Source/WebKit2/Shared/SecurityOriginData.h [new file with mode: 0644]
Source/WebKit2/UIProcess/API/C/WKAPICast.h
Source/WebKit2/UIProcess/API/C/WKContext.cpp
Source/WebKit2/UIProcess/API/C/WKContext.h
Source/WebKit2/UIProcess/API/C/WKResourceCacheManager.cpp [new file with mode: 0644]
Source/WebKit2/UIProcess/API/C/WKResourceCacheManager.h [new file with mode: 0644]
Source/WebKit2/UIProcess/WebContext.cpp
Source/WebKit2/UIProcess/WebContext.h
Source/WebKit2/UIProcess/WebProcessProxy.cpp
Source/WebKit2/UIProcess/WebResourceCacheManagerProxy.cpp [new file with mode: 0644]
Source/WebKit2/UIProcess/WebResourceCacheManagerProxy.h [new file with mode: 0644]
Source/WebKit2/UIProcess/WebResourceCacheManagerProxy.messages.in [new file with mode: 0644]
Source/WebKit2/WebKit2.pro
Source/WebKit2/WebKit2.xcodeproj/project.pbxproj
Source/WebKit2/WebProcess/ResourceCache/WebResourceCacheManager.cpp [new file with mode: 0644]
Source/WebKit2/WebProcess/ResourceCache/WebResourceCacheManager.h [new file with mode: 0644]
Source/WebKit2/WebProcess/ResourceCache/WebResourceCacheManager.messages.in [new file with mode: 0644]
Source/WebKit2/WebProcess/WebProcess.cpp
Source/WebKit2/WebProcess/WebProcess.h
Source/WebKit2/win/WebKit2.vcproj
Source/WebKit2/win/WebKit2Common.vsprops
Source/WebKit2/win/WebKit2Generated.make