Allow FileSystem API implementation to pass snapshot metadata at File creation time
authorkinuko@chromium.org <kinuko@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 17 May 2012 12:07:55 +0000 (12:07 +0000)
committerkinuko@chromium.org <kinuko@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 17 May 2012 12:07:55 +0000 (12:07 +0000)
commit790c738842cf2f8ae285b06745ec2fcce5555112
treee6ef53b826ee9d3146aa73a5f4a4132eb9fd374f
parentc52729a4bbe6ce21e7649a997f90839f7cf88bb4
Allow FileSystem API implementation to pass snapshot metadata at File creation time
https://bugs.webkit.org/show_bug.cgi?id=78879

Reviewed by Jian Li.

Source/WebCore:

We query File metadata (e.g. size and modifiedTime) when File.size,
lastModifiedTime or webkitSlice() is accessed / called, but in some
platform-specific filesystems it may not be feasible since synchronous
metadata query could take very long time.

This patch adds new File constructor which takes metadata argument
to allow each FileSystem API implementation to pass snapshot metadata
so that File object could cache the given metadata not to make
synchronous query.

We only call this constructor if the filesystem type is neither
Temporary nor Persistent, therefore this patch should not affect
existing code behavior.

Test: fast/filesystem/file-read-after-write.html

* Modules/filesystem/DOMFileSystem.cpp:
(WebCore::DOMFileSystem::createFile):
* Modules/filesystem/DOMFileSystemSync.cpp:
* fileapi/Blob.cpp:
(WebCore::Blob::webkitSlice): Updated implementation.
* fileapi/Blob.h:
* fileapi/File.cpp:
(WebCore::File::File): Added new constructor.
(WebCore::File::lastModifiedDate): Updated implementation.
(WebCore::File::size): Updated implementation.
(WebCore::File::captureSnapshot): Updated implementation.
* fileapi/File.h:
(WebCore::File::createForFileSystemFile): Added.
* platform/AsyncFileSystem.h:
(AsyncFileSystem): Updated comment.

LayoutTests:

Added tests for making sure metadata is not cached in the regular
temporary filesystem.

* fast/filesystem/file-metadata-after-write-expected.txt: Added.
* fast/filesystem/file-metadata-after-write.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@117432 268f45cc-cd09-0410-ab3c-d52691b4dbfc
LayoutTests/ChangeLog
LayoutTests/fast/filesystem/file-metadata-after-write-expected.txt [new file with mode: 0644]
LayoutTests/fast/filesystem/file-metadata-after-write.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/Modules/filesystem/DOMFileSystem.cpp
Source/WebCore/Modules/filesystem/DOMFileSystemSync.cpp
Source/WebCore/fileapi/File.cpp
Source/WebCore/fileapi/File.h
Source/WebCore/platform/AsyncFileSystem.h