// set the cache policy correctly, copied from
// network/mac/ResourceHandleMac.mm
request.setCachePolicy(ReturnCacheDataDontLoad);
- return WebCoreResourceLoader::willLoadFromCache(request.url());
+ FormData* formData = request.httpBody();
+ return WebCoreResourceLoader::willLoadFromCache(request.url(), formData ? formData->identifier() : 0);
}
bool ResourceHandle::loadsBlocked()
#include <config.h>
#include <wtf/Platform.h>
+#include <wtf/CurrentTime.h>
#include "android_graphics.h"
#include "Arena.h"
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",
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);
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);
}
* 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);
"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");
/**
* 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);
// 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
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;