diff options
-rw-r--r-- | WebKit/android/WebCoreSupport/ChromeClientAndroid.cpp | 63 | ||||
-rw-r--r-- | WebKit/android/jni/WebViewCore.cpp | 24 | ||||
-rw-r--r-- | WebKit/android/jni/WebViewCore.h | 9 |
3 files changed, 61 insertions, 35 deletions
diff --git a/WebKit/android/WebCoreSupport/ChromeClientAndroid.cpp b/WebKit/android/WebCoreSupport/ChromeClientAndroid.cpp index 71d9f59..a0f3f8d 100644 --- a/WebKit/android/WebCoreSupport/ChromeClientAndroid.cpp +++ b/WebKit/android/WebCoreSupport/ChromeClientAndroid.cpp @@ -27,6 +27,7 @@ #include "config.h" +#include "ApplicationCacheStorage.h" #include "ChromeClientAndroid.h" #include "CString.h" #include "DatabaseTracker.h" @@ -280,42 +281,48 @@ void ChromeClientAndroid::exceededDatabaseQuota(Frame* frame, const String& name { SecurityOrigin* origin = frame->document()->securityOrigin(); - // TODO: This default quota value should be pulled from the web browser - // settings. For now, settle for 5 meg. - const unsigned long long defaultQuota = 1024 * 1024 * 5; - + // We want to wait on a new quota from the UI thread. Reset the m_newQuota variable to represent we haven't received a new quota. + m_newQuota = -1; + // This origin is being tracked and has exceeded it's quota. Call into + // the Java side of things to inform the user. + unsigned long long currentQuota = 0; if (WebCore::DatabaseTracker::tracker().hasEntryForOrigin(origin)) { - // We want to wait on a new quota from the UI thread. Reset the m_newQuota variable to represent we haven't received a new quota. - m_newQuota = -1; - - // This origin is being tracked and has exceeded it's quota. Call into - // the Java side of things to inform the user. - const unsigned long long currentQuota = WebCore::DatabaseTracker::tracker().quotaForOrigin(origin); - android::WebViewCore::getWebViewCore(frame->view())->exceededDatabaseQuota(frame->document()->documentURI(), name, currentQuota); - - // We've sent notification to the browser so now wait for it to come back. - m_quotaThreadLock.lock(); - while (m_newQuota == -1) { - m_quotaThreadCondition.wait(m_quotaThreadLock); - } - m_quotaThreadLock.unlock(); - - // Update the DatabaseTracker with the new quota value (if the user declined - // new quota, this may equal the old quota) - DatabaseTracker::tracker().setQuota(origin, m_newQuota); - } else { - // This origin is not being tracked, so set it's entry in the Origins table - // to the default quota, casusing it to be tracked from now on. - DatabaseTracker::tracker().setQuota(origin, defaultQuota); + currentQuota = WebCore::DatabaseTracker::tracker().quotaForOrigin(origin); + } + android::WebViewCore::getWebViewCore(frame->view())->exceededDatabaseQuota(frame->document()->documentURI(), name, currentQuota); + + // We've sent notification to the browser so now wait for it to come back. + m_quotaThreadLock.lock(); + while (m_newQuota == -1) { + m_quotaThreadCondition.wait(m_quotaThreadLock); } + m_quotaThreadLock.unlock(); + + // Update the DatabaseTracker with the new quota value (if the user declined + // new quota, this may equal the old quota) + DatabaseTracker::tracker().setQuota(origin, m_newQuota); } #endif #if ENABLE(OFFLINE_WEB_APPLICATIONS) void ChromeClientAndroid::reachedMaxAppCacheSize(int64_t spaceNeeded) { - // FIXME: Free some space. - notImplemented(); + Page* page = m_webFrame->page(); + Frame* mainFrame = page->mainFrame(); + FrameView* view = mainFrame->view(); + android::WebViewCore::getWebViewCore(view)->reachedMaxAppCacheSize(spaceNeeded); + + // We've sent notification to the browser so now wait for it to come back. + m_newQuota = -1; + m_quotaThreadLock.lock(); + while (m_newQuota == -1) { + m_quotaThreadCondition.wait(m_quotaThreadLock); + } + m_quotaThreadLock.unlock(); + if (m_newQuota > 0) { + WebCore::cacheStorage().setMaximumSize(m_newQuota); + // Now the app cache will retry the saving the previously failed cache. + } } #endif diff --git a/WebKit/android/jni/WebViewCore.cpp b/WebKit/android/jni/WebViewCore.cpp index 45e1434..f46759a 100644 --- a/WebKit/android/jni/WebViewCore.cpp +++ b/WebKit/android/jni/WebViewCore.cpp @@ -177,6 +177,7 @@ struct WebViewCore::JavaGlue { jmethodID m_needTouchEvents; jmethodID m_requestKeyboard; jmethodID m_exceededDatabaseQuota; + jmethodID m_reachedMaxAppCacheSize; jmethodID m_addMessageToConsole; jmethodID m_createSurface; jmethodID m_destroySurface; @@ -247,6 +248,7 @@ WebViewCore::WebViewCore(JNIEnv* env, jobject javaWebViewCore, WebCore::Frame* m m_javaGlue->m_needTouchEvents = GetJMethod(env, clazz, "needTouchEvents", "(Z)V"); m_javaGlue->m_requestKeyboard = GetJMethod(env, clazz, "requestKeyboard", "(Z)V"); m_javaGlue->m_exceededDatabaseQuota = GetJMethod(env, clazz, "exceededDatabaseQuota", "(Ljava/lang/String;Ljava/lang/String;J)V"); + m_javaGlue->m_reachedMaxAppCacheSize = GetJMethod(env, clazz, "reachedMaxAppCacheSize", "(J)V"); m_javaGlue->m_addMessageToConsole = GetJMethod(env, clazz, "addMessageToConsole", "(Ljava/lang/String;ILjava/lang/String;)V"); m_javaGlue->m_createSurface = GetJMethod(env, clazz, "createSurface", "(I)Landroid/view/SurfaceView;"); m_javaGlue->m_destroySurface = GetJMethod(env, clazz, "destroySurface", "(Landroid/view/SurfaceView;)V"); @@ -1941,6 +1943,15 @@ void WebViewCore::exceededDatabaseQuota(const WebCore::String& url, const WebCor #endif } +void WebViewCore::reachedMaxAppCacheSize(const unsigned long long spaceNeeded) +{ +#if ENABLE(OFFLINE_WEB_APPLICATIONS) + JNIEnv* env = JSC::Bindings::getJNIEnv(); + env->CallVoidMethod(m_javaGlue->object(env).get(), m_javaGlue->m_reachedMaxAppCacheSize, spaceNeeded); + checkException(env); +#endif +} + bool WebViewCore::jsConfirm(const WebCore::String& url, const WebCore::String& text) { JNIEnv* env = JSC::Bindings::getJNIEnv(); @@ -2530,10 +2541,11 @@ static void SetJsFlags(JNIEnv *env, jobject obj, jstring flags) } -// Called from the Java side to set a new quota for the origin in response. -// to a notification that the original quota was exceeded. -static void SetDatabaseQuota(JNIEnv* env, jobject obj, jlong quota) { -#if ENABLE(DATABASE) +// Called from the Java side to set a new quota for the origin or new appcache +// max size in response to a notification that the original quota was exceeded or +// that the appcache has reached its maximum size. +static void SetNewStorageLimit(JNIEnv* env, jobject obj, jlong quota) { +#if ENABLE(DATABASE) || ENABLE(OFFLINE_WEB_APPLICATIONS) WebViewCore* viewImpl = GET_NATIVE_VIEW(env, obj); Frame* frame = viewImpl->mainFrame(); @@ -2722,8 +2734,8 @@ static JNINativeMethod gJavaWebViewCoreMethods[] = { (void*) DumpRenderTree }, { "nativeDumpNavTree", "()V", (void*) DumpNavTree }, - { "nativeSetDatabaseQuota", "(J)V", - (void*) SetDatabaseQuota }, + { "nativeSetNewStorageLimit", "(J)V", + (void*) SetNewStorageLimit }, { "nativeSurfaceChanged", "(IIIII)V", (void*) SurfaceChanged }, { "nativePause", "()V", (void*) Pause }, diff --git a/WebKit/android/jni/WebViewCore.h b/WebKit/android/jni/WebViewCore.h index dba644c..8fbe934 100644 --- a/WebKit/android/jni/WebViewCore.h +++ b/WebKit/android/jni/WebViewCore.h @@ -182,7 +182,7 @@ namespace android { bool jsInterrupt(); /** - * Tell the Java side that the origin has exceeded it's database quota. + * Tell the Java side that the origin has exceeded its database quota. * @param url The URL of the page that caused the quota overflow * @param databaseIdentifier the id of the database that caused the * quota overflow. @@ -192,6 +192,13 @@ namespace android { const WebCore::String& databaseIdentifier, const unsigned long long currentQuota); + /** + * Tell the Java side that the appcache has exceeded its max size. + * @param spaceNeeded is the amount of disk space that would be needed + * in order for the last appcache operation to succeed. + */ + void reachedMaxAppCacheSize(const unsigned long long spaceNeeded); + void addMessageToConsole(const String& message, unsigned int lineNumber, const String& sourceID); // |