diff options
author | Android (Google) Code Review <android-gerrit@google.com> | 2009-07-22 00:44:49 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2009-07-22 00:44:49 -0700 |
commit | 769e21eaac67b6b46de0e2cafc31f61fb990179e (patch) | |
tree | 408b9797bcffb509b81950bb1222dc321a1aca99 /WebKit/android | |
parent | 360a1ec8de320b6633c2fd5e5cb474d87de6a4b3 (diff) | |
parent | 32e333a0ebf3f651ae55805a3f1b8d263878b42f (diff) | |
download | external_webkit-769e21eaac67b6b46de0e2cafc31f61fb990179e.zip external_webkit-769e21eaac67b6b46de0e2cafc31f61fb990179e.tar.gz external_webkit-769e21eaac67b6b46de0e2cafc31f61fb990179e.tar.bz2 |
Merge change 8031
* changes:
wire the appcache to the HTML5 UI
Diffstat (limited to 'WebKit/android')
-rw-r--r-- | WebKit/android/jni/WebStorage.cpp | 62 |
1 files changed, 50 insertions, 12 deletions
diff --git a/WebKit/android/jni/WebStorage.cpp b/WebKit/android/jni/WebStorage.cpp index f625939..aa83892 100644 --- a/WebKit/android/jni/WebStorage.cpp +++ b/WebKit/android/jni/WebStorage.cpp @@ -29,6 +29,7 @@ #include <JNIHelp.h> +#include <WebCore/loader/appcache/ApplicationCacheStorage.h> #include <WebCore/page/SecurityOrigin.h> #include <WebCore/storage/DatabaseTracker.h> @@ -43,21 +44,31 @@ static jobject GetOrigins(JNIEnv* env, jobject obj) { Vector<RefPtr<WebCore::SecurityOrigin> > coreOrigins; WebCore::DatabaseTracker::tracker().origins(coreOrigins); + Vector<WebCore::KURL> manifestUrls; + if (WebCore::cacheStorage().manifestURLs(&manifestUrls)) { + int size = manifestUrls.size(); + for (int i = 0; i < size; ++i) { + RefPtr<WebCore::SecurityOrigin> manifestOrigin = WebCore::SecurityOrigin::create(manifestUrls[i]); + if (manifestOrigin.get() == 0) + continue; + coreOrigins.append(manifestOrigin); + } + } - jclass vectorClass = env->FindClass("java/util/Vector"); - jmethodID cid = env->GetMethodID(vectorClass, "<init>", "()V"); - jmethodID mid = env->GetMethodID(vectorClass, "addElement", "(Ljava/lang/Object;)V"); - jobject vector = env->NewObject(vectorClass, cid); + jclass setClass = env->FindClass("java/util/HashSet"); + jmethodID cid = env->GetMethodID(setClass, "<init>", "()V"); + jmethodID mid = env->GetMethodID(setClass, "add", "(Ljava/lang/Object;)Z"); + jobject set = env->NewObject(setClass, cid); for (unsigned i = 0; i < coreOrigins.size(); ++i) { WebCore::SecurityOrigin* origin = coreOrigins[i].get(); WebCore::String url = origin->toString(); jstring jUrl = env->NewString(url.characters(), url.length()); - env->CallVoidMethod(vector, mid, jUrl); + env->CallBooleanMethod(set, mid, jUrl); env->DeleteLocalRef(jUrl); } - return vector; + return set; } static unsigned long long GetQuotaForOrigin(JNIEnv* env, jobject obj, jstring origin) @@ -72,8 +83,22 @@ static unsigned long long GetUsageForOrigin(JNIEnv* env, jobject obj, jstring or { WebCore::String originStr = to_string(env, origin); RefPtr<WebCore::SecurityOrigin> securityOrigin = WebCore::SecurityOrigin::createFromString(originStr); - unsigned long long quota = WebCore::DatabaseTracker::tracker().usageForOrigin(securityOrigin.get()); - return quota; + unsigned long long usage = WebCore::DatabaseTracker::tracker().usageForOrigin(securityOrigin.get()); + Vector<WebCore::KURL> manifestUrls; + if (!WebCore::cacheStorage().manifestURLs(&manifestUrls)) + return usage; + int size = manifestUrls.size(); + for (int i = 0; i < size; ++i) { + RefPtr<WebCore::SecurityOrigin> manifestOrigin = WebCore::SecurityOrigin::create(manifestUrls[i]); + if (manifestOrigin.get() == 0) + continue; + if (manifestOrigin->isSameSchemeHostPort(securityOrigin.get())) { + int64_t size = 0; + WebCore::cacheStorage().cacheGroupSize(manifestUrls[i].string(), &size); + usage += size; + } + } + return usage; } static void SetQuotaForOrigin(JNIEnv* env, jobject obj, jstring origin, unsigned long long quota) @@ -88,18 +113,31 @@ static void DeleteOrigin(JNIEnv* env, jobject obj, jstring origin) WebCore::String originStr = to_string(env, origin); RefPtr<WebCore::SecurityOrigin> securityOrigin = WebCore::SecurityOrigin::createFromString(originStr); WebCore::DatabaseTracker::tracker().deleteOrigin(securityOrigin.get()); + + Vector<WebCore::KURL> manifestUrls; + if (!WebCore::cacheStorage().manifestURLs(&manifestUrls)) + return; + int size = manifestUrls.size(); + for (int i = 0; i < size; ++i) { + RefPtr<WebCore::SecurityOrigin> manifestOrigin = WebCore::SecurityOrigin::create(manifestUrls[i]); + if (manifestOrigin.get() == 0) + continue; + if (manifestOrigin->isSameSchemeHostPort(securityOrigin.get())) + WebCore::cacheStorage().deleteCacheGroup(manifestUrls[i]); + } } -static void DeleteAllDatabases(JNIEnv* env, jobject obj) +static void DeleteAllData(JNIEnv* env, jobject obj) { WebCore::DatabaseTracker::tracker().deleteAllDatabases(); + WebCore::cacheStorage().empty(); } /* * JNI registration */ static JNINativeMethod gWebStorageMethods[] = { - { "nativeGetOrigins", "()Ljava/util/Vector;", + { "nativeGetOrigins", "()Ljava/util/Set;", (void*) GetOrigins }, { "nativeGetUsageForOrigin", "(Ljava/lang/String;)J", (void*) GetUsageForOrigin }, @@ -109,8 +147,8 @@ static JNINativeMethod gWebStorageMethods[] = { (void*) SetQuotaForOrigin }, { "nativeDeleteOrigin", "(Ljava/lang/String;)V", (void*) DeleteOrigin }, - { "nativeDeleteAllDatabases", "()V", - (void*) DeleteAllDatabases } + { "nativeDeleteAllData", "()V", + (void*) DeleteAllData } }; int register_webstorage(JNIEnv* env) |