: mQueryId(1)
, mWebViewCore(0)
, mLastSearchDomVersion(0)
+ , mParsingForms(false)
{
mTabContents = new TabContents();
setEmptyProfile();
if (!enabled())
return;
+ MutexLocker lock(mFormsSeenMutex);
+
init();
cleanUpQueryMap();
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)
mQueryMap[mQueryId] = new FormDataAndField(form, formField);
bool suggestions = mAutoFillManager->GetAutoFillSuggestions(*form, *formField);
+
mQueryId++;
if (!suggestions) {
ASSERT(mWebViewCore);
#include <vector>
#include <wtf/Noncopyable.h>
#include <wtf/OwnPtr.h>
+#include <wtf/ThreadingPrimitives.h>
class AutoFillManager;
class AutoFillProfile;
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