Commit 8990786b authored by andersca@apple.com's avatar andersca@apple.com

WebCore:

2008-05-12  Anders Carlsson  <andersca@apple.com>

        Reviewed by Alexey.

        Add ApplicationCacheStorage::empty() method which will empty
        the application cache database.
        
        * WebCore.base.exp:
        * loader/appcache/ApplicationCache.cpp:
        (WebCore::ApplicationCache::clearStorageID):
        * loader/appcache/ApplicationCache.h:
        * loader/appcache/ApplicationCacheGroup.cpp:
        (WebCore::ApplicationCacheGroup::clearStorageID):
        * loader/appcache/ApplicationCacheGroup.h:
        * loader/appcache/ApplicationCacheResource.h:
        (WebCore::ApplicationCacheResource::clearStorageID):
        * loader/appcache/ApplicationCacheStorage.cpp:
        (WebCore::ApplicationCacheStorage::empty):
        * loader/appcache/ApplicationCacheStorage.h:

WebKit/mac:

2008-05-12  Anders Carlsson  <andersca@apple.com>

        Reviewed by Alexey.

        Empty the application cache when changing the cache model.
        
        * WebView/WebView.mm:
        (+[WebView _setCacheModel:]):



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@33051 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent e7ab2092
2008-05-12 Anders Carlsson <andersca@apple.com>
Reviewed by Alexey.
Add ApplicationCacheStorage::empty() method which will empty
the application cache database.
* WebCore.base.exp:
* loader/appcache/ApplicationCache.cpp:
(WebCore::ApplicationCache::clearStorageID):
* loader/appcache/ApplicationCache.h:
* loader/appcache/ApplicationCacheGroup.cpp:
(WebCore::ApplicationCacheGroup::clearStorageID):
* loader/appcache/ApplicationCacheGroup.h:
* loader/appcache/ApplicationCacheResource.h:
(WebCore::ApplicationCacheResource::clearStorageID):
* loader/appcache/ApplicationCacheStorage.cpp:
(WebCore::ApplicationCacheStorage::empty):
* loader/appcache/ApplicationCacheStorage.h:
2008-05-12 Anders Carlsson <andersca@apple.com>
Reviewed by John.
......@@ -394,6 +394,7 @@ __ZN7WebCore21reportThreadViolationEPKc
__ZN7WebCore22createFragmentFromTextEPNS_5RangeERKNS_6StringE
__ZN7WebCore22externalRepresentationEPNS_12RenderObjectE
__ZN7WebCore23ApplicationCacheStorage17setCacheDirectoryERKNS_6StringE
__ZN7WebCore23ApplicationCacheStorage5emptyEv
__ZN7WebCore23ReplaceSelectionCommandC1EPNS_8DocumentEN3WTF10PassRefPtrINS_16DocumentFragmentEEEbbbbbNS_10EditActionE
__ZN7WebCore23createFragmentFromNodesEPNS_8DocumentERKN3WTF6VectorIPNS_4NodeELm0EEE
__ZN7WebCore24createFragmentFromMarkupEPNS_8DocumentERKNS_6StringES4_
......
......@@ -166,6 +166,15 @@ bool ApplicationCache::isURLInOnlineWhitelist(const KURL& url)
return m_onlineWhitelist.contains(copy);
}
void ApplicationCache::clearStorageID()
{
m_storageID = 0;
ResourceMap::const_iterator end = m_resources.end();
for (ResourceMap::const_iterator it = m_resources.begin(); it != end; ++it)
it->second->clearStorageID();
}
#ifndef NDEBUG
void ApplicationCache::dump()
{
......
......@@ -81,7 +81,8 @@ public:
void setStorageID(unsigned storageID) { m_storageID = storageID; }
unsigned storageID() const { return m_storageID; }
void clearStorageID();
static bool requestIsHTTPOrHTTPSGet(const ResourceRequest&);
private:
ApplicationCache();
......
......@@ -615,6 +615,16 @@ void ApplicationCacheGroup::callListeners(ListenerFunction listenerFunction, con
}
}
void ApplicationCacheGroup::clearStorageID()
{
m_storageID = 0;
HashSet<ApplicationCache*>::const_iterator end = m_caches.end();
for (HashSet<ApplicationCache*>::const_iterator it = m_caches.begin(); it != end; ++it)
(*it)->clearStorageID();
}
}
#endif // ENABLE(OFFLINE_WEB_APPLICATIONS)
......@@ -64,6 +64,7 @@ public:
void setStorageID(unsigned storageID) { m_storageID = storageID; }
unsigned storageID() const { return m_storageID; }
void clearStorageID();
void update(Frame*);
void cacheDestroyed(ApplicationCache*);
......
......@@ -54,7 +54,8 @@ public:
void setStorageID(unsigned storageID) { m_storageID = storageID; }
unsigned storageID() const { return m_storageID; }
void clearStorageID() { m_storageID = 0; }
#ifndef NDEBUG
static void dumpType(unsigned type);
#endif
......
......@@ -533,6 +533,26 @@ void ApplicationCacheStorage::remove(ApplicationCache* cache)
executeStatement(statement);
}
void ApplicationCacheStorage::empty()
{
openDatabase(false);
if (!m_database.isOpen())
return;
// Clear cache groups, caches and cache resources.
executeSQLCommand("DELETE FROM CacheGroups");
executeSQLCommand("DELETE FROM Caches");
executeSQLCommand("DELETE FROM CacheResources");
// Clear the storage IDs for the caches in memory.
// The caches will still work, but cached resources will not be saved to disk
// until a cache update process has been initiated.
CacheGroupMap::const_iterator end = m_cachesInMemory.end();
for (CacheGroupMap::const_iterator it = m_cachesInMemory.begin(); it != end; ++it)
it->second->clearStorageID();
}
ApplicationCacheStorage& cacheStorage()
{
static ApplicationCacheStorage storage;
......
......@@ -54,6 +54,8 @@ public:
void store(ApplicationCacheResource*, ApplicationCache*);
void remove(ApplicationCache*);
void empty();
private:
PassRefPtr<ApplicationCache> loadCache(unsigned storageID);
ApplicationCacheGroup* loadCacheGroup(const KURL& manifestURL);
......
2008-05-12 Anders Carlsson <andersca@apple.com>
Reviewed by Alexey.
Empty the application cache when changing the cache model.
* WebView/WebView.mm:
(+[WebView _setCacheModel:]):
2008-05-12 Anders Carlsson <andersca@apple.com>
Reviewed by Oliver.
......
......@@ -4066,6 +4066,9 @@ static WebFrameView *containingFrameView(NSView *view)
[nsurlCache setMemoryCapacity:nsurlCacheMemoryCapacity];
[nsurlCache setDiskCapacity:nsurlCacheDiskCapacity];
// Empty the application cache.
cacheStorage().empty();
s_cacheModel = cacheModel;
s_didSetCacheModel = YES;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment