Support cross-filesystem operations in FileSystem API
authorkinuko@chromium.org <kinuko@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 8 May 2012 03:34:47 +0000 (03:34 +0000)
committerkinuko@chromium.org <kinuko@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 8 May 2012 03:34:47 +0000 (03:34 +0000)
commit04a8189cf2f5bf2b8f0d232893444a0e705fb35e
treeb908f2f00c515a3176d820a765dce0a14984d677
parentd25bf66fa3d31528a7009c369e0922069362e60f
Support cross-filesystem operations in FileSystem API
https://bugs.webkit.org/show_bug.cgi?id=84135

Reviewed by David Levin.

Source/WebCore:

Currently we pass Entry's fullPath to AsyncFileSystem layer where
we convert the given path to filesystem URL which includes origin and
filesystem type information, but in that way we cannot handle
cross-filesystem operations (e.g. cross-filesystem copy and move)
well since we end up with always attaching the source filesystem's
origin and type information for argument paths.

This patch does:
- change AsyncFileSystem's operation methods not to take entry paths
  but complete filesystem URLs.
- move type and rootURL information from AsyncFileSystem instance into
  DOMFileSystemBase instance (platform layer to Modules/filesystem layer)
- move filesystem-type related code in AsyncFileSystemChromium.cpp into
  DOMFileSystemChromium.cpp, which implements chromioum-specific
  DOMFileSystem code.
- move platform/FileSystemType.h into Modules/filesystem/FileSystemType.h.
- adding FileSystemType.h entry to build files (e.g. WebCore.gypi, WebCore.xcodeproj etc)

Test: fast/filesystem/cross-filesystem-op.html

* Modules/filesystem/DOMFileSystem.cpp:
(WebCore::DOMFileSystem::create):
(WebCore::DOMFileSystem::DOMFileSystem):
(WebCore::DOMFileSystem::createWriter):
(WebCore::DOMFileSystem::createFile):
* Modules/filesystem/DOMFileSystem.h:
* Modules/filesystem/DOMFileSystemBase.cpp:
(WebCore::DOMFileSystemBase::DOMFileSystemBase):
(WebCore::DOMFileSystemBase::createFileSystemURL): Added as an internal
implementation of Entry.toURL().
(WebCore::DOMFileSystemBase::getMetadata):
(WebCore::verifyAndGetDestinationPathForCopyOrMove):
(WebCore::DOMFileSystemBase::move):
(WebCore::DOMFileSystemBase::copy):
(WebCore::DOMFileSystemBase::remove):
(WebCore::DOMFileSystemBase::removeRecursively):
(WebCore::DOMFileSystemBase::getParent):
(WebCore::DOMFileSystemBase::getFile):
(WebCore::DOMFileSystemBase::getDirectory):
(WebCore::DOMFileSystemBase::readDirectory):
* Modules/filesystem/DOMFileSystemBase.h: Changed to make each
DOMFileSystemBase instance have filesystem type and rootURL (they were
held by AsyncFileSystem previously)
(WebCore::DOMFileSystemBase::create): Changed to take additional parameters.
(WebCore::DOMFileSystemBase::type): Added.(Moved from AsyncFileSystem::type)
(WebCore::DOMFileSystemBase::rootURL): Added.(Moved from AsyncFileSystem::rootURL).
* Modules/filesystem/DOMFileSystemSync.cpp:
(WebCore::DOMFileSystemSync::create):
(WebCore::DOMFileSystemSync::DOMFileSystemSync):
(WebCore::DOMFileSystemSync::createFile):
(WebCore::DOMFileSystemSync::createWriter):
* Modules/filesystem/DOMFileSystemSync.h:
(WebCore::DOMFileSystemSync::create):
* Modules/filesystem/DOMWindowFileSystem.cpp:
(WebCore::DOMWindowFileSystem::webkitRequestFileSystem):
(WebCore::DOMWindowFileSystem::webkitResolveLocalFileSystemURL):
* Modules/filesystem/EntryBase.cpp:
(WebCore::EntryBase::toURL):
* Modules/filesystem/FileSystemCallbacks.cpp:
(WebCore::FileSystemCallbacks::create):
(WebCore::FileSystemCallbacks::FileSystemCallbacks):
(WebCore::FileSystemCallbacks::didOpenFileSystem):
(WebCore::ResolveURICallbacks::create):
(WebCore::ResolveURICallbacks::ResolveURICallbacks):
(WebCore::ResolveURICallbacks::didOpenFileSystem):
* Modules/filesystem/FileSystemCallbacks.h:
(FileSystemCallbacks):
(ResolveURICallbacks):
* Modules/filesystem/FileSystemType.h: Renamed from Source/WebCore/platform/FileSystemType.h.
* Modules/filesystem/LocalFileSystem.cpp:
(WebCore::openFileSystem):
(WebCore::LocalFileSystem::readFileSystem):
(WebCore::LocalFileSystem::requestFileSystem):
* Modules/filesystem/LocalFileSystem.h:
* Modules/filesystem/WorkerContextFileSystem.cpp:
(WebCore::WorkerContextFileSystem::webkitRequestFileSystem):
(WebCore::WorkerContextFileSystem::webkitRequestFileSystemSync):
(WebCore::WorkerContextFileSystem::webkitResolveLocalFileSystemURL):
(WebCore::WorkerContextFileSystem::webkitResolveLocalFileSystemSyncURL):
* Modules/filesystem/chromium/DOMFileSystemChromium.cpp: Added for chromium-specific
implementation. Almost all of the code is moved from AsyncFileSystemChromium.
(WebCore::DOMFileSystemBase::isValidType):
(WebCore::DOMFileSystemBase::crackFileSystemURL):
(WebCore::DOMFileSystemBase::supportsToURL):
(WebCore::DOMFileSystemBase::createFileSystemURL):
(WebCore::DOMFileSystemChromium::createIsolatedFileSystem):
* Modules/filesystem/chromium/DOMFileSystemChromium.h: Added.
* Modules/filesystem/chromium/DataTransferItemFileSystemChromium.cpp:
(WebCore::DataTransferItemFileSystem::webkitGetAsEntry):
* Modules/filesystem/chromium/DraggedIsolatedFileSystem.cpp:
(WebCore::DraggedIsolatedFileSystem::getDOMFileSystem):
* WebCore.gypi:
* platform/AsyncFileSystem.cpp:
(WebCore::AsyncFileSystem::openFileSystem):
* platform/AsyncFileSystem.h:
(AsyncFileSystem):
(WebCore::AsyncFileSystem::AsyncFileSystem):
* platform/AsyncFileSystemCallbacks.h:
(WebCore::AsyncFileSystemCallbacks::didOpenFileSystem):
* platform/blackberry/AsyncFileSystemBlackBerry.cpp:
(WebCore::AsyncFileSystem::create):
(WebCore::AsyncFileSystem::openFileSystem):
(WebCore::AsyncFileSystemBlackBerry::AsyncFileSystemBlackBerry):
(WebCore::AsyncFileSystemBlackBerry::move):
(WebCore::AsyncFileSystemBlackBerry::copy):
(WebCore::AsyncFileSystemBlackBerry::remove):
(WebCore::AsyncFileSystemBlackBerry::removeRecursively):
(WebCore::AsyncFileSystemBlackBerry::readMetadata):
(WebCore::AsyncFileSystemBlackBerry::createFile):
(WebCore::AsyncFileSystemBlackBerry::createDirectory):
(WebCore::AsyncFileSystemBlackBerry::fileExists):
(WebCore::AsyncFileSystemBlackBerry::directoryExists):
(WebCore::AsyncFileSystemBlackBerry::readDirectory):
(WebCore::AsyncFileSystemBlackBerry::createWriter):
(WebCore::AsyncFileSystemBlackBerry::createSnapshotFileAndReadMetadata):
* platform/blackberry/AsyncFileSystemBlackBerry.h:
* platform/chromium/PlatformSupport.h:
* platform/gtk/AsyncFileSystemGtk.cpp:
(WebCore::AsyncFileSystem::create):
(WebCore::AsyncFileSystem::openFileSystem):
(WebCore::AsyncFileSystemGtk::AsyncFileSystemGtk):
(WebCore::AsyncFileSystemGtk::move):
(WebCore::AsyncFileSystemGtk::copy):
(WebCore::AsyncFileSystemGtk::remove):
(WebCore::AsyncFileSystemGtk::removeRecursively):
(WebCore::AsyncFileSystemGtk::readMetadata):
(WebCore::AsyncFileSystemGtk::createFile):
(WebCore::AsyncFileSystemGtk::createDirectory):
(WebCore::AsyncFileSystemGtk::fileExists):
(WebCore::AsyncFileSystemGtk::directoryExists):
(WebCore::AsyncFileSystemGtk::readDirectory):
(WebCore::AsyncFileSystemGtk::createWriter):
* platform/gtk/AsyncFileSystemGtk.h:

* GNUmakefile.list.am: Added FileSystemType.h.
* WebCore.gypi: Added FileSystemType.h.
* WebCore.vcproj/WebCore.vcproj: Added FileSystemType.h.
* WebCore.xcodeproj/project.pbxproj: Added FileSystemType.h.

Source/WebKit/chromium:

Currently we pass Entry's fullPath to AsyncFileSystem layer where
we convert the given path to filesystem URL which includes origin and
filesystem type information, but in that way we cannot handle
cross-filesystem operations (e.g. cross-filesystem copy and move)
well since we end up with always attaching the source filesystem's
origin and type information for argument paths.

This patch does:
- move filesystem-type related code out of AsyncFileSystemChromium.cpp
  (moving into DOMFileSystemChromium.cpp)
- change AsyncFileSystemChromium's methods implementation not to take
  entry paths but complete filesystem URLs.

* src/AsyncFileSystemChromium.cpp:
(WebCore::AsyncFileSystemChromium::AsyncFileSystemChromium):
(WebCore::AsyncFileSystemChromium::move):
(WebCore::AsyncFileSystemChromium::copy):
(WebCore::AsyncFileSystemChromium::remove):
(WebCore::AsyncFileSystemChromium::removeRecursively):
(WebCore::AsyncFileSystemChromium::readMetadata):
(WebCore::AsyncFileSystemChromium::createFile):
(WebCore::AsyncFileSystemChromium::createDirectory):
(WebCore::AsyncFileSystemChromium::fileExists):
(WebCore::AsyncFileSystemChromium::directoryExists):
(WebCore::AsyncFileSystemChromium::readDirectory):
(WebCore::AsyncFileSystemChromium::createWriter):
(WebCore::AsyncFileSystemChromium::createSnapshotFileAndReadMetadata):
* src/AsyncFileSystemChromium.h:
(WebCore::AsyncFileSystemChromium::create):
(AsyncFileSystemChromium):
* src/LocalFileSystemChromium.cpp:
(WebCore::openFileSystemHelper):
* src/PlatformSupport.cpp:
(WebCore::PlatformSupport::createAsyncFileSystem):
* src/WebFileSystemCallbacksImpl.cpp:
(WebKit::WebFileSystemCallbacksImpl::WebFileSystemCallbacksImpl):
(WebKit::WebFileSystemCallbacksImpl::didOpenFileSystem):
* src/WebFileSystemCallbacksImpl.h:
(WebFileSystemCallbacksImpl):
* src/WebFrameImpl.cpp:
(WebKit::WebFrameImpl::createFileSystem):
(WebKit::WebFrameImpl::createFileEntry):
* src/WorkerAsyncFileSystemChromium.cpp:
(WebCore::WorkerAsyncFileSystemChromium::WorkerAsyncFileSystemChromium):
(WebCore::WorkerAsyncFileSystemChromium::move):
(WebCore::WorkerAsyncFileSystemChromium::copy):
(WebCore::WorkerAsyncFileSystemChromium::remove):
(WebCore::WorkerAsyncFileSystemChromium::removeRecursively):
(WebCore::WorkerAsyncFileSystemChromium::readMetadata):
(WebCore::WorkerAsyncFileSystemChromium::createFile):
(WebCore::WorkerAsyncFileSystemChromium::createDirectory):
(WebCore::WorkerAsyncFileSystemChromium::fileExists):
(WebCore::WorkerAsyncFileSystemChromium::directoryExists):
(WebCore::WorkerAsyncFileSystemChromium::readDirectory):
(WebCore::WorkerAsyncFileSystemChromium::createWriter):
(WebCore::WorkerAsyncFileSystemChromium::createSnapshotFileAndReadMetadata):
* src/WorkerAsyncFileSystemChromium.h:
(WebCore::WorkerAsyncFileSystemChromium::create):
(WorkerAsyncFileSystemChromium):

LayoutTests:

* fast/filesystem/cross-filesystem-op-expected.txt: Added.
* fast/filesystem/cross-filesystem-op.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@116388 268f45cc-cd09-0410-ab3c-d52691b4dbfc
44 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/filesystem/cross-filesystem-op-expected.txt [new file with mode: 0644]
LayoutTests/fast/filesystem/cross-filesystem-op.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/GNUmakefile.list.am
Source/WebCore/Modules/filesystem/DOMFileSystem.cpp
Source/WebCore/Modules/filesystem/DOMFileSystem.h
Source/WebCore/Modules/filesystem/DOMFileSystemBase.cpp
Source/WebCore/Modules/filesystem/DOMFileSystemBase.h
Source/WebCore/Modules/filesystem/DOMFileSystemSync.cpp
Source/WebCore/Modules/filesystem/DOMFileSystemSync.h
Source/WebCore/Modules/filesystem/DOMWindowFileSystem.cpp
Source/WebCore/Modules/filesystem/EntryBase.cpp
Source/WebCore/Modules/filesystem/FileSystemCallbacks.cpp
Source/WebCore/Modules/filesystem/FileSystemCallbacks.h
Source/WebCore/Modules/filesystem/FileSystemType.h [moved from Source/WebCore/platform/FileSystemType.h with 100% similarity]
Source/WebCore/Modules/filesystem/LocalFileSystem.cpp
Source/WebCore/Modules/filesystem/LocalFileSystem.h
Source/WebCore/Modules/filesystem/WorkerContextFileSystem.cpp
Source/WebCore/Modules/filesystem/chromium/DOMFileSystemChromium.cpp [new file with mode: 0644]
Source/WebCore/Modules/filesystem/chromium/DOMFileSystemChromium.h [new file with mode: 0644]
Source/WebCore/Modules/filesystem/chromium/DataTransferItemFileSystemChromium.cpp
Source/WebCore/Modules/filesystem/chromium/DraggedIsolatedFileSystem.cpp
Source/WebCore/WebCore.gypi
Source/WebCore/WebCore.vcproj/WebCore.vcproj
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/platform/AsyncFileSystem.cpp
Source/WebCore/platform/AsyncFileSystem.h
Source/WebCore/platform/AsyncFileSystemCallbacks.h
Source/WebCore/platform/blackberry/AsyncFileSystemBlackBerry.cpp
Source/WebCore/platform/blackberry/AsyncFileSystemBlackBerry.h
Source/WebCore/platform/chromium/PlatformSupport.h
Source/WebCore/platform/gtk/AsyncFileSystemGtk.cpp
Source/WebCore/platform/gtk/AsyncFileSystemGtk.h
Source/WebKit/chromium/ChangeLog
Source/WebKit/chromium/src/AsyncFileSystemChromium.cpp
Source/WebKit/chromium/src/AsyncFileSystemChromium.h
Source/WebKit/chromium/src/LocalFileSystemChromium.cpp
Source/WebKit/chromium/src/PlatformSupport.cpp
Source/WebKit/chromium/src/WebFileSystemCallbacksImpl.cpp
Source/WebKit/chromium/src/WebFileSystemCallbacksImpl.h
Source/WebKit/chromium/src/WebFrameImpl.cpp
Source/WebKit/chromium/src/WorkerAsyncFileSystemChromium.cpp
Source/WebKit/chromium/src/WorkerAsyncFileSystemChromium.h