Bug 86995 - Cleanup: add a file system call which captures the file metadata at once.
Summary: Cleanup: add a file system call which captures the file metadata at once.
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit Misc. (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Kinuko Yasuda
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-05-21 01:21 PDT by Kinuko Yasuda
Modified: 2012-05-24 23:40 PDT (History)
11 users (show)

See Also:


Attachments
Patch (19.67 KB, patch)
2012-05-21 01:38 PDT, Kinuko Yasuda
buildbot: commit-queue-
Details | Formatted Diff | Diff
Patch (19.83 KB, patch)
2012-05-21 02:37 PDT, Kinuko Yasuda
buildbot: commit-queue-
Details | Formatted Diff | Diff
Patch (20.04 KB, patch)
2012-05-21 04:06 PDT, Kinuko Yasuda
no flags Details | Formatted Diff | Diff
Patch (20.95 KB, patch)
2012-05-21 05:05 PDT, Kinuko Yasuda
no flags Details | Formatted Diff | Diff
Patch (20.97 KB, patch)
2012-05-21 05:09 PDT, Kinuko Yasuda
no flags Details | Formatted Diff | Diff
Patch (26.35 KB, patch)
2012-05-21 10:55 PDT, Kinuko Yasuda
no flags Details | Formatted Diff | Diff
Patch (26.64 KB, patch)
2012-05-24 02:16 PDT, Kinuko Yasuda
levin: review+
levin: commit-queue-
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Kinuko Yasuda 2012-05-21 01:21:16 PDT
Cleanup: add a file system call which captures the file metadata at once.

Current File.slice() (webkitSlice()) implementation calls two separate platform calls,
getFileSize() and getFileModificationTime() [both are defined in platform/FileSystem.h],
to capture the file metadata, but we should have a single file system call to get them at once
for two reasons: 1. save additional system call costs, and 2. atomically obtain the file metadata.
Comment 1 Kinuko Yasuda 2012-05-21 01:38:04 PDT
Created attachment 142967 [details]
Patch
Comment 2 WebKit Review Bot 2012-05-21 01:41:50 PDT
Please wait for approval from abarth@webkit.org, dglazkov@chromium.org, fishd@chromium.org, jamesr@chromium.org or tkent@chromium.org before submitting, as this patch contains changes to the Chromium public API. See also https://trac.webkit.org/wiki/ChromiumWebKitAPI.
Comment 3 Build Bot 2012-05-21 02:06:42 PDT
Comment on attachment 142967 [details]
Patch

Attachment 142967 [details] did not pass win-ews (win):
Output: http://queues.webkit.org/results/12741192
Comment 4 Kinuko Yasuda 2012-05-21 02:37:45 PDT
Created attachment 142975 [details]
Patch
Comment 5 Build Bot 2012-05-21 03:01:55 PDT
Comment on attachment 142975 [details]
Patch

Attachment 142975 [details] did not pass win-ews (win):
Output: http://queues.webkit.org/results/12744151
Comment 6 Kinuko Yasuda 2012-05-21 04:06:42 PDT
Created attachment 142989 [details]
Patch
Comment 7 Build Bot 2012-05-21 04:27:52 PDT
Comment on attachment 142989 [details]
Patch

Attachment 142989 [details] did not pass win-ews (win):
Output: http://queues.webkit.org/results/12736521
Comment 8 Kinuko Yasuda 2012-05-21 05:05:07 PDT
Created attachment 143003 [details]
Patch
Comment 9 Kinuko Yasuda 2012-05-21 05:09:47 PDT
Created attachment 143005 [details]
Patch
Comment 10 Adam Barth 2012-05-21 08:56:44 PDT
Comment on attachment 143005 [details]
Patch

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

> Source/Platform/chromium/public/WebFileUtilities.h:44
> +struct WebFileInfo;

Looks like you forgot to svn add WebFileInfo.h

> Source/Platform/chromium/public/WebFileUtilities.h:57
>      virtual bool getFileSize(const WebString& path, long long& result) { return false; }
>      virtual bool getFileModificationTime(const WebString& path, double& result) { return false; }

Should we mark these as deprecated and plan to delete them?
Comment 11 Adam Barth 2012-05-21 08:58:05 PDT
Actually, looks like it does exist at http://trac.webkit.org/browser/trunk/Source/WebKit/chromium/public/WebFileInfo.h.  Can you move it into Platform/chromium/public ?  The Source/Platform shouldn't refer to things in Source/WebKit
Comment 12 Kinuko Yasuda 2012-05-21 10:55:31 PDT
Created attachment 143059 [details]
Patch
Comment 13 Kinuko Yasuda 2012-05-21 10:57:06 PDT
Comment on attachment 143005 [details]
Patch

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

>> Source/Platform/chromium/public/WebFileUtilities.h:44
>> +struct WebFileInfo;
> 
> Looks like you forgot to svn add WebFileInfo.h

Moved Source/WebKit/chromium/public/WebFileInfo.h into Platform/chromium/public.

>> Source/Platform/chromium/public/WebFileUtilities.h:57
>>      virtual bool getFileModificationTime(const WebString& path, double& result) { return false; }
> 
> Should we mark these as deprecated and plan to delete them?

Sounds good, added a comment.
Comment 14 Kinuko Yasuda 2012-05-21 10:57:12 PDT
Comment on attachment 143005 [details]
Patch

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

>> Source/Platform/chromium/public/WebFileUtilities.h:44
>> +struct WebFileInfo;
> 
> Looks like you forgot to svn add WebFileInfo.h

Moved Source/WebKit/chromium/public/WebFileInfo.h into Platform/chromium/public.

>> Source/Platform/chromium/public/WebFileUtilities.h:57
>>      virtual bool getFileModificationTime(const WebString& path, double& result) { return false; }
> 
> Should we mark these as deprecated and plan to delete them?

Sounds good, added a comment.
Comment 15 Adam Barth 2012-05-21 11:01:22 PDT
Comment on attachment 143059 [details]
Patch

WebKit API changes LGTM
Comment 16 Kinuko Yasuda 2012-05-22 22:45:45 PDT
This isn't intended to change existing behavior but is intended to remove FIXME's in File and cleanup platform APIs.  (I also would like to use the new platform API for other purpose)
Jian, David could either of you take a look at the patch?  Thanks!
Comment 17 David Levin 2012-05-23 14:37:39 PDT
Comment on attachment 143059 [details]
Patch

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

r- see comments. I would do it in a dropdown but I have https://code.google.com/p/chromium/issues/detail?id=129444  to contend with :(.

> Source/WebCore/platform/posix/FileSystemPOSIX.cpp:199
> +    return true;

It feels like this code should be exactly like the code you added in FileSystemGtk.cpp (or visa versa) except for the g_stat vs stat. Why are there are other differences?

> Source/WebCore/platform/qt/FileSystemQt.cpp:80
> +    result.modificationTime = info.lastModified().toTime_t();

What data is being access if the file doesn't exist?

It feels sketchy to do this if !info.exists().

> Source/WebCore/platform/win/FileSystemWin.cpp:79
> +    return true;

Why return a bool at all if it always returns true?

> Source/WebCore/platform/wince/FileSystemWinCE.cpp:72
> +static void getFileSizeFromFileInfo(const BY_HANDLE_FILE_INFORMATION& fileInfo, long long& result)

result isn't very descriptive of what the variable contains.

> Source/WebCore/platform/wince/FileSystemWinCE.cpp:84
> +    result = t.QuadPart * 0.0000001 - 11644473600.0;

ditto re result (and in the other changes in this file).

> Source/WebCore/platform/wx/FileSystemWx.cpp:89
> +bool getFileMetadata(const String& path, FileMetadata& t)

avoid abbreviations "t"

> Source/WebKit/chromium/src/PlatformSupport.cpp:340
> +    result.type = static_cast<FileMetadata::Type>(webFileInfo.type);

Is there already a function to do this conversion (near some place with COMPILE_ASSERTS to verify that the values are the same)?
Comment 18 Kinuko Yasuda 2012-05-24 02:16:53 PDT
Created attachment 143768 [details]
Patch
Comment 19 Kinuko Yasuda 2012-05-24 02:20:40 PDT
Comment on attachment 143059 [details]
Patch

Thanks!! Updated the patch.

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

>> Source/WebCore/platform/posix/FileSystemPOSIX.cpp:199
>> +    return true;
> 
> It feels like this code should be exactly like the code you added in FileSystemGtk.cpp (or visa versa) except for the g_stat vs stat. Why are there are other differences?

Basically I followed other code in the same file (e.g. posix's getFileMetadata() is implemented after posix's getFileSize and getFileModificationTime), and coding convention / preferences in each platform looks slightly different.

>> Source/WebCore/platform/qt/FileSystemQt.cpp:80
>> +    result.modificationTime = info.lastModified().toTime_t();
> 
> What data is being access if the file doesn't exist?
> 
> It feels sketchy to do this if !info.exists().

Good catch, fixed to exit earlier.

>> Source/WebCore/platform/win/FileSystemWin.cpp:79
>> +    return true;
> 
> Why return a bool at all if it always returns true?

Fixed.

>> Source/WebCore/platform/wince/FileSystemWinCE.cpp:72
>> +static void getFileSizeFromFileInfo(const BY_HANDLE_FILE_INFORMATION& fileInfo, long long& result)
> 
> result isn't very descriptive of what the variable contains.

Fixed.

>> Source/WebCore/platform/wince/FileSystemWinCE.cpp:84
>> +    result = t.QuadPart * 0.0000001 - 11644473600.0;
> 
> ditto re result (and in the other changes in this file).

Fixed.

>> Source/WebCore/platform/wx/FileSystemWx.cpp:89
>> +bool getFileMetadata(const String& path, FileMetadata& t)
> 
> avoid abbreviations "t"

Fixed.

>> Source/WebKit/chromium/src/PlatformSupport.cpp:340
>> +    result.type = static_cast<FileMetadata::Type>(webFileInfo.type);
> 
> Is there already a function to do this conversion (near some place with COMPILE_ASSERTS to verify that the values are the same)?

Yes, we have assertions in WebKit/chromium/src/AssertMatchingEnums.cpp.
Comment 20 David Levin 2012-05-24 11:37:20 PDT
Comment on attachment 143768 [details]
Patch

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

Only two comments. Feel free to address and submit.

> Source/WebCore/platform/FileMetadata.h:57
> +#endif // ENABLE(FILE_SYSTEM)

The end comment for the if isn't necessary and doesn't seem very useful for such a short area.

> Source/WebCore/platform/chromium/FileSystemChromium.cpp:61
> +bool getFileMetadata(const String& path, FileMetadata& result)

result isn't very descriptive.

> Source/WebCore/platform/chromium/FileSystemChromium.cpp:70
> +    result.modificationTime = modificationTime;

Why doesn't this set type?
Comment 21 Kinuko Yasuda 2012-05-24 23:33:40 PDT
Thanks, will address them and submit.

(In reply to comment #20)
> (From update of attachment 143768 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=143768&action=review
> 
> Only two comments. Feel free to address and submit.
> 
> > Source/WebCore/platform/FileMetadata.h:57
> > +#endif // ENABLE(FILE_SYSTEM)
> 
> The end comment for the if isn't necessary and doesn't seem very useful for such a short area.

Will remove it.

> > Source/WebCore/platform/chromium/FileSystemChromium.cpp:61
> > +bool getFileMetadata(const String& path, FileMetadata& result)
> 
> result isn't very descriptive.

Will fix.

> > Source/WebCore/platform/chromium/FileSystemChromium.cpp:70
> > +    result.modificationTime = modificationTime;
> 
> Why doesn't this set type?

The type info isn't available until the chromium port implementation is landed (which will come shortly).  For now I I'll add more specific FIXME comment.
Comment 22 Kinuko Yasuda 2012-05-24 23:40:38 PDT
Committed r118481: <http://trac.webkit.org/changeset/118481>