Bug 122781 - Refactor stored website data APIs
Summary: Refactor stored website data APIs
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit2 (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Enhancement
Assignee: Martin Hock
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-10-14 15:18 PDT by Martin Hock
Modified: 2013-10-17 13:50 PDT (History)
12 users (show)

See Also:


Attachments
Add WebOriginDataManager and friends (57.89 KB, patch)
2013-10-14 15:54 PDT, Martin Hock
eflews.bot: commit-queue-
Details | Formatted Diff | Diff
Fix style errors (57.36 KB, patch)
2013-10-14 16:16 PDT, Martin Hock
eflews.bot: commit-queue-
Details | Formatted Diff | Diff
build fix + enum change (63.08 KB, patch)
2013-10-14 20:18 PDT, Martin Hock
eflews.bot: commit-queue-
Details | Formatted Diff | Diff
build fix (63.06 KB, patch)
2013-10-14 20:48 PDT, Martin Hock
eflews.bot: commit-queue-
Details | Formatted Diff | Diff
another build fix (63.45 KB, patch)
2013-10-14 23:53 PDT, Martin Hock
eflews.bot: commit-queue-
Details | Formatted Diff | Diff
build fix + more stubs (68.01 KB, patch)
2013-10-15 11:53 PDT, Martin Hock
no flags Details | Formatted Diff | Diff
fix gtk build (68.02 KB, patch)
2013-10-15 13:00 PDT, Martin Hock
beidson: review-
Details | Formatted Diff | Diff
Address Brady's comments (61.71 KB, patch)
2013-10-15 15:39 PDT, Martin Hock
no flags Details | Formatted Diff | Diff
Fix merge conflict (65.60 KB, patch)
2013-10-15 16:25 PDT, Martin Hock
no flags Details | Formatted Diff | Diff
Rebase patch (61.72 KB, patch)
2013-10-15 20:30 PDT, Martin Hock
gtk-ews: commit-queue-
Details | Formatted Diff | Diff
gtk-wk2 build fix (62.34 KB, patch)
2013-10-16 11:32 PDT, Martin Hock
no flags Details | Formatted Diff | Diff
rebase (62.31 KB, patch)
2013-10-16 13:16 PDT, Martin Hock
no flags Details | Formatted Diff | Diff
typo in GNUmakefile.list.am (62.30 KB, patch)
2013-10-16 14:09 PDT, Martin Hock
beidson: review+
commit-queue: commit-queue-
Details | Formatted Diff | Diff
rebase + fix comment (62.39 KB, patch)
2013-10-17 13:10 PDT, Martin Hock
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Hock 2013-10-14 15:18:55 PDT
There are a number of APIs in WebKit2 for dealing with stored website data:
WKApplicationCacheManager
WKCookieManager
WKDatabaseManager
WKKeyValueStorageManager
WKMediaCacheManager
WKPluginSiteDataManager
WKResourceCacheManager

We can consolidate these and simplify the implementation.
Comment 1 Martin Hock 2013-10-14 15:54:33 PDT
Created attachment 214200 [details]
Add WebOriginDataManager and friends
Comment 2 WebKit Commit Bot 2013-10-14 15:58:27 PDT
Attachment 214200 [details] did not pass style-queue:

Failed to run "['Tools/Scripts/check-webkit-style', '--diff-files', u'Source/WebKit2/ChangeLog', u'Source/WebKit2/DerivedSources.make', u'Source/WebKit2/Shared/API/c/WKBase.h', u'Source/WebKit2/Shared/APIObject.h', u'Source/WebKit2/Shared/OriginDataAcceptPolicy.h', u'Source/WebKit2/UIProcess/API/C/WKAPICast.h', u'Source/WebKit2/UIProcess/API/C/WKContext.cpp', u'Source/WebKit2/UIProcess/API/C/WKContext.h', u'Source/WebKit2/UIProcess/API/C/WKOriginDataManager.cpp', u'Source/WebKit2/UIProcess/API/C/WKOriginDataManager.h', u'Source/WebKit2/UIProcess/WebOriginDataManagerProxy.cpp', u'Source/WebKit2/UIProcess/WebOriginDataManagerProxy.h', u'Source/WebKit2/UIProcess/WebOriginDataManagerProxy.messages.in', u'Source/WebKit2/UIProcess/WebOriginDataManagerProxyChangeClient.cpp', u'Source/WebKit2/UIProcess/WebOriginDataManagerProxyChangeClient.h', u'Source/WebKit2/WebKit2.xcodeproj/project.pbxproj', u'Source/WebKit2/WebProcess/OriginData/WebOriginDataManager.cpp', u'Source/WebKit2/WebProcess/OriginData/WebOriginDataManager.h', u'Source/WebKit2/WebProcess/OriginData/WebOriginDataManager.messages.in']" exit_code: 1
Source/WebKit2/WebProcess/OriginData/WebOriginDataManager.h:32:  Alphabetical sorting problem.  [build/include_order] [4]
Source/WebKit2/WebProcess/OriginData/WebOriginDataManager.h:47:  The parameter name "mask" adds no information, so it should be removed.  [readability/parameter_name] [5]
Source/WebKit2/WebProcess/OriginData/WebOriginDataManager.h:50:  The parameter name "mask" adds no information, so it should be removed.  [readability/parameter_name] [5]
Source/WebKit2/WebProcess/OriginData/WebOriginDataManager.h:51:  The parameter name "mask" adds no information, so it should be removed.  [readability/parameter_name] [5]
Source/WebKit2/UIProcess/API/C/WKOriginDataManager.cpp:76:  Could not find a newline character at the end of the file.  [whitespace/ending_newline] [5]
Source/WebKit2/UIProcess/WebOriginDataManagerProxy.h:37:  Alphabetical sorting problem.  [build/include_order] [4]
Source/WebKit2/UIProcess/WebOriginDataManagerProxy.h:41:  Code inside a namespace should not be indented.  [whitespace/indent] [4]
Source/WebKit2/UIProcess/API/C/WKContext.cpp:45:  Alphabetical sorting problem.  [build/include_order] [4]
Source/WebKit2/UIProcess/WebOriginDataManagerProxy.cpp:31:  Alphabetical sorting problem.  [build/include_order] [4]
Source/WebKit2/UIProcess/WebOriginDataManagerProxy.cpp:37:  Code inside a namespace should not be indented.  [whitespace/indent] [4]
Source/WebKit2/UIProcess/WebOriginDataManagerProxy.cpp:147:  Place brace on its own line for function definitions.  [whitespace/braces] [4]
Source/WebKit2/UIProcess/WebOriginDataManagerProxy.cpp:154:  Place brace on its own line for function definitions.  [whitespace/braces] [4]
Source/WebKit2/UIProcess/WebOriginDataManagerProxy.cpp:161:  Place brace on its own line for function definitions.  [whitespace/braces] [4]
Source/WebKit2/WebProcess/OriginData/WebOriginDataManager.cpp:32:  Alphabetical sorting problem.  [build/include_order] [4]
Total errors found: 14 in 19 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 3 Tim Horton 2013-10-14 15:59:15 PDT
Comment on attachment 214200 [details]
Add WebOriginDataManager and friends

View in context: https://bugs.webkit.org/attachment.cgi?id=214200&action=review

> Source/WebKit2/UIProcess/API/C/WKOriginDataManager.h:44
> +    kWKOriginDataMaskApplicationCache = 01,
> +    kWKOriginDataMaskCookie = 02,
> +    kWKOriginDataMaskDatabase = 04,
> +    kWKOriginDataMaskKeyValueStorage = 010,
> +    kWKOriginDataMaskMediaCache = 020,
> +    kWKOriginDataMaskPluginData = 040,
> +    kWKOriginDataMaskResourceCache = 0100,
> +
> +    kWKOriginDataMaskAll = 0177

Probably this should use bitshifts like WKLayoutMilestones?
Comment 4 EFL EWS Bot 2013-10-14 16:10:58 PDT
Comment on attachment 214200 [details]
Add WebOriginDataManager and friends

Attachment 214200 [details] did not pass efl-wk2-ews (efl-wk2):
Output: http://webkit-queues.appspot.com/results/3947948
Comment 5 Martin Hock 2013-10-14 16:16:41 PDT
Created attachment 214204 [details]
Fix style errors
Comment 6 EFL EWS Bot 2013-10-14 16:32:48 PDT
Comment on attachment 214204 [details]
Fix style errors

Attachment 214204 [details] did not pass efl-wk2-ews (efl-wk2):
Output: http://webkit-queues.appspot.com/results/4043080
Comment 7 Tim Horton 2013-10-14 16:41:36 PDT
(In reply to comment #6)
> (From update of attachment 214204 [details])
> Attachment 214204 [details] did not pass efl-wk2-ews (efl-wk2):
> Output: http://webkit-queues.appspot.com/results/4043080


> CMakeFiles/WebKit2.dir/UIProcess/API/C/WKContext.cpp.o: In function `WKContextGetOriginDataManager':
> WKContext.cpp:(.text.WKContextGetOriginDataManager+0x5): undefined reference to `WebKit::WebOriginDataManagerProxy::supplementName()'
Comment 8 Brady Eidson 2013-10-14 17:22:34 PDT
(In reply to comment #3)
> (From update of attachment 214200 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=214200&action=review
> 
> > Source/WebKit2/UIProcess/API/C/WKOriginDataManager.h:44
> > +    kWKOriginDataMaskApplicationCache = 01,
> > +    kWKOriginDataMaskCookie = 02,
> > +    kWKOriginDataMaskDatabase = 04,
> > +    kWKOriginDataMaskKeyValueStorage = 010,
> > +    kWKOriginDataMaskMediaCache = 020,
> > +    kWKOriginDataMaskPluginData = 040,
> > +    kWKOriginDataMaskResourceCache = 0100,
> > +
> > +    kWKOriginDataMaskAll = 0177
> 
> Probably this should use bitshifts like WKLayoutMilestones?

Definitely.
Comment 9 Martin Hock 2013-10-14 17:30:43 PDT
(In reply to comment #8)
> (In reply to comment #3)
> > (From update of attachment 214200 [details] [details])
> > View in context: https://bugs.webkit.org/attachment.cgi?id=214200&action=review
> > 
> > > Source/WebKit2/UIProcess/API/C/WKOriginDataManager.h:44
> > > +    kWKOriginDataMaskApplicationCache = 01,
> > > +    kWKOriginDataMaskCookie = 02,
> > > +    kWKOriginDataMaskDatabase = 04,
> > > +    kWKOriginDataMaskKeyValueStorage = 010,
> > > +    kWKOriginDataMaskMediaCache = 020,
> > > +    kWKOriginDataMaskPluginData = 040,
> > > +    kWKOriginDataMaskResourceCache = 0100,
> > > +
> > > +    kWKOriginDataMaskAll = 0177
> > 
> > Probably this should use bitshifts like WKLayoutMilestones?
> 
> Definitely.

I was being overly cautious about putting expressions in enums.  Apparently gcc with -std=c89 -pedantic thinks it's fine.

For the kWKOriginDataMaskAll value, I'll use the identity sum(i=0..n)(2^i) = 2^(n+1)-1, so in that case, kWKOriginDataMaskAll = (1 << 7) - 1 [parens are important!]
Comment 10 Martin Hock 2013-10-14 20:18:08 PDT
Created attachment 214223 [details]
build fix + enum change
Comment 11 EFL EWS Bot 2013-10-14 20:30:47 PDT
Comment on attachment 214223 [details]
build fix + enum change

Attachment 214223 [details] did not pass efl-wk2-ews (efl-wk2):
Output: http://webkit-queues.appspot.com/results/4025046
Comment 12 Martin Hock 2013-10-14 20:48:44 PDT
Created attachment 214226 [details]
build fix
Comment 13 EFL EWS Bot 2013-10-14 21:13:11 PDT
Comment on attachment 214226 [details]
build fix

Attachment 214226 [details] did not pass efl-wk2-ews (efl-wk2):
Output: http://webkit-queues.appspot.com/results/3578056
Comment 14 kov's GTK+ EWS bot 2013-10-14 22:36:06 PDT
Comment on attachment 214223 [details]
build fix + enum change

Attachment 214223 [details] did not pass gtk-ews (gtk):
Output: http://webkit-queues.appspot.com/results/4067025
Comment 15 Brady Eidson 2013-10-14 22:38:05 PDT
> /mnt/eflews/webkit/WebKit/Source/WebKit2/UIProcess/WebOriginDataManagerProxy.cpp:32:47: fatal error: WebOriginDataManagerProxyMessages.h: No such file or directory
 
EFL (apparently) isn't generating the messages.in file here.
Comment 16 kov's GTK+ EWS bot 2013-10-14 22:42:17 PDT
Comment on attachment 214226 [details]
build fix

Attachment 214226 [details] did not pass gtk-ews (gtk):
Output: http://webkit-queues.appspot.com/results/3578077
Comment 17 Martin Hock 2013-10-14 23:53:19 PDT
Created attachment 214235 [details]
another build fix
Comment 18 EFL EWS Bot 2013-10-15 04:19:38 PDT
Comment on attachment 214235 [details]
another build fix

Attachment 214235 [details] did not pass efl-wk2-ews (efl-wk2):
Output: http://webkit-queues.appspot.com/results/3851007
Comment 19 kov's GTK+ EWS bot 2013-10-15 05:14:27 PDT
Comment on attachment 214235 [details]
another build fix

Attachment 214235 [details] did not pass gtk-wk2-ews (gtk-wk2):
Output: http://webkit-queues.appspot.com/results/3452047
Comment 20 kov's GTK+ EWS bot 2013-10-15 06:51:19 PDT
Comment on attachment 214235 [details]
another build fix

Attachment 214235 [details] did not pass gtk-ews (gtk):
Output: http://webkit-queues.appspot.com/results/3723010
Comment 21 Martin Hock 2013-10-15 11:53:17 PDT
Created attachment 214288 [details]
build fix + more stubs
Comment 22 Martin Hock 2013-10-15 13:00:38 PDT
Created attachment 214294 [details]
fix gtk build
Comment 23 Brady Eidson 2013-10-15 14:55:57 PDT
Comment on attachment 214294 [details]
fix gtk build

View in context: https://bugs.webkit.org/attachment.cgi?id=214294&action=review

Lots and lots of plumbing out of the way, great start!  I'm going to be super picky on the exposed API before reviewing any further.

We should get Anders to look at this when he's around, and the 3 of us can even hash out ideas in person.

I do have some individual feedback that relegates this to an r-

> Source/WebKit2/UIProcess/API/C/WKOriginDataManager.h:42
> +    kWKOriginDataMaskApplicationCache = 1 << 0,
> +    kWKOriginDataMaskCookie = 1 << 1,
> +    kWKOriginDataMaskDatabase = 1 << 2,
> +    kWKOriginDataMaskKeyValueStorage = 1 << 3,
> +    kWKOriginDataMaskMediaCache = 1 << 4,
> +    kWKOriginDataMaskPluginData = 1 << 5,
> +    kWKOriginDataMaskResourceCache = 1 << 6,

I don't think "Mask" is a good component of one of these names, even if they are logically bit masks.

As mentioned, we could follow the previously established WKLayoutMilestone pattern for these bit masks.  This pattern includes not necessarily predicated each of these values with the same prefix.

I'd suggest something like:
kWKApplicationCacheOriginData,
kWKCookieOriginData,
etc etc

> Source/WebKit2/UIProcess/API/C/WKOriginDataManager.h:46
> +typedef uint32_t WKOriginDataMask;

And for the typedef here, I'd go with WKOriginDataTypes.

To me, just like with "WKLayoutMilestones", the pluralization of "Types" illustrates that one variable might reflect multiple values in the mask.

> Source/WebKit2/UIProcess/API/C/WKOriginDataManager.h:53
> +enum {
> +    kWKOriginDataAcceptPolicyAlways = 0,
> +    kWKOriginDataAcceptPolicyNever = 1,
> +    kWKOriginDataAcceptPolicyOnlyFromMainDocumentDomain = 2
> +};
> +typedef uint32_t WKOriginDataAcceptPolicy;

This is primarily about cookies, and has nothing to do with origins.  I think the WKCookieManager can live on and provide only this functionality.

> Source/WebKit2/UIProcess/API/C/WKOriginDataManager.h:77
> +// Currently, only mask == WKOriginDataManagerCookie is supported for the following.
> +WK_EXPORT void WKOriginDataManagerSetAcceptPolicy(WKOriginDataManagerRef originDataManager, WKOriginDataMask mask, WKOriginDataAcceptPolicy policy);
> +typedef void (*WKOriginDataManagerGetAcceptPolicyFunction)(WKOriginDataAcceptPolicy, WKErrorRef, void*);
> +WK_EXPORT void WKOriginDataManagerGetAcceptPolicy(WKOriginDataManagerRef originDataManager, WKOriginDataMask mask, void* context, WKOriginDataManagerGetAcceptPolicyFunction callback);

As mentioned above, these can live only in the cookie manager.
Comment 24 Martin Hock 2013-10-15 15:39:07 PDT
Created attachment 214312 [details]
Address Brady's comments
Comment 25 Martin Hock 2013-10-15 16:25:37 PDT
Created attachment 214318 [details]
Fix merge conflict
Comment 26 Martin Hock 2013-10-15 20:30:13 PDT
Created attachment 214337 [details]
Rebase patch
Comment 27 kov's GTK+ EWS bot 2013-10-16 03:46:18 PDT
Comment on attachment 214337 [details]
Rebase patch

Attachment 214337 [details] did not pass gtk-wk2-ews (gtk-wk2):
Output: http://webkit-queues.appspot.com/results/4106249
Comment 28 Martin Hock 2013-10-16 11:32:54 PDT
Created attachment 214378 [details]
gtk-wk2 build fix
Comment 29 Martin Hock 2013-10-16 13:16:44 PDT
Created attachment 214387 [details]
rebase
Comment 30 Martin Hock 2013-10-16 14:09:09 PDT
Created attachment 214395 [details]
typo in GNUmakefile.list.am
Comment 31 Brady Eidson 2013-10-17 10:59:11 PDT
Comment on attachment 214395 [details]
typo in GNUmakefile.list.am

View in context: https://bugs.webkit.org/attachment.cgi?id=214395&action=review

Looks good overall.  One thing that gets an r- from me, but should be easy to address.

> Source/WebKit2/UIProcess/API/C/WKOriginDataManager.h:46
> +typedef uint32_t WKOriginDataTypes;

Since we never really store these and aren't concerned about memory usage/etc, and since we'd like to make this one API as future proof as possible, let's make this a uint64_t here and everywhere else that uses it.

Otherwise we'd be cursing ourselves when we add the 33rd data type...

> Source/WebKit2/WebProcess/OriginData/WebOriginDataManager.cpp:85
> +void WebOriginDataManager::deleteEntriesForOrigin(WKOriginDataTypes types, const SecurityOriginData& originData)
> +{
> +    RefPtr<SecurityOrigin> origin = SecurityOrigin::create(originData.protocol, originData.host, originData.port);
> +    if (!origin)
> +        return;
> +
> +    // FIXME: delete cache

Not really "delete cache", it's more than that!
Comment 32 Brady Eidson 2013-10-17 12:55:41 PDT
(In reply to comment #31)
> (From update of attachment 214395 [details])
> > Source/WebKit2/UIProcess/API/C/WKOriginDataManager.h:46
> > +typedef uint32_t WKOriginDataTypes;
> 
> Since we never really store these and aren't concerned about memory usage/etc, and since we'd like to make this one API as future proof as possible, let's make this a uint64_t here and everywhere else that uses it.
> 
> Otherwise we'd be cursing ourselves when we add the 33rd data type...

Because of the C-ness of the API, this won't work.  we'll leave as-is.
Comment 33 WebKit Commit Bot 2013-10-17 12:58:15 PDT
Comment on attachment 214395 [details]
typo in GNUmakefile.list.am

Rejecting attachment 214395 [details] from commit-queue.

Failed to run "['/Volumes/Data/EWS/WebKit/Tools/Scripts/webkit-patch', '--status-host=webkit-queues.appspot.com', '--bot-id=webkit-cq-01', 'apply-attachment', '--no-update', '--non-interactive', 214395, '--port=mac']" exit_code: 2 cwd: /Volumes/Data/EWS/WebKit

Last 500 characters of output:
nes).
1 out of 17 hunks FAILED -- saving rejects to file Source/WebKit2/WebKit2.xcodeproj/project.pbxproj.rej
patching file Source/WebKit2/WebProcess/OriginData/WebOriginDataManager.cpp
patching file Source/WebKit2/WebProcess/OriginData/WebOriginDataManager.h
patching file Source/WebKit2/WebProcess/OriginData/WebOriginDataManager.messages.in

Failed to run "[u'/Volumes/Data/EWS/WebKit/Tools/Scripts/svn-apply', '--force', '--reviewer', u'Brady Eidson']" exit_code: 1 cwd: /Volumes/Data/EWS/WebKit

Full output: http://webkit-queues.appspot.com/results/3856063
Comment 34 Martin Hock 2013-10-17 13:10:42 PDT
Created attachment 214494 [details]
rebase + fix comment
Comment 35 WebKit Commit Bot 2013-10-17 13:50:21 PDT
Comment on attachment 214494 [details]
rebase + fix comment

Clearing flags on attachment: 214494

Committed r157595: <http://trac.webkit.org/changeset/157595>
Comment 36 WebKit Commit Bot 2013-10-17 13:50:25 PDT
All reviewed patches have been landed.  Closing bug.