Bug 55644 - [fileapi] Add URI resolution support to WorkerContext
Summary: [fileapi] Add URI resolution support to WorkerContext
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebCore Misc. (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-03-02 18:54 PST by Adam Klein
Modified: 2011-03-21 20:35 PDT (History)
8 users (show)

See Also:


Attachments
Patch (18.67 KB, patch)
2011-03-02 18:57 PST, Adam Klein
no flags Details | Formatted Diff | Diff
Patch (18.89 KB, patch)
2011-03-03 12:10 PST, Adam Klein
no flags Details | Formatted Diff | Diff
Use an enum for internal create param (19.16 KB, patch)
2011-03-03 14:08 PST, Adam Klein
no flags Details | Formatted Diff | Diff
Now with tests, but not ready for review (35.07 KB, patch)
2011-03-18 14:47 PDT, Adam Klein
no flags Details | Formatted Diff | Diff
Ready for review, tests pass (35.47 KB, patch)
2011-03-18 17:48 PDT, Adam Klein
no flags Details | Formatted Diff | Diff
Patch (35.67 KB, patch)
2011-03-21 16:37 PDT, Adam Klein
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Adam Klein 2011-03-02 18:54:45 PST
[fileapi] Add URI resolution support to WorkerContext
Comment 1 Adam Klein 2011-03-02 18:57:57 PST
Created attachment 84508 [details]
Patch
Comment 2 Adam Klein 2011-03-02 18:59:11 PST
Depends on http://codereview.chromium.org/6613008/.
Comment 3 Kinuko Yasuda 2011-03-02 23:08:05 PST
Comment on attachment 84508 [details]
Patch

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

lgtm.

> Source/WebKit/chromium/src/LocalFileSystemChromium.cpp:60
> +void LocalFileSystem::readFileSystem(ScriptExecutionContext* context, AsyncFileSystem::Type type, PassOwnPtr<AsyncFileSystemCallbacks> callbacks, bool synchronous)

The implementation of this method is mostly same as that of requestFileSystem-- maybe we could factor out a common private method that takes all of parameters plus boolean create flag and make both readFileSystem and requestFileSystem a wrapper of the method.
Comment 4 Adam Klein 2011-03-03 12:09:45 PST
Comment on attachment 84508 [details]
Patch

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

>> Source/WebKit/chromium/src/LocalFileSystemChromium.cpp:60
>> +void LocalFileSystem::readFileSystem(ScriptExecutionContext* context, AsyncFileSystem::Type type, PassOwnPtr<AsyncFileSystemCallbacks> callbacks, bool synchronous)
> 
> The implementation of this method is mostly same as that of requestFileSystem-- maybe we could factor out a common private method that takes all of parameters plus boolean create flag and make both readFileSystem and requestFileSystem a wrapper of the method.

Good idea.  I've done that.  The only thing that I don't like about all this is the fact that there's two bools and a long long all together in one signature.  Quite easy to screw up the order and break stuff.  I'd like to come back to this code and redo the API with enums instead.
Comment 5 Adam Klein 2011-03-03 12:10:39 PST
Created attachment 84604 [details]
Patch
Comment 6 Kinuko Yasuda 2011-03-03 12:24:13 PST
(In reply to comment #5)
> Created an attachment (id=84604) [details]
> Patch

LGTM.

(In reply to comment #4)
> > The implementation of this method is mostly same as that of requestFileSystem-- maybe we could factor out a common private method that takes all of parameters plus boolean create flag and make both readFileSystem and requestFileSystem a wrapper of the method.
> 
> Good idea.  I've done that.  The only thing that I don't like about all this is the fact that there's two bools and a long long all together in one signature.  Quite easy to screw up the order and break stuff.  I'd like to come back to this code and redo the API with enums instead.

Agreed, the signature looks a bit messed up after repeated ad-hoc changes.  Anyway the two public methods look nicer now, thanks for doing this.
Comment 7 Adam Klein 2011-03-03 12:57:49 PST
CCing some possible reviewers.
Comment 8 David Levin 2011-03-03 13:58:10 PST
Comment on attachment 84604 [details]
Patch

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

> Source/WebCore/ChangeLog:9
> +        in the WebKit Chromium builds.

Why are are adding more stuff here if none of it is testable? (I thought I saw some tests for the file system in workers but maybe not.)

If they aren't testable, can we fix that before adding more here.

> Source/WebKit/chromium/src/LocalFileSystemChromium.cpp:77
> +    openFileSystemHelper(context, type, callbacks, synchronous, 0, false);

That last parameter should be an enum instead of a bool to make the call sites more readable.
Comment 9 Adam Klein 2011-03-03 14:08:35 PST
Created attachment 84624 [details]
Use an enum for internal create param
Comment 10 Adam Klein 2011-03-03 14:10:49 PST
Comment on attachment 84604 [details]
Patch

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

>> Source/WebCore/ChangeLog:9
>> +        in the WebKit Chromium builds.
> 
> Why are are adding more stuff here if none of it is testable? (I thought I saw some tests for the file system in workers but maybe not.)
> 
> If they aren't testable, can we fix that before adding more here.

Thanks for calling me on this. Kinuko, can you help here?  Last time I tried to run the worker tests they just hung.

>> Source/WebKit/chromium/src/LocalFileSystemChromium.cpp:77
>> +    openFileSystemHelper(context, type, callbacks, synchronous, 0, false);
> 
> That last parameter should be an enum instead of a bool to make the call sites more readable.

Done.
Comment 11 Adam Klein 2011-03-03 14:19:51 PST
Removing review bit while I go get the filesystem sync tests running in Chromium.
Comment 12 David Levin 2011-03-03 16:24:38 PST
I saw this but then forgot to mention this before. Avoid abbreviations in WebKit. I'm referring to "fs" below:
  RefPtr<DOMFileSystemSync> fs = readFileSystemHelper.getResult(ec);
Comment 13 Adam Klein 2011-03-18 14:47:43 PDT
Created attachment 86215 [details]
Now with tests, but not ready for review
Comment 14 Adam Klein 2011-03-18 14:48:54 PDT
The one thing holding this back from review is the backslash test: I can't figure out why it's passing in async mode but failing in sync.  Will probably require a debugging session.
Comment 15 Adam Klein 2011-03-18 17:48:33 PDT
Created attachment 86248 [details]
Ready for review, tests pass
Comment 16 Adam Klein 2011-03-21 14:52:35 PDT
Just a friendly ping that this is ready for review again, now with the tests David asked for.
Comment 17 Adam Barth 2011-03-21 15:08:53 PDT
I'm going to let dave_levin review this patch.  I looked over it briefly and it looked sane to me.  :)
Comment 18 David Levin 2011-03-21 15:58:41 PDT
Comment on attachment 86248 [details]
Ready for review, tests pass

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

Just a few minor things to address.

> Source/WebCore/fileapi/LocalFileSystem.h:57
> +    void readFileSystem(ScriptExecutionContext*, AsyncFileSystem::Type, PassOwnPtr<AsyncFileSystemCallbacks>, bool synchronous = false);

Why add this parameter and then ignore it?

> Source/WebCore/workers/WorkerContext.h:136
> +        void resolveLocalFileSystemURL(const String& url, PassRefPtr<EntryCallback>, PassRefPtr<ErrorCallback>);

The parameter name successCallback would add information in this case so it would be good to add it.

> Source/WebKit/chromium/src/LocalFileSystemChromium.cpp:67
> +void openFileSystemHelper(ScriptExecutionContext* context, AsyncFileSystem::Type type, PassOwnPtr<AsyncFileSystemCallbacks> callbacks, bool synchronous, long long size, CreationFlag create)

Function local to file should be "static".
Comment 19 Adam Klein 2011-03-21 16:37:33 PDT
Created attachment 86384 [details]
Patch
Comment 20 Adam Klein 2011-03-21 16:41:40 PDT
Comment on attachment 86248 [details]
Ready for review, tests pass

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

>> Source/WebCore/fileapi/LocalFileSystem.h:57
>> +    void readFileSystem(ScriptExecutionContext*, AsyncFileSystem::Type, PassOwnPtr<AsyncFileSystemCallbacks>, bool synchronous = false);
> 
> Why add this parameter and then ignore it?

The code in fileapi/LocalFileSystem.cpp is a stubbed-out implementation that's not currently used since the Chromium port is the only one to implement FileSystem.  My code's ignoring of the new parameter is just following in the footsteps of requestFileSystem, in this same file.  Note that I do use the bool in LocalFileSystemChromium.cpp.

Kinuko may be able to explain why this stubbed impl exists at all; it seems that things would work just fine without it.

>> Source/WebCore/workers/WorkerContext.h:136
>> +        void resolveLocalFileSystemURL(const String& url, PassRefPtr<EntryCallback>, PassRefPtr<ErrorCallback>);
> 
> The parameter name successCallback would add information in this case so it would be good to add it.

Added the name here, and above for requestFileSystem for consistency.

>> Source/WebKit/chromium/src/LocalFileSystemChromium.cpp:67
>> +void openFileSystemHelper(ScriptExecutionContext* context, AsyncFileSystem::Type type, PassOwnPtr<AsyncFileSystemCallbacks> callbacks, bool synchronous, long long size, CreationFlag create)
> 
> Function local to file should be "static".

Function was already inside an anonymous namespace, but I've moved the namespace up to cover only the enum, and made the function static.  Let me know if you want the function inside the namespace, but that seems redundant to me.
Comment 21 WebKit Commit Bot 2011-03-21 20:31:53 PDT
The commit-queue encountered the following flaky tests while processing attachment 86384 [details]:

fast/dom/onerror-img.html bug 51019
The commit-queue is continuing to process your patch.
Comment 22 WebKit Commit Bot 2011-03-21 20:35:24 PDT
Comment on attachment 86384 [details]
Patch

Clearing flags on attachment: 86384

Committed r81640: <http://trac.webkit.org/changeset/81640>
Comment 23 WebKit Commit Bot 2011-03-21 20:35:29 PDT
All reviewed patches have been landed.  Closing bug.