From d531ae5ea94ec991d57dfa9cf8ab4de44ada92b8 Mon Sep 17 00:00:00 2001 From: Kristian Monsen Date: Tue, 21 Dec 2010 16:31:19 +0000 Subject: Adding a method to delete a WebCache This is needed so the cache doesn't survive when closing all private tabs. Change-Id: I52ffaf89f8794466f98370c289b9a646de0fdb59 --- WebKit/android/WebCoreSupport/WebCache.cpp | 7 +++++++ WebKit/android/WebCoreSupport/WebCache.h | 1 + WebKit/android/WebCoreSupport/WebRequestContext.cpp | 7 +++++-- 3 files changed, 13 insertions(+), 2 deletions(-) (limited to 'WebKit/android') diff --git a/WebKit/android/WebCoreSupport/WebCache.cpp b/WebKit/android/WebCoreSupport/WebCache.cpp index 602395d..c7a6a1d 100644 --- a/WebKit/android/WebCoreSupport/WebCache.cpp +++ b/WebKit/android/WebCoreSupport/WebCache.cpp @@ -80,6 +80,13 @@ WebCache* WebCache::get(bool isPrivateBrowsing) return instancePtr->get(); } +void WebCache::cleanup(bool isPrivateBrowsing) +{ + MutexLocker lock(instanceMutex); + scoped_refptr* instancePtr = instance(isPrivateBrowsing); + *instancePtr = 0; +} + WebCache::~WebCache() { // We currently leak the HostResolver object to avoid a crash. diff --git a/WebKit/android/WebCoreSupport/WebCache.h b/WebKit/android/WebCoreSupport/WebCache.h index a231eb8..50ad03c 100644 --- a/WebKit/android/WebCoreSupport/WebCache.h +++ b/WebKit/android/WebCoreSupport/WebCache.h @@ -41,6 +41,7 @@ public: ~WebCache(); void clear(); + static void cleanup(bool isPrivateBrowsing); net::HostResolver* hostResolver() { return m_hostResolver.get(); } net::HttpCache* cache() { return m_cache.get(); } net::ProxyConfigServiceAndroid* proxy() { return m_proxyConfigService; } diff --git a/WebKit/android/WebCoreSupport/WebRequestContext.cpp b/WebKit/android/WebCoreSupport/WebRequestContext.cpp index 99e44ec..e108e2a 100644 --- a/WebKit/android/WebCoreSupport/WebRequestContext.cpp +++ b/WebKit/android/WebCoreSupport/WebRequestContext.cpp @@ -52,6 +52,7 @@ WebRequestContext::WebRequestContext(bool isPrivateBrowsing) if (m_isPrivateBrowsing) { // Delete the old files if this is the first private browsing instance // They are probably leftovers from a power cycle + // We do not need to clear the cache as it is in memory only for private browsing if (!numPrivateBrowsingInstances) WebCookieJar::cleanup(true); numPrivateBrowsingInstances++; @@ -74,9 +75,11 @@ WebRequestContext::~WebRequestContext() if (m_isPrivateBrowsing) { numPrivateBrowsingInstances--; - // This is the last private browsing context, delete the cookies - if (!numPrivateBrowsingInstances) + // This is the last private browsing context, delete the cookies and cache + if (!numPrivateBrowsingInstances) { WebCookieJar::cleanup(true); + WebCache::cleanup(true); + } } } -- cgit v1.1