summaryrefslogtreecommitdiffstats
path: root/WebKit/android/jni/WebCoreFrameBridge.cpp
diff options
context:
space:
mode:
authorSteve Block <steveblock@google.com>2010-10-04 17:11:19 +0100
committerSteve Block <steveblock@google.com>2010-10-06 16:53:03 +0100
commitab94c4fa344a138877ccfc89d7267e72837b34ae (patch)
treed1db36aa4e46df7d0f370bfcbef9446c006a9b8e /WebKit/android/jni/WebCoreFrameBridge.cpp
parent08817161ae6caddd24794dfd675db28cff0a6f48 (diff)
downloadexternal_webkit-ab94c4fa344a138877ccfc89d7267e72837b34ae.zip
external_webkit-ab94c4fa344a138877ccfc89d7267e72837b34ae.tar.gz
external_webkit-ab94c4fa344a138877ccfc89d7267e72837b34ae.tar.bz2
Hook up WebView.clearCache() for the Chromium HTTP stack
Bug: 2999397 Change-Id: If104a32fa2fd56cf60fdd37a4193a0ec4e0065e2
Diffstat (limited to 'WebKit/android/jni/WebCoreFrameBridge.cpp')
-rw-r--r--WebKit/android/jni/WebCoreFrameBridge.cpp44
1 files changed, 30 insertions, 14 deletions
diff --git a/WebKit/android/jni/WebCoreFrameBridge.cpp b/WebKit/android/jni/WebCoreFrameBridge.cpp
index d89f965..f1de0c9 100644
--- a/WebKit/android/jni/WebCoreFrameBridge.cpp
+++ b/WebKit/android/jni/WebCoreFrameBridge.cpp
@@ -78,6 +78,7 @@
#include "StringBuilder.h"
#include "SubstituteData.h"
#include "UserGestureIndicator.h"
+#include "WebCache.h"
#include "WebCoreJni.h"
#include "WebCoreResourceLoader.h"
#include "WebHistory.h"
@@ -1552,19 +1553,8 @@ static jboolean CacheDisabled(JNIEnv *env, jobject obj)
return WebCore::cache()->disabled();
}
-static void ClearCache(JNIEnv *env, jobject obj)
+static void ClearWebCoreCache()
{
-#ifdef ANDROID_INSTRUMENT
- TimeCounterAuto counter(TimeCounter::NativeCallbackTimeCounter);
-#if USE(JSC)
- JSC::JSLock lock(false);
- JSC::Heap::Statistics jsHeapStatistics = WebCore::JSDOMWindow::commonJSGlobalData()->heap.statistics();
- LOGD("About to gc and JavaScript heap size is %d and has %d bytes free",
- jsHeapStatistics.size, jsHeapStatistics.free);
-#endif // USE(JSC)
- LOGD("About to clear cache and current cache has %d bytes live and %d bytes dead",
- cache()->getLiveSize(), cache()->getDeadSize());
-#endif // ANDROID_INSTRUMENT
if (!WebCore::cache()->disabled()) {
// Disabling the cache will remove all resources from the cache. They may
// still live on if they are referenced by some Web page though.
@@ -1578,13 +1568,39 @@ static void ClearCache(JNIEnv *env, jobject obj)
WebCore::pageCache()->setCapacity(0);
WebCore::pageCache()->releaseAutoreleasedPagesNow();
WebCore::pageCache()->setCapacity(pageCapacity);
+}
+
+static void ClearWebViewCache()
+{
+#if USE(CHROME_NETWORK_STACK)
+ WebCache::clear();
+#else
+ // The Android network stack provides a WebView cache in CacheManager.java.
+ // Clearing this is handled entirely Java-side.
+#endif
+}
-#if USE(JSC)
+static void ClearCache(JNIEnv *env, jobject obj)
+{
+#ifdef ANDROID_INSTRUMENT
+ TimeCounterAuto counter(TimeCounter::NativeCallbackTimeCounter);
+#if USE(JSC)
+ JSC::JSLock lock(false);
+ JSC::Heap::Statistics jsHeapStatistics = WebCore::JSDOMWindow::commonJSGlobalData()->heap.statistics();
+ LOGD("About to gc and JavaScript heap size is %d and has %d bytes free",
+ jsHeapStatistics.size, jsHeapStatistics.free);
+#endif // USE(JSC)
+ LOGD("About to clear cache and current cache has %d bytes live and %d bytes dead",
+ cache()->getLiveSize(), cache()->getDeadSize());
+#endif // ANDROID_INSTRUMENT
+ ClearWebCoreCache();
+ ClearWebViewCache();
+#if USE(JSC)
// force JavaScript to GC when clear cache
WebCore::gcController().garbageCollectSoon();
#elif USE(V8)
WebCore::Frame* pFrame = GET_NATIVE_FRAME(env, obj);
- pFrame->script()->lowMemoryNotification();
+ pFrame->script()->lowMemoryNotification();
#endif // USE(JSC)
}