#include "config.h"
+#include "ApplicationCacheStorage.h"
#include "ChromeClientAndroid.h"
#include "CString.h"
#include "DatabaseTracker.h"
{
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
jmethodID m_needTouchEvents;
jmethodID m_requestKeyboard;
jmethodID m_exceededDatabaseQuota;
+ jmethodID m_reachedMaxAppCacheSize;
jmethodID m_addMessageToConsole;
jmethodID m_createSurface;
jmethodID m_destroySurface;
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");
#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();
}
-// 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();
(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 },
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.
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);
//