Bug 85575

Summary: [BlackBerry] Autofill backing store implementation upstream
Product: WebKit Reporter: Jonathan Dong <jonathan.dong.webkit@gmail.com>
Component: WebKit BlackBerryAssignee: Nobody <webkit-unassigned@lists.webkit.org>
Status: RESOLVED FIXED    
Severity: Normal CC: charles.wei@torchmobile.com.cn, leo.yang@torchmobile.com.cn, mstaikos@rim.com, rakuco@webkit.org, rwlbuis@gmail.com, staikos@kde.org, tonikitoo@webkit.org, webkit.review.bot@gmail.com
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on:    
Bug Blocks: 85576    
Attachments:
Description Flags
Patch
none
Patch
none
Patch
none
Patch none

Description From 2012-05-03 21:09:45 PST
RIM PR: 136405

The form auto fill feature by my current implementation is pretty much like the behavior of desktop browsers, when user submits a form, the name attribute and the value of text input fields(exclude password) will be stored in the autofill database as a name-value pair. Next time when the user fills any form on any site, the browser will search the db to find out if there's any matched name-value pair to fill the current editing input text field. We will find all the values which has the same name attribute and starts with the character that user has input, and pops up a context dialog to notify user those candidates used by him. If user chooses one from the context dialog, the value will fill the current input text field.

This PR is about the implementation of class AutofillBackingStore, which takes over all the database interaction for AutofillManager.
------- Comment #1 From 2012-05-03 23:57:12 PST -------
Created an attachment (id=140169) [details]
Patch
------- Comment #2 From 2012-05-04 04:49:44 PST -------
(From update of attachment 140169 [details])
View in context: https://bugs.webkit.org/attachment.cgi?id=140169&action=review

Can be cleaned up some more.

> Source/WebCore/platform/network/blackberry/AutofillBackingStore.cpp:24
> +#include "NotImplemented.h"

Can be removed?

> Source/WebCore/platform/network/blackberry/AutofillBackingStore.cpp:163
> +    int numOfRow = m_hasStatement->getColumnInt(0);

Do you mean numberOfRows here or rowNumber? 
Better not abbreviate.

> Source/WebCore/platform/network/blackberry/AutofillBackingStore.cpp:170
> +    return false;

You can combine these into one return statement.

> Source/WebCore/platform/network/blackberry/AutofillBackingStore.h:23
> +#include <wtf/Vector.h>

Does not seem like we need this include here.

> Source/WebCore/platform/network/blackberry/AutofillBackingStore.h:40
> +    bool has(const String& name, const String& value);

has is an unclear name for a function. How about contains?

> Source/WebCore/platform/network/blackberry/AutofillBackingStore.h:41
> +

Please check if any of the functions are const.
------- Comment #3 From 2012-05-04 09:26:12 PST -------
Created an attachment (id=140251) [details]
Patch
------- Comment #4 From 2012-05-04 09:34:43 PST -------
(From update of attachment 140251 [details])
View in context: https://bugs.webkit.org/attachment.cgi?id=140251&action=review

> Source/WebCore/platform/network/blackberry/AutofillBackingStore.cpp:56
> +        m_database.close();

Should the dtor here do similar things like close()? Can you assure somewhow close() is called before the dtor is called? Is the dtor called at all?
------- Comment #5 From 2012-05-04 09:47:42 PST -------
(From update of attachment 140251 [details])
Attachment 140251 [details] did not pass win-ews (win):
Output: http://queues.webkit.org/results/12480935
------- Comment #6 From 2012-05-04 09:53:41 PST -------
(From update of attachment 140251 [details])
View in context: https://bugs.webkit.org/attachment.cgi?id=140251&action=review

>> Source/WebCore/platform/network/blackberry/AutofillBackingStore.cpp:56
>> +        m_database.close();
> 
> Should the dtor here do similar things like close()? Can you assure somewhow close() is called before the dtor is called? Is the dtor called at all?

well that's a good question. I think as AutofillBackingStore works as a singleton, close() should make as a private function and called from dtor, we shouldn't let people call close() explicitly.
dtor should be called after exit main(), I'll make a build and debug it tomorrow to see if it works as expected, too tired today.
I guess CredentialBackingStore has the same issue, sorry for that. Will fix it together with next patch. Thanks.
------- Comment #7 From 2012-05-04 10:44:56 PST -------
Hi Jonathan,

(In reply to comment #6)
> (From update of attachment 140251 [details] [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=140251&action=review
> 
> >> Source/WebCore/platform/network/blackberry/AutofillBackingStore.cpp:56
> >> +        m_database.close();
> > 
> > Should the dtor here do similar things like close()? Can you assure somewhow close() is called before the dtor is called? Is the dtor called at all?
> 
> well that's a good question. I think as AutofillBackingStore works as a singleton, close() should make as a private function and called from dtor, we shouldn't let people call close() explicitly.
> dtor should be called after exit main(), I'll make a build and debug it tomorrow to see if it works as expected, too tired today.
> I guess CredentialBackingStore has the same issue, sorry for that. Will fix it together with next patch. Thanks.

Sounds good. Also if you use DEFINE_STATIC_LOCAL for the singleton it should call the dtor, maybe you can debug that.
If you only call close() from the dtor then maybe you do not even need that function but just put the code in the dtor.
Looking forward to the patch :)
Cheers,

Rob.
------- Comment #8 From 2012-05-04 10:47:29 PST -------
(From update of attachment 140251 [details])
Clearing review flag since Jonathan will fix the dtor issues in a new patch.
------- Comment #9 From 2012-05-06 03:22:07 PST -------
Created an attachment (id=140421) [details]
Patch
------- Comment #10 From 2012-05-06 16:30:16 PST -------
(From update of attachment 140421 [details])
View in context: https://bugs.webkit.org/attachment.cgi?id=140421&action=review

Looks good. I don't really see the need to move away from instance() concept, but ok.

> Source/WebCore/platform/network/blackberry/AutofillBackingStore.cpp:185
> +

One newline too much.
------- Comment #11 From 2012-05-06 16:53:57 PST -------
Created an attachment (id=140445) [details]
Patch
------- Comment #12 From 2012-05-06 16:58:37 PST -------
(From update of attachment 140445 [details])
Looks good.
------- Comment #13 From 2012-05-06 18:50:01 PST -------
(From update of attachment 140445 [details])
Clearing flags on attachment: 140445

Committed r116258: <http://trac.webkit.org/changeset/116258>
------- Comment #14 From 2012-05-06 18:50:08 PST -------
All reviewed patches have been landed.  Closing bug.