Bug 169044 - Add SPI to create WebsiteDataStore objects pointing to custom paths
Summary: Add SPI to create WebsiteDataStore objects pointing to custom paths
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit Misc. (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Brady Eidson
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-03-01 10:38 PST by Brady Eidson
Modified: 2017-03-01 20:38 PST (History)
3 users (show)

See Also:


Attachments
Patch (21.96 KB, text/plain)
2017-03-01 10:39 PST, Brady Eidson
no flags Details
Patch (15.29 KB, patch)
2017-03-01 10:41 PST, Brady Eidson
no flags Details | Formatted Diff | Diff
Patch (28.19 KB, patch)
2017-03-01 12:48 PST, Brady Eidson
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Brady Eidson 2017-03-01 10:38:26 PST
Add SPI to create WebsiteDataStore objects pointing to custom paths

This is not comprehensive quite yet; Baby steps.
Comment 1 Brady Eidson 2017-03-01 10:39:47 PST
Created attachment 303079 [details]
Patch
Comment 2 Brady Eidson 2017-03-01 10:41:49 PST
Created attachment 303080 [details]
Patch
Comment 3 Tim Horton 2017-03-01 10:46:05 PST
Comment on attachment 303080 [details]
Patch

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

> Source/WebKit2/UIProcess/API/APIWebsiteDataStore.h:42
> +    WebsiteDataStore(WebKit::WebsiteDataStore::Configuration);

+explicit

> Source/WebKit2/UIProcess/API/Cocoa/_WKWebsiteDataStoreConfiguration.h:34
> +WK_CLASS_AVAILABLE(macosx(10.12), ios(10.0))

This does not seem accurate.

> Source/WebKit2/UIProcess/API/Cocoa/_WKWebsiteDataStoreConfiguration.h:37
> +@property (nonatomic, strong) NSString *webStorageDirectory;

Don't we usually copy string properties? I guess it doesn't really matter because you toss the configuration immediately after it's passed in, but it's good practice.
Comment 4 Brady Eidson 2017-03-01 12:48:01 PST
Created attachment 303099 [details]
Patch
Comment 5 WebKit Commit Bot 2017-03-01 12:50:51 PST
Attachment 303099 [details] did not pass style-queue:


ERROR: Tools/TestWebKitAPI/Tests/WebKit2Cocoa/WebsiteDataStoreCustomPaths.mm:31:  Alphabetical sorting problem.  [build/include_order] [4]
Total errors found: 1 in 12 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 6 WebKit Commit Bot 2017-03-01 14:03:07 PST
Comment on attachment 303099 [details]
Patch

Clearing flags on attachment: 303099

Committed r213241: <http://trac.webkit.org/changeset/213241>
Comment 7 WebKit Commit Bot 2017-03-01 14:03:10 PST
All reviewed patches have been landed.  Closing bug.
Comment 8 mitz 2017-03-01 14:24:10 PST
Comment on attachment 303099 [details]
Patch

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

> Source/WebKit2/UIProcess/API/Cocoa/_WKWebsiteDataStoreConfiguration.h:39
> +@property (nonatomic, copy) NSString *webStorageDirectory;
> +@property (nonatomic, copy) NSString *indexedDBDatabaseDirectory;
> +@property (nonatomic, copy) NSString *webSQLDatabaseDirectory;

Modern Cocoa APIs use file NSURLs for filesystem locations rather than path NSStrings.
Comment 9 Brady Eidson 2017-03-01 15:20:24 PST
(In reply to comment #8)
> Comment on attachment 303099 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=303099&action=review
> 
> > Source/WebKit2/UIProcess/API/Cocoa/_WKWebsiteDataStoreConfiguration.h:39
> > +@property (nonatomic, copy) NSString *webStorageDirectory;
> > +@property (nonatomic, copy) NSString *indexedDBDatabaseDirectory;
> > +@property (nonatomic, copy) NSString *webSQLDatabaseDirectory;
> 
> Modern Cocoa APIs use file NSURLs for filesystem locations rather than path
> NSStrings.

What would you suggest the failure mode be if somebody puts in a remote URL?
Comment 10 Tim Horton 2017-03-01 15:44:10 PST
(In reply to comment #9)
> (In reply to comment #8)
> > Comment on attachment 303099 [details]
> > Patch
> > 
> > View in context:
> > https://bugs.webkit.org/attachment.cgi?id=303099&action=review
> > 
> > > Source/WebKit2/UIProcess/API/Cocoa/_WKWebsiteDataStoreConfiguration.h:39
> > > +@property (nonatomic, copy) NSString *webStorageDirectory;
> > > +@property (nonatomic, copy) NSString *indexedDBDatabaseDirectory;
> > > +@property (nonatomic, copy) NSString *webSQLDatabaseDirectory;
> > 
> > Modern Cocoa APIs use file NSURLs for filesystem locations rather than path
> > NSStrings.
> 
> What would you suggest the failure mode be if somebody puts in a remote URL?

What is the failure mode if somebody puts in a garbage string? They should probably be the same.
Comment 11 Brady Eidson 2017-03-01 15:49:37 PST
(In reply to comment #10)
> (In reply to comment #9)
> > (In reply to comment #8)
> > > Comment on attachment 303099 [details]
> > > Patch
> > > 
> > > View in context:
> > > https://bugs.webkit.org/attachment.cgi?id=303099&action=review
> > > 
> > > > Source/WebKit2/UIProcess/API/Cocoa/_WKWebsiteDataStoreConfiguration.h:39
> > > > +@property (nonatomic, copy) NSString *webStorageDirectory;
> > > > +@property (nonatomic, copy) NSString *indexedDBDatabaseDirectory;
> > > > +@property (nonatomic, copy) NSString *webSQLDatabaseDirectory;
> > > 
> > > Modern Cocoa APIs use file NSURLs for filesystem locations rather than path
> > > NSStrings.
> > 
> > What would you suggest the failure mode be if somebody puts in a remote URL?
> 
> What is the failure mode if somebody puts in a garbage string? They should
> probably be the same.

Currently a garbage string would result in "things just don't work right", simply because we have no special handling.

Transitioning to NSURLs - without specifically addressing the failure mode - could mean that storage/websql/indexeddb reads might actually try to go to the network.
Comment 12 Brady Eidson 2017-03-01 15:50:00 PST
I'm definitely willing to iterate on this once we identify the appropriate failure mode.
Comment 13 Tim Horton 2017-03-01 15:53:38 PST
It's a programming error, not a "we don't expect this to happen" error, so why not throw an exception?
Comment 14 Brady Eidson 2017-03-01 16:05:32 PST
(In reply to comment #13)
> It's a programming error, not a "we don't expect this to happen" error, so
> why not throw an exception?

If that's the desired behavior, I can implement it.
Comment 15 mitz 2017-03-01 18:26:01 PST
(In reply to comment #9)
> (In reply to comment #8)
> > Comment on attachment 303099 [details]
> > Patch
> > 
> > View in context:
> > https://bugs.webkit.org/attachment.cgi?id=303099&action=review
> > 
> > > Source/WebKit2/UIProcess/API/Cocoa/_WKWebsiteDataStoreConfiguration.h:39
> > > +@property (nonatomic, copy) NSString *webStorageDirectory;
> > > +@property (nonatomic, copy) NSString *indexedDBDatabaseDirectory;
> > > +@property (nonatomic, copy) NSString *webSQLDatabaseDirectory;
> > 
> > Modern Cocoa APIs use file NSURLs for filesystem locations rather than path
> > NSStrings.
> 
> What would you suggest the failure mode be if somebody puts in a remote URL?

Same thing we do in -[WKWebView loadFileURL:allowingReadAccessToURL:].
Comment 16 Brady Eidson 2017-03-01 20:38:29 PST
(In reply to comment #15)
> (In reply to comment #9)
> > (In reply to comment #8)
> > > Comment on attachment 303099 [details]
> > > Patch
> > > 
> > > View in context:
> > > https://bugs.webkit.org/attachment.cgi?id=303099&action=review
> > > 
> > > > Source/WebKit2/UIProcess/API/Cocoa/_WKWebsiteDataStoreConfiguration.h:39
> > > > +@property (nonatomic, copy) NSString *webStorageDirectory;
> > > > +@property (nonatomic, copy) NSString *indexedDBDatabaseDirectory;
> > > > +@property (nonatomic, copy) NSString *webSQLDatabaseDirectory;
> > > 
> > > Modern Cocoa APIs use file NSURLs for filesystem locations rather than path
> > > NSStrings.
> > 
> > What would you suggest the failure mode be if somebody puts in a remote URL?
> 
> Same thing we do in -[WKWebView loadFileURL:allowingReadAccessToURL:].

A concrete example! I like those. :)

Thanks!