summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBen Murdoch <benm@google.com>2011-11-15 15:26:37 +0000
committerBen Murdoch <benm@google.com>2011-11-15 16:08:47 +0000
commit8d55fa6a7b44dd646774f089c2b88697d9d56096 (patch)
tree8bc2f6d46299bee1c9434ad58a9e6484d0c66f85 /Source
parent61a908361c8a96eeb70afdb5430e89845edb2bdd (diff)
downloadexternal_webkit-8d55fa6a7b44dd646774f089c2b88697d9d56096.zip
external_webkit-8d55fa6a7b44dd646774f089c2b88697d9d56096.tar.gz
external_webkit-8d55fa6a7b44dd646774f089c2b88697d9d56096.tar.bz2
Fix CacheManager to correctly write CacheFiles to disk.
There are two problems with the CacheManager - 1. Need to null terminate the file path used for the cache file on disk. 2. A race condition between starting the background task to write the file and updating internal state variables. These were causing a CTS test to fail. Bug: 5619303 Change-Id: I61f06d50b7ef560ede2f1141fc51d92255d4efbd
Diffstat (limited to 'Source')
-rw-r--r--Source/WebKit/android/WebCoreSupport/CacheResult.cpp11
-rw-r--r--Source/WebKit/android/jni/CacheManager.cpp1
2 files changed, 6 insertions, 6 deletions
diff --git a/Source/WebKit/android/WebCoreSupport/CacheResult.cpp b/Source/WebKit/android/WebCoreSupport/CacheResult.cpp
index 5309c66..6710e49 100644
--- a/Source/WebKit/android/WebCoreSupport/CacheResult.cpp
+++ b/Source/WebKit/android/WebCoreSupport/CacheResult.cpp
@@ -134,11 +134,11 @@ bool CacheResult::writeToFile(const String& filePath) const
if (!thread)
return false;
- CacheResult* me = const_cast<CacheResult*>(this);
- thread->message_loop()->PostTask(FROM_HERE, NewRunnableMethod(me, &CacheResult::writeToFileImpl));
-
m_filePath = filePath.threadsafeCopy();
m_isAsyncOperationInProgress = true;
+
+ thread->message_loop()->PostTask(FROM_HERE, NewRunnableMethod(const_cast<CacheResult*>(this), &CacheResult::writeToFileImpl));
+
while (m_isAsyncOperationInProgress)
m_condition.wait(m_mutex);
@@ -213,10 +213,9 @@ HttpResponseHeaders* CacheResult::responseHeaders() const
if (!thread)
return 0;
- CacheResult* me = const_cast<CacheResult*>(this);
- thread->message_loop()->PostTask(FROM_HERE, NewRunnableMethod(me, &CacheResult::responseHeadersImpl));
-
m_isAsyncOperationInProgress = true;
+ thread->message_loop()->PostTask(FROM_HERE, NewRunnableMethod(const_cast<CacheResult*>(this), &CacheResult::responseHeadersImpl));
+
while (m_isAsyncOperationInProgress)
m_condition.wait(m_mutex);
diff --git a/Source/WebKit/android/jni/CacheManager.cpp b/Source/WebKit/android/jni/CacheManager.cpp
index 144b62a..f600d00 100644
--- a/Source/WebKit/android/jni/CacheManager.cpp
+++ b/Source/WebKit/android/jni/CacheManager.cpp
@@ -90,6 +90,7 @@ static jobject getCacheResult(JNIEnv* env, jobject, jstring url)
String urlWtfString = jstringToWtfString(env, url);
Vector<char> encodedUrl;
base64Encode(urlWtfString.utf8().data(), urlWtfString.length(), encodedUrl, false /*insertLFs*/);
+ encodedUrl.append('\0');
String filePath = pathByAppendingComponent(getCacheFileBaseDir(env), encodedUrl.data());
if (!result->writeToFile(filePath))
return 0;