summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBen Murdoch <benm@google.com>2011-01-10 12:40:47 +0000
committerBen Murdoch <benm@google.com>2011-01-11 15:29:34 +0000
commitcd51200f40bf65e9e34a749187707ae619c6d1e5 (patch)
treea4e3af220b6029e5ea58bd5c5af79aafa844e7d6
parentb383f91699cfc5e30da4b1a75d4fd3cba8329c25 (diff)
downloadexternal_webkit-cd51200f40bf65e9e34a749187707ae619c6d1e5.zip
external_webkit-cd51200f40bf65e9e34a749187707ae619c6d1e5.tar.gz
external_webkit-cd51200f40bf65e9e34a749187707ae619c6d1e5.tar.bz2
Merge Chromium at 9.0.597.55: Move formsSeen call to IO thread.
When we search the document for forms to be autofilled, we make a URL request to the AutoFill server to ask it for form field data. With Chromium r67655, this URL request needs to be made on a Chrome thread. This is a simple fix for the merge, which blocks until the call completes. See http://src.chromium.org/viewvc/chrome?view=rev&revision=67655 Change-Id: Iad96314e4ecb66ee7e65c1ef846709e9c41b0e2e
-rw-r--r--WebKit/android/WebCoreSupport/autofill/WebAutoFill.cpp22
-rw-r--r--WebKit/android/WebCoreSupport/autofill/WebAutoFill.h7
2 files changed, 28 insertions, 1 deletions
diff --git a/WebKit/android/WebCoreSupport/autofill/WebAutoFill.cpp b/WebKit/android/WebCoreSupport/autofill/WebAutoFill.cpp
index b8afbe9..a80636c 100644
--- a/WebKit/android/WebCoreSupport/autofill/WebAutoFill.cpp
+++ b/WebKit/android/WebCoreSupport/autofill/WebAutoFill.cpp
@@ -52,6 +52,7 @@ WebAutoFill::WebAutoFill()
: mQueryId(1)
, mWebViewCore(0)
, mLastSearchDomVersion(0)
+ , mParsingForms(false)
{
mTabContents = new TabContents();
setEmptyProfile();
@@ -89,6 +90,8 @@ void WebAutoFill::searchDocument(WebCore::Frame* frame)
if (!enabled())
return;
+ MutexLocker lock(mFormsSeenMutex);
+
init();
cleanUpQueryMap();
@@ -104,8 +107,24 @@ void WebAutoFill::searchDocument(WebCore::Frame* frame)
mFormManager->ExtractForms(frame);
mFormManager->GetFormsInFrame(frame, FormManager::REQUIRE_AUTOCOMPLETE, &mForms);
- mAutoFillManager->FormsSeen(mForms);
+ // Needs to be done on a Chrome thread as it will make a URL request to the AutoFill server.
+ // TODO: Use our own Autofill thread instead of the IO thread.
+ // TODO: For now, block here. Would like to make this properly async.
+ base::Thread* thread = WebUrlLoaderClient::ioThread();
+ mParsingForms = true;
+ thread->message_loop()->PostTask(FROM_HERE, NewRunnableMethod(this, &WebAutoFill::formsSeenImpl));
+ while (mParsingForms)
+ mFormsSeenCondition.wait(mFormsSeenMutex);
+}
+
+// Called on the Chromium IO thread.
+void WebAutoFill::formsSeenImpl()
+{
+ MutexLocker lock(mFormsSeenMutex);
+ mAutoFillManager->FormsSeen(mForms);
+ mParsingForms = false;
+ mFormsSeenCondition.signal();
}
void WebAutoFill::formFieldFocused(WebCore::HTMLFormControlElement* formFieldElement)
@@ -148,6 +167,7 @@ void WebAutoFill::formFieldFocused(WebCore::HTMLFormControlElement* formFieldEle
mQueryMap[mQueryId] = new FormDataAndField(form, formField);
bool suggestions = mAutoFillManager->GetAutoFillSuggestions(*form, *formField);
+
mQueryId++;
if (!suggestions) {
ASSERT(mWebViewCore);
diff --git a/WebKit/android/WebCoreSupport/autofill/WebAutoFill.h b/WebKit/android/WebCoreSupport/autofill/WebAutoFill.h
index ee1ac17..9389281 100644
--- a/WebKit/android/WebCoreSupport/autofill/WebAutoFill.h
+++ b/WebKit/android/WebCoreSupport/autofill/WebAutoFill.h
@@ -34,6 +34,7 @@
#include <vector>
#include <wtf/Noncopyable.h>
#include <wtf/OwnPtr.h>
+#include <wtf/ThreadingPrimitives.h>
class AutoFillManager;
class AutoFillProfile;
@@ -112,9 +113,15 @@ private:
WebViewCore* mWebViewCore;
int mLastSearchDomVersion;
+
+ WTF::Mutex mFormsSeenMutex; // Guards mFormsSeenCondition and mParsingForms.
+ WTF::ThreadCondition mFormsSeenCondition;
+ bool volatile mParsingForms;
};
}
+DISABLE_RUNNABLE_METHOD_REFCOUNT(android::WebAutoFill);
+
#endif // ENABLE(WEB_AUTOFILL)
#endif // WebAutoFill_h