summaryrefslogtreecommitdiffstats
path: root/WebKit/android/jni
diff options
context:
space:
mode:
authorGrace Kloba <klobag@google.com>2009-11-08 18:45:44 -0800
committerGrace Kloba <klobag@google.com>2009-11-08 18:45:44 -0800
commitef7b176b34c6a1fe082a87dd17523e47737c1e19 (patch)
treeb54458af83b948cd33d08b960389b48eb47a101b /WebKit/android/jni
parentde2098fbe71502df93eb3228ceaabd698aef0542 (diff)
downloadexternal_webkit-ef7b176b34c6a1fe082a87dd17523e47737c1e19.zip
external_webkit-ef7b176b34c6a1fe082a87dd17523e47737c1e19.tar.gz
external_webkit-ef7b176b34c6a1fe082a87dd17523e47737c1e19.tar.bz2
Add/expose postdata identifier so that when we cache
the post data, we can distinguish them. add identifier to postUrl(). add identifier when we check whether the post data can be loaded from cache. Fix http://b/issue?id=1980031
Diffstat (limited to 'WebKit/android/jni')
-rw-r--r--WebKit/android/jni/WebCoreFrameBridge.cpp12
-rw-r--r--WebKit/android/jni/WebCoreResourceLoader.cpp6
-rw-r--r--WebKit/android/jni/WebCoreResourceLoader.h2
-rw-r--r--WebKit/android/jni/WebHistory.cpp16
4 files changed, 27 insertions, 9 deletions
diff --git a/WebKit/android/jni/WebCoreFrameBridge.cpp b/WebKit/android/jni/WebCoreFrameBridge.cpp
index 0675bcb..541e878 100644
--- a/WebKit/android/jni/WebCoreFrameBridge.cpp
+++ b/WebKit/android/jni/WebCoreFrameBridge.cpp
@@ -28,6 +28,7 @@
#include <config.h>
#include <wtf/Platform.h>
+#include <wtf/CurrentTime.h>
#include "android_graphics.h"
#include "Arena.h"
@@ -169,7 +170,7 @@ WebFrame::WebFrame(JNIEnv* env, jobject obj, jobject historyList, WebCore::Page*
mJavaFrame->mObj = adoptGlobalRef(env, obj);
mJavaFrame->mHistoryList = adoptGlobalRef(env, historyList);
mJavaFrame->mStartLoadingResource = env->GetMethodID(clazz, "startLoadingResource",
- "(ILjava/lang/String;Ljava/lang/String;Ljava/util/HashMap;[BIZ)Landroid/webkit/LoadListener;");
+ "(ILjava/lang/String;Ljava/lang/String;Ljava/util/HashMap;[BJIZ)Landroid/webkit/LoadListener;");
mJavaFrame->mLoadStarted = env->GetMethodID(clazz, "loadStarted",
"(Ljava/lang/String;Landroid/graphics/Bitmap;IZ)V");
mJavaFrame->mTransitionToCommitted = env->GetMethodID(clazz, "transitionToCommitted",
@@ -441,7 +442,8 @@ WebFrame::startLoadingResource(WebCore::ResourceHandle* loader,
jobject jLoadListener =
env->CallObjectMethod(obj.get(), mJavaFrame->mStartLoadingResource,
(int)loader, jUrlStr, jMethodStr, jHeaderMap,
- jPostDataStr, cacheMode, synchronous);
+ jPostDataStr, formdata ? formdata->identifier(): 0,
+ cacheMode, synchronous);
env->DeleteLocalRef(jUrlStr);
env->DeleteLocalRef(jMethodStr);
@@ -1000,7 +1002,11 @@ static void PostUrl(JNIEnv *env, jobject obj, jstring url, jbyteArray postData)
if (postData) {
jsize size = env->GetArrayLength(postData);
jbyte* bytes = env->GetByteArrayElements(postData, NULL);
- request.setHTTPBody(WebCore::FormData::create((const void*)bytes, size));
+ RefPtr<FormData> formData = FormData::create((const void*)bytes, size);
+ // the identifier uses the same logic as generateFormDataIdentifier() in
+ // HTMLFormElement.cpp
+ formData->setIdentifier(static_cast<int64_t>(WTF::currentTime() * 1000000.0));
+ request.setHTTPBody(formData);
env->ReleaseByteArrayElements(postData, bytes, 0);
}
diff --git a/WebKit/android/jni/WebCoreResourceLoader.cpp b/WebKit/android/jni/WebCoreResourceLoader.cpp
index 1b40eb6..0891323 100644
--- a/WebKit/android/jni/WebCoreResourceLoader.cpp
+++ b/WebKit/android/jni/WebCoreResourceLoader.cpp
@@ -100,14 +100,14 @@ void WebCoreResourceLoader::downloadFile()
* the cache. This may be slow, but is only used during a navigation to
* a POST response.
*/
-bool WebCoreResourceLoader::willLoadFromCache(const WebCore::KURL& url)
+bool WebCoreResourceLoader::willLoadFromCache(const WebCore::KURL& url, int64_t identifier)
{
JNIEnv* env = JSC::Bindings::getJNIEnv();
WebCore::String urlStr = url.string();
jstring jUrlStr = env->NewString(urlStr.characters(), urlStr.length());
jclass resourceLoader = env->FindClass("android/webkit/LoadListener");
bool val = env->CallStaticBooleanMethod(resourceLoader,
- gResourceLoader.mWillLoadFromCacheMethodID, jUrlStr);
+ gResourceLoader.mWillLoadFromCacheMethodID, jUrlStr, identifier);
checkException(env);
env->DeleteLocalRef(jUrlStr);
@@ -318,7 +318,7 @@ int register_resource_loader(JNIEnv* env)
"Could not find method downloadFile on LoadListener");
gResourceLoader.mWillLoadFromCacheMethodID =
- env->GetStaticMethodID(resourceLoader, "willLoadFromCache", "(Ljava/lang/String;)Z");
+ env->GetStaticMethodID(resourceLoader, "willLoadFromCache", "(Ljava/lang/String;J)Z");
LOG_FATAL_IF(gResourceLoader.mWillLoadFromCacheMethodID == NULL,
"Could not find static method willLoadFromCache on LoadListener");
diff --git a/WebKit/android/jni/WebCoreResourceLoader.h b/WebKit/android/jni/WebCoreResourceLoader.h
index 60c0d0e..7ea1107 100644
--- a/WebKit/android/jni/WebCoreResourceLoader.h
+++ b/WebKit/android/jni/WebCoreResourceLoader.h
@@ -53,7 +53,7 @@ public:
/**
* Call to java to find out if this URL is in the cache
*/
- static bool willLoadFromCache(const WebCore::KURL& url);
+ static bool willLoadFromCache(const WebCore::KURL& url, int64_t identifier);
// Native jni functions
static void SetResponseHeader(JNIEnv*, jobject, jint, jstring, jstring);
diff --git a/WebKit/android/jni/WebHistory.cpp b/WebKit/android/jni/WebHistory.cpp
index d7aacfb..bed0e84 100644
--- a/WebKit/android/jni/WebHistory.cpp
+++ b/WebKit/android/jni/WebHistory.cpp
@@ -420,9 +420,12 @@ static void write_item(WTF::Vector<char>& v, WebCore::HistoryItem* item)
// Form data
const WebCore::FormData* formData = item->formData();
- if (formData)
+ if (formData) {
write_string(v, formData->flattenToString());
- else
+ // save the identifier as it is not included in the flatten data
+ int64_t id = formData->identifier();
+ v.append((char*)&id, sizeof(int64_t));
+ } else
write_string(v, WebCore::String()); // Empty constructor does not allocate a buffer.
// Target
@@ -573,6 +576,15 @@ static bool read_item_recursive(WebCore::HistoryItem* newItem,
else
return false;
data += l;
+ // Read the identifier
+ {
+ int64_t id;
+ int size = (int)sizeof(int64_t);
+ memcpy(&id, data, size);
+ data += size;
+ if (id)
+ formData->setIdentifier(id);
+ }
}
if (end - data < sizeofUnsigned)
return false;