WebCore:
authorandersca@apple.com <andersca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 12 May 2008 20:13:51 +0000 (20:13 +0000)
committerandersca@apple.com <andersca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 12 May 2008 20:13:51 +0000 (20:13 +0000)
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: https://svn.webkit.org/repository/webkit/trunk@33051 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebCore/ChangeLog
WebCore/WebCore.base.exp
WebCore/loader/appcache/ApplicationCache.cpp
WebCore/loader/appcache/ApplicationCache.h
WebCore/loader/appcache/ApplicationCacheGroup.cpp
WebCore/loader/appcache/ApplicationCacheGroup.h
WebCore/loader/appcache/ApplicationCacheResource.h
WebCore/loader/appcache/ApplicationCacheStorage.cpp
WebCore/loader/appcache/ApplicationCacheStorage.h
WebKit/mac/ChangeLog
WebKit/mac/WebView/WebView.mm

index cabd716..753838a 100644 (file)
@@ -1,5 +1,25 @@
 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.
 
         Don't throw an exception if the string passed in is an invalid URL.
index 09631b3..9751944 100644 (file)
@@ -394,6 +394,7 @@ __ZN7WebCore21reportThreadViolationEPKc
 __ZN7WebCore22createFragmentFromTextEPNS_5RangeERKNS_6StringE
 __ZN7WebCore22externalRepresentationEPNS_12RenderObjectE
 __ZN7WebCore23ApplicationCacheStorage17setCacheDirectoryERKNS_6StringE
+__ZN7WebCore23ApplicationCacheStorage5emptyEv
 __ZN7WebCore23ReplaceSelectionCommandC1EPNS_8DocumentEN3WTF10PassRefPtrINS_16DocumentFragmentEEEbbbbbNS_10EditActionE
 __ZN7WebCore23createFragmentFromNodesEPNS_8DocumentERKN3WTF6VectorIPNS_4NodeELm0EEE
 __ZN7WebCore24createFragmentFromMarkupEPNS_8DocumentERKNS_6StringES4_
index 58861c9..097a176 100644 (file)
@@ -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()
 {
index 4899e52..e536cbe 100644 (file)
@@ -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();
index 25703f1..7f24f0b 100644 (file)
@@ -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)
index bb30e3a..fb60dca 100644 (file)
@@ -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*);
index a0a721f..1d7b853 100644 (file)
@@ -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
index f6b7156..0462a81 100644 (file)
@@ -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;
index ece2d28..fb6597b 100644 (file)
@@ -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);
index f6e08d7..c6cb0d4 100644 (file)
@@ -1,5 +1,14 @@
 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.
 
         <rdar://problem/5774495> Make Unicode text input possible in Netscape-style plug-ins
index b916d42..d48e519 100644 (file)
@@ -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;
 }