summaryrefslogtreecommitdiffstats
path: root/WebKit/android/WebCoreSupport
diff options
context:
space:
mode:
Diffstat (limited to 'WebKit/android/WebCoreSupport')
-rw-r--r--WebKit/android/WebCoreSupport/WebRequest.cpp10
-rw-r--r--WebKit/android/WebCoreSupport/WebRequest.h3
-rw-r--r--WebKit/android/WebCoreSupport/WebUrlLoaderClient.cpp13
3 files changed, 19 insertions, 7 deletions
diff --git a/WebKit/android/WebCoreSupport/WebRequest.cpp b/WebKit/android/WebCoreSupport/WebRequest.cpp
index da84126..9e464c1 100644
--- a/WebKit/android/WebCoreSupport/WebRequest.cpp
+++ b/WebKit/android/WebCoreSupport/WebRequest.cpp
@@ -152,7 +152,13 @@ void WebRequest::appendBytesToUpload(WTF::Vector<char>* data)
delete data;
}
-void WebRequest::start(WebRequestContext* context)
+void WebRequest::setRequestContext(WebRequestContext* context)
+{
+ if (m_request)
+ m_request->set_context(context);
+}
+
+void WebRequest::start()
{
ASSERT(m_loadState == Created, "Start called on a WebRequest not in CREATED state: (%s)", m_url.c_str());
@@ -168,8 +174,6 @@ void WebRequest::start(WebRequestContext* context)
if (m_request->url().SchemeIs("browser"))
return handleBrowserURL(m_request->url());
- m_request->set_context(context);
-
m_request->Start();
}
diff --git a/WebKit/android/WebCoreSupport/WebRequest.h b/WebKit/android/WebCoreSupport/WebRequest.h
index c3c5ec0..e896284 100644
--- a/WebKit/android/WebCoreSupport/WebRequest.h
+++ b/WebKit/android/WebCoreSupport/WebRequest.h
@@ -66,7 +66,8 @@ public:
void appendBytesToUpload(Vector<char>* data);
void appendFileToUpload(const std::string& filename);
- void start(WebRequestContext*);
+ void setRequestContext(WebRequestContext* context);
+ void start();
void cancel();
// From URLRequest::Delegate
diff --git a/WebKit/android/WebCoreSupport/WebUrlLoaderClient.cpp b/WebKit/android/WebCoreSupport/WebUrlLoaderClient.cpp
index 437ffe0..d6224e0 100644
--- a/WebKit/android/WebCoreSupport/WebUrlLoaderClient.cpp
+++ b/WebKit/android/WebCoreSupport/WebUrlLoaderClient.cpp
@@ -133,7 +133,10 @@ WebUrlLoaderClient::WebUrlLoaderClient(WebFrame* webFrame, WebCore::ResourceHand
// Chromium check if it is a directory by checking
// element.m_fileLength, that doesn't work in Android
std::string filename = element.m_filename.utf8().data();
- if (filename.size() > 0) {
+ if (filename.size()) {
+ // Change from a url string to a filename
+ if (filename.find("file://") == 0) // Found at pos 0
+ filename.erase(0, 7);
base::Thread* thread = ioThread();
if (thread)
thread->message_loop()->PostTask(FROM_HERE, NewRunnableMethod(m_request.get(), &WebRequest::appendFileToUpload, filename));
@@ -163,7 +166,8 @@ bool WebUrlLoaderClient::start(bool sync, WebRequestContext* context)
m_sync = sync;
if (m_sync) {
AutoLock autoLock(*syncLock());
- thread->message_loop()->PostTask(FROM_HERE, NewRunnableMethod(m_request.get(), &WebRequest::start, context));
+ m_request->setRequestContext(context);
+ thread->message_loop()->PostTask(FROM_HERE, NewRunnableMethod(m_request.get(), &WebRequest::start));
// Run callbacks until the queue is exhausted and m_finished is true.
while(!m_finished) {
@@ -182,7 +186,10 @@ bool WebUrlLoaderClient::start(bool sync, WebRequestContext* context)
m_resourceHandle = 0;
} else {
// Asynchronous start.
- thread->message_loop()->PostTask(FROM_HERE, NewRunnableMethod(m_request.get(), &WebRequest::start, context));
+ // Important to set this before the thread starts so it has a reference and can't be deleted
+ // before the task starts running on the IO thread.
+ m_request->setRequestContext(context);
+ thread->message_loop()->PostTask(FROM_HERE, NewRunnableMethod(m_request.get(), &WebRequest::start));
}
return true;
}