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)
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

index a47247b..ceb838c 100644 (file)
@@ -1,3 +1,13 @@
+2012-05-07  Kinuko Yasuda  <kinuko@chromium.org>
+
+        Support cross-filesystem operations in FileSystem API
+        https://bugs.webkit.org/show_bug.cgi?id=84135
+
+        Reviewed by David Levin.
+
+        * fast/filesystem/cross-filesystem-op-expected.txt: Added.
+        * fast/filesystem/cross-filesystem-op.html: Added.
+
 2012-05-07  Ojan Vafai  <ojan@chromium.org>
 
         Chromium rebaselines after http://trac.webkit.org/changeset/116373.
diff --git a/LayoutTests/fast/filesystem/cross-filesystem-op-expected.txt b/LayoutTests/fast/filesystem/cross-filesystem-op-expected.txt
new file mode 100644 (file)
index 0000000..2f0f148
--- /dev/null
@@ -0,0 +1,39 @@
+This tests basic cross-filesystem operations.
+Drop files here if you test this manually
+Verifying contents of DataTransferItems...
+PASS: "1" == "1"
+PASS: "file" == "file"
+PASS: "true" == "true"
+Successfully setup test environment.
+file__0:Temporary: reset /test
+Testing copyTo apple.gif: /resources => /test
+PASS: "apple.gif" == "apple.gif"
+PASS: "1476" == "1476"
+Testing copyTo mozilla.gif: /resources => /test
+PASS: "mozilla.gif" == "mozilla.gif"
+PASS: "2593" == "2593"
+Testing copyTo drop-file-svg.svg: /resources => /test
+PASS: "drop-file-svg.svg" == "drop-file-svg.svg"
+PASS: "109" == "109"
+Testing copyTo copy-backslash-euc.html: /resources => /test
+PASS: "copy-backslash-euc.html" == "copy-backslash-euc.html"
+PASS: "478" == "478"
+Testing copyTo test_directory/test.txt: /resources => /test
+PASS: "test.txt" == "test.txt"
+PASS: "13" == "13"
+file__0:Temporary: reset /test
+Testing copyTo mozilla.gif: /resources => /test
+PASS: "mozilla.gif" == "mozilla.gif"
+PASS: "2593" == "2593"
+Testing copyTo drop-file-svg.svg: /resources => /test
+PASS: "drop-file-svg.svg" == "drop-file-svg.svg"
+PASS: "109" == "109"
+Testing copyTo copy-backslash-euc.html: /resources => /test
+PASS: "copy-backslash-euc.html" == "copy-backslash-euc.html"
+PASS: "478" == "478"
+Testing copyTo test_directory/test.txt: /resources => /test
+PASS: "test.txt" == "test.txt"
+PASS: "13" == "13"
+Successfully ran 2 tests.
+Cleanup done.
+
diff --git a/LayoutTests/fast/filesystem/cross-filesystem-op.html b/LayoutTests/fast/filesystem/cross-filesystem-op.html
new file mode 100644 (file)
index 0000000..6352cfa
--- /dev/null
@@ -0,0 +1,264 @@
+<html>
+<body>
+<div>This tests basic cross-filesystem operations.</div>
+
+<div id="destination" style="min-height:100px; border: solid 1px black">Drop files here if you test this manually</div>
+
+<div id="console"></div>
+
+<script>
+var methods = [ 'copyTo', 'moveTo' ];
+var sourceTestDirectory, destTestDirectory;
+
+var destDirectoryPath = '/test';
+var sourceDirectoryPath = '../../editing/pasteboard/resources';
+
+// Actual files in the sourceDirectoryPath.
+var testFiles = [
+    { path:'apple.gif' },
+    { path:'mozilla.gif' },
+    { path:'drop-file-svg.svg' },
+    { path:'copy-backslash-euc.html' },
+    { path:'test_directory', directory:true },
+    { path:'test_directory/test.txt' }
+];
+
+// Note: for now we don't run moveTo test since drag-and-drop isolated
+// filesystem, which we use for source filesystem, is read-only.
+// FIXME: allow writing to PERSISTENT filesystem without quota error in
+// DumpRenderTree so that we can test TEMPORARY <-> PERSISTENT cross operation
+// checks.
+var tests = [
+    testCopyFile,
+    testCopyDirectory,
+];
+
+function log(text)
+{
+    var console = document.getElementById('console');
+    console.appendChild(document.createTextNode(text));
+    console.appendChild(document.createElement('br'));
+}
+
+function test(expect, actual)
+{
+    log((expect == actual ? 'PASS' : 'FAIL') + ': "' + expect + '" == "' + actual + '"');
+}
+
+
+function errorCallback(msg)
+{
+    return function(e) {
+        console.log(e);
+        log('ERROR:' + msg + ': ' + e.code);
+        if (window.layoutTestController)
+            layoutTestController.notifyDone();
+    };
+}
+
+function setupDestFileSystem(successCallback) {
+    webkitRequestFileSystem(window.TEMPORARY, 1024, function (fs) {
+        fs.root.getDirectory(
+            destDirectoryPath,
+            {create:true},
+            function (entry) {
+                destTestDirectory = entry;
+                successCallback();
+            },
+            errorCallback('dest: createDirectory(' + destDirectoryPath + ')'));
+    }, errorCallback('dest: requestFileSystem for PERSISTENT'));
+}
+
+function runTests(index, successCallback) {
+    if (index >= tests.length) {
+        successCallback();
+        return;
+    }
+    var next = function() { runTests(index + 1, successCallback); };
+    resetDirectory(destTestDirectory, function() { tests[index](next); });
+}
+
+function testCopyFile(successCallback) {
+    testOnFile(0, 'copyTo', successCallback);
+}
+
+function testCopyDirectory(successCallback) {
+    testOnDirectory(0, 'copyTo', successCallback);
+}
+
+function testOnFile(index, method, successCallback) {
+    if (index >= testFiles.length) {
+        successCallback();
+        return;
+    }
+    var next = function() { testOnFile(index + 1, method, successCallback); };
+    if (testFiles[index].directory) {
+        next();
+        return;
+    }
+    var file = testFiles[index];
+    log('Testing ' + method + ' ' + file.path + ': ' + sourceTestDirectory.fullPath + ' => ' + destTestDirectory.fullPath);
+    sourceTestDirectory.getFile(
+        file.path, {create:false}, function(source) {
+            source[method](destTestDirectory, '', function(dest) {
+                verifyFile(source, dest, next);
+            }, errorCallback('testOnFile: ' + method + ':' + file.path));
+        }, errorCallback('testOnFile: getFile:' + file.path));
+}
+
+function testOnDirectory(index, method, successCallback) {
+    if (index >= testFiles.length) {
+        successCallback();
+        return;
+    }
+    var next = function() { testOnFile(index + 1, method, successCallback); };
+    if (!testFiles[index].directory) {
+        next();
+        return;
+    }
+    var file = testFiles[index];
+    log('Testing ' + method + ' ' + file.path + ': ' + sourceTestDirectory.fullPath + ' => ' + destTestDirectory.fullPath);
+    sourceTestDirectory.getDirectory(
+        file.path, {create:false}, function(source) {
+            source[method](destTestDirectory, '', function(dest) {
+                verifyFile(source, dest, next);
+            }, errorCallback('testOnDirectory: ' + method + ':' + file.path));
+        }, errorCallback('testOnDirectory: getDirectory:' + file.path));
+}
+
+function verifyFile(source, dest, successCallback) {
+    test(source.name, dest.name);
+    source.getMetadata(function(sourceMetadata) {
+        var expectedSize = sourceMetadata.size;
+        dest.getMetadata(function(destMetadata) {
+            test(expectedSize, destMetadata.size);
+            successCallback();
+        }, errorCallback('getMetadata:' + dest.fullPath));
+    }, errorCallback('getMetadata:' + source.fullPath));
+}
+
+function verifyDirectory(source, dest, successCallback) {
+    getDirectoryEntries(source, function(sourceEntries) {
+        getDirectoryEntries(dest, function(destEntries) {
+            sourceEntries.sort();
+            destEntries.sort();
+            test(sourceEntries.length, destEntries.length);
+            var verifyOne = function(index) {
+                verifyFile(sourceEntries[index], destEntries[index], function() {
+                    if (index >= sourceEntries.length) {
+                        successCallback();
+                        return;
+                    }
+                    verifyOne(index + 1);
+                });
+            };
+            verifyOne(0);
+        });
+    });
+}
+
+function getDirectoryEntries(entry, entriesCallback) {
+    var allEntries = [];
+    var addEntries = function(entries, continueCallback) {
+        if (entries.length == 0) {
+            entriesCallback(allEntries);
+            return;
+        }
+        allEntries.concat(entries);
+        if (entries.length != 0) continueCallback();
+    };
+    var entriesCallback = function(entries) {
+        addEntries(entries, successCallback, function() {
+            reader.readDirectory(entriesCallback);
+        });
+    };
+    var reader = entry.createReader();
+    reader.readDirectory(entriesCallback, errorCallback('readDirectory: ' + entry.fullPath));
+}
+
+function cleanupDirectory(directory, successCallback) {
+    directory.removeRecursively(
+        successCallback,
+        errorCallback('removeRecursively:' + directory.fullPath));
+}
+
+function resetDirectory(directory, successCallback) {
+    var fs = directory.filesystem;
+    var path = directory.fullPath;
+    cleanupDirectory(directory, function() {
+        fs.root.getDirectory(path, {create:true},
+                             function () {
+                                log(fs.name + ': reset ' + path);
+                                successCallback();
+                             }, errorCallback('getDirectory(create):' + path));
+    });
+}
+
+function setupFiles(root, index, successCallback)
+{
+    if (index >= testFiles.length) {
+        successCallback();
+        return;
+    }
+    var file = testFiles[index];
+    var msg = 'create testFiles[' + index + ']: ' + file.path;
+    var callback = function(entry) { setupFiles(root, index + 1, successCallback); };
+    if (file.directory) {
+        root.getDirectory(destDirectoryPath + '/' + file.path, {create:true}, callback, errorCallback(msg));
+        return;
+    }
+
+    root.getFile(file.path, {create:true}, function(entry) {
+        entry.createWriter(function (writer) {
+            writer.truncate(file.size);
+            writer.onerror = errorCallback('truncate ' + entry.fullPath);
+            writer.onwriteend = callback;
+        }, errorCallback('create writer for ' + entry.fullPath));
+    }, errorCallback(msg));
+}
+
+function startTest(e) {
+    e.stopPropagation(e);
+    e.preventDefault();
+
+    log('Verifying contents of DataTransferItems...');
+    var items = e.dataTransfer.items;
+    test(1, items.length);
+    test('file', items[0].kind);
+    items[0].webkitGetAsEntry(function(entry) {
+        test(true, entry.isDirectory);
+        sourceTestDirectory = entry;
+        setupDestFileSystem(function() {
+            log('Successfully setup test environment.');
+            runTests(0, function() {
+                log('Successfully ran ' + tests.length + ' tests.');
+                cleanupDirectory(destTestDirectory, function() {
+                    log('Cleanup done.');
+                    if (window.layoutTestController)
+                        layoutTestController.notifyDone();
+                });
+            });
+        });
+    });
+}
+
+var destination = document.getElementById('destination');
+destination.addEventListener('dragover', function(e) {
+    e.stopPropagation();
+    e.preventDefault();
+}, false);
+destination.addEventListener('drop', startTest, false);
+
+if (window.layoutTestController) {
+    layoutTestController.waitUntilDone();
+    layoutTestController.dumpAsText();
+
+    eventSender.beginDragWithFiles([sourceDirectoryPath]);
+    eventSender.leapForward(100);
+    eventSender.mouseMoveTo(destination.offsetLeft + 10, destination.offsetTop + destination.offsetHeight / 2);
+    eventSender.mouseUp();
+}
+
+</script>
+</body>
+</html>
index c55c86a..e57b957 100644 (file)
@@ -1,3 +1,149 @@
+2012-05-07  Kinuko Yasuda  <kinuko@chromium.org>
+
+        Support cross-filesystem operations in FileSystem API
+        https://bugs.webkit.org/show_bug.cgi?id=84135
+
+        Reviewed by David Levin.
+
+        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.
+
 2012-05-07  Adam Barth  <abarth@webkit.org>
 
         [Chromium] Android wishes to use an empty implementation if AXObjectCache
index 916286d..538b92a 100644 (file)
@@ -1027,6 +1027,7 @@ webcore_modules_sources += \
        Source/WebCore/Modules/filesystem/FileSystemCallback.h \
        Source/WebCore/Modules/filesystem/FileSystemCallbacks.cpp \
        Source/WebCore/Modules/filesystem/FileSystemCallbacks.h \
+       Source/WebCore/Modules/filesystem/FileSystemType.h \
        Source/WebCore/Modules/filesystem/FileWriter.cpp \
        Source/WebCore/Modules/filesystem/FileWriter.h \
        Source/WebCore/Modules/filesystem/FileWriterBase.cpp \
index d36ee1d..090bcc0 100644 (file)
 namespace WebCore {
 
 // static
-PassRefPtr<DOMFileSystem> DOMFileSystem::create(ScriptExecutionContext* context, const String& name, PassOwnPtr<AsyncFileSystem> asyncFileSystem)
+PassRefPtr<DOMFileSystem> DOMFileSystem::create(ScriptExecutionContext* context, const String& name, FileSystemType type, const KURL& rootURL, PassOwnPtr<AsyncFileSystem> asyncFileSystem)
 {
-    RefPtr<DOMFileSystem> fileSystem(adoptRef(new DOMFileSystem(context, name, asyncFileSystem)));
+    RefPtr<DOMFileSystem> fileSystem(adoptRef(new DOMFileSystem(context, name, type, rootURL, asyncFileSystem)));
     fileSystem->suspendIfNeeded();
     InspectorInstrumentation::didOpenFileSystem(fileSystem.get());
     return fileSystem.release();
 }
 
-DOMFileSystem::DOMFileSystem(ScriptExecutionContext* context, const String& name, PassOwnPtr<AsyncFileSystem> asyncFileSystem)
-    : DOMFileSystemBase(context, name, asyncFileSystem)
+DOMFileSystem::DOMFileSystem(ScriptExecutionContext* context, const String& name, FileSystemType type, const KURL& rootURL, PassOwnPtr<AsyncFileSystem> asyncFileSystem)
+    : DOMFileSystemBase(context, name, type, rootURL, asyncFileSystem)
     , ActiveDOMObject(context, this)
 {
 }
@@ -118,7 +118,7 @@ void DOMFileSystem::createWriter(const FileEntry* fileEntry, PassRefPtr<FileWrit
     RefPtr<FileWriter> fileWriter = FileWriter::create(scriptExecutionContext());
     RefPtr<FileWriterBaseCallback> conversionCallback = ConvertToFileWriterCallback::create(successCallback);
     OwnPtr<FileWriterBaseCallbacks> callbacks = FileWriterBaseCallbacks::create(fileWriter, conversionCallback, errorCallback);
-    m_asyncFileSystem->createWriter(fileWriter.get(), fileEntry->fullPath(), callbacks.release());
+    m_asyncFileSystem->createWriter(fileWriter.get(), createFileSystemURL(fileEntry), callbacks.release());
 }
 
 namespace {
@@ -158,7 +158,7 @@ private:
 
 void DOMFileSystem::createFile(const FileEntry* fileEntry, PassRefPtr<FileCallback> successCallback, PassRefPtr<ErrorCallback> errorCallback)
 {
-    m_asyncFileSystem->createSnapshotFileAndReadMetadata(fileEntry->fullPath(), GetPathCallback::create(this, fileEntry->name(), successCallback, errorCallback));
+    m_asyncFileSystem->createSnapshotFileAndReadMetadata(createFileSystemURL(fileEntry), GetPathCallback::create(this, fileEntry->name(), successCallback, errorCallback));
 }
 
 } // namespace WebCore
index 74fa9ac..7f5ebcd 100644 (file)
@@ -47,7 +47,7 @@ class FileWriterCallback;
 
 class DOMFileSystem : public DOMFileSystemBase, public ActiveDOMObject {
 public:
-    static PassRefPtr<DOMFileSystem> create(ScriptExecutionContext*, const String& name, PassOwnPtr<AsyncFileSystem>);
+    static PassRefPtr<DOMFileSystem> create(ScriptExecutionContext*, const String& name, FileSystemType, const KURL& rootURL, PassOwnPtr<AsyncFileSystem>);
 
     PassRefPtr<DirectoryEntry> root();
 
@@ -71,7 +71,7 @@ public:
     }
 
 private:
-    DOMFileSystem(ScriptExecutionContext*, const String& name, PassOwnPtr<AsyncFileSystem>);
+    DOMFileSystem(ScriptExecutionContext*, const String& name, FileSystemType, const KURL& rootURL, PassOwnPtr<AsyncFileSystem>);
 
     // A helper template to schedule a callback task.
     template <typename CB, typename CBArg>
index 4335ab9..62fcea0 100644 (file)
 
 namespace WebCore {
 
-DOMFileSystemBase::DOMFileSystemBase(ScriptExecutionContext* context, const String& name, PassOwnPtr<AsyncFileSystem> asyncFileSystem)
+const char DOMFileSystemBase::persistentPathPrefix[] = "persistent";
+const size_t DOMFileSystemBase::persistentPathPrefixLength = sizeof(DOMFileSystemBase::persistentPathPrefix) - 1;
+const char DOMFileSystemBase::temporaryPathPrefix[] = "temporary";
+const size_t DOMFileSystemBase::temporaryPathPrefixLength = sizeof(DOMFileSystemBase::temporaryPathPrefix) - 1;
+
+DOMFileSystemBase::DOMFileSystemBase(ScriptExecutionContext* context, const String& name, FileSystemType type, const KURL& rootURL, PassOwnPtr<AsyncFileSystem> asyncFileSystem)
     : m_context(context)
     , m_name(name)
+    , m_type(type)
+    , m_filesystemRootURL(rootURL)
     , m_asyncFileSystem(asyncFileSystem)
 {
 }
@@ -66,9 +73,14 @@ SecurityOrigin* DOMFileSystemBase::securityOrigin() const
     return m_context->securityOrigin();
 }
 
+KURL DOMFileSystemBase::createFileSystemURL(const EntryBase* entry) const
+{
+    return createFileSystemURL(entry->fullPath());
+}
+
 bool DOMFileSystemBase::getMetadata(const EntryBase* entry, PassRefPtr<MetadataCallback> successCallback, PassRefPtr<ErrorCallback> errorCallback)
 {
-    m_asyncFileSystem->readMetadata(entry->fullPath(), MetadataCallbacks::create(successCallback, errorCallback));
+    m_asyncFileSystem->readMetadata(createFileSystemURL(entry), MetadataCallbacks::create(successCallback, errorCallback));
     return true;
 }
 
@@ -82,12 +94,14 @@ static bool verifyAndGetDestinationPathForCopyOrMove(const EntryBase* source, En
     if (!newName.isEmpty() && !DOMFilePath::isValidName(newName))
         return false;
 
+    const bool isSameFileSystem = (*source->filesystem() == *parent->filesystem());
+
     // It is an error to try to copy or move an entry inside itself at any depth if it is a directory.
-    if (source->isDirectory() && DOMFilePath::isParentOf(source->fullPath(), parent->fullPath()))
+    if (source->isDirectory() && isSameFileSystem && DOMFilePath::isParentOf(source->fullPath(), parent->fullPath()))
         return false;
 
     // It is an error to copy or move an entry into its parent if a name different from its current one isn't provided.
-    if ((newName.isEmpty() || source->name() == newName) && DOMFilePath::getDirectory(source->fullPath()) == parent->fullPath())
+    if (isSameFileSystem && (newName.isEmpty() || source->name() == newName) && DOMFilePath::getDirectory(source->fullPath()) == parent->fullPath())
         return false;
 
     destinationPath = parent->fullPath();
@@ -118,7 +132,7 @@ bool DOMFileSystemBase::move(const EntryBase* source, EntryBase* parent, const S
     if (!verifyAndGetDestinationPathForCopyOrMove(source, parent, newName, destinationPath))
         return false;
 
-    m_asyncFileSystem->move(source->fullPath(), destinationPath, EntryCallbacks::create(successCallback, errorCallback, this, destinationPath, source->isDirectory()));
+    m_asyncFileSystem->move(createFileSystemURL(source), parent->filesystem()->createFileSystemURL(destinationPath), EntryCallbacks::create(successCallback, errorCallback, parent->filesystem(), destinationPath, source->isDirectory()));
     return true;
 }
 
@@ -128,7 +142,7 @@ bool DOMFileSystemBase::copy(const EntryBase* source, EntryBase* parent, const S
     if (!verifyAndGetDestinationPathForCopyOrMove(source, parent, newName, destinationPath))
         return false;
 
-    m_asyncFileSystem->copy(source->fullPath(), destinationPath, EntryCallbacks::create(successCallback, errorCallback, this, destinationPath, source->isDirectory()));
+    m_asyncFileSystem->copy(createFileSystemURL(source), parent->filesystem()->createFileSystemURL(destinationPath), EntryCallbacks::create(successCallback, errorCallback, parent->filesystem(), destinationPath, source->isDirectory()));
     return true;
 }
 
@@ -138,7 +152,7 @@ bool DOMFileSystemBase::remove(const EntryBase* entry, PassRefPtr<VoidCallback>
     // We don't allow calling remove() on the root directory.
     if (entry->fullPath() == String(DOMFilePath::root))
         return false;
-    m_asyncFileSystem->remove(entry->fullPath(), VoidCallbacks::create(successCallback, errorCallback));
+    m_asyncFileSystem->remove(createFileSystemURL(entry), VoidCallbacks::create(successCallback, errorCallback));
     return true;
 }
 
@@ -148,7 +162,7 @@ bool DOMFileSystemBase::removeRecursively(const EntryBase* entry, PassRefPtr<Voi
     // We don't allow calling remove() on the root directory.
     if (entry->fullPath() == String(DOMFilePath::root))
         return false;
-    m_asyncFileSystem->removeRecursively(entry->fullPath(), VoidCallbacks::create(successCallback, errorCallback));
+    m_asyncFileSystem->removeRecursively(createFileSystemURL(entry), VoidCallbacks::create(successCallback, errorCallback));
     return true;
 }
 
@@ -157,42 +171,42 @@ bool DOMFileSystemBase::getParent(const EntryBase* entry, PassRefPtr<EntryCallba
     ASSERT(entry);
     String path = DOMFilePath::getDirectory(entry->fullPath());
 
-    m_asyncFileSystem->directoryExists(path, EntryCallbacks::create(successCallback, errorCallback, this, path, true));
+    m_asyncFileSystem->directoryExists(createFileSystemURL(path), EntryCallbacks::create(successCallback, errorCallback, this, path, true));
     return true;
 }
 
 bool DOMFileSystemBase::getFile(const EntryBase* entry, const String& path, PassRefPtr<WebKitFlags> flags, PassRefPtr<EntryCallback> successCallback, PassRefPtr<ErrorCallback> errorCallback)
 {
     String absolutePath;
-    if (!pathToAbsolutePath(m_asyncFileSystem->type(), entry, path, absolutePath))
+    if (!pathToAbsolutePath(m_type, entry, path, absolutePath))
         return false;
 
     OwnPtr<EntryCallbacks> callbacks = EntryCallbacks::create(successCallback, errorCallback, this, absolutePath, false);
     if (flags && flags->isCreate())
-        m_asyncFileSystem->createFile(absolutePath, flags->isExclusive(), callbacks.release());
+        m_asyncFileSystem->createFile(createFileSystemURL(absolutePath), flags->isExclusive(), callbacks.release());
     else
-        m_asyncFileSystem->fileExists(absolutePath, callbacks.release());
+        m_asyncFileSystem->fileExists(createFileSystemURL(absolutePath), callbacks.release());
     return true;
 }
 
 bool DOMFileSystemBase::getDirectory(const EntryBase* entry, const String& path, PassRefPtr<WebKitFlags> flags, PassRefPtr<EntryCallback> successCallback, PassRefPtr<ErrorCallback> errorCallback)
 {
     String absolutePath;
-    if (!pathToAbsolutePath(m_asyncFileSystem->type(), entry, path, absolutePath))
+    if (!pathToAbsolutePath(m_type, entry, path, absolutePath))
         return false;
 
     OwnPtr<EntryCallbacks> callbacks = EntryCallbacks::create(successCallback, errorCallback, this, absolutePath, true);
     if (flags && flags->isCreate())
-        m_asyncFileSystem->createDirectory(absolutePath, flags->isExclusive(), callbacks.release());
+        m_asyncFileSystem->createDirectory(createFileSystemURL(absolutePath), flags->isExclusive(), callbacks.release());
     else
-        m_asyncFileSystem->directoryExists(absolutePath, callbacks.release());
+        m_asyncFileSystem->directoryExists(createFileSystemURL(absolutePath), callbacks.release());
     return true;
 }
 
 bool DOMFileSystemBase::readDirectory(PassRefPtr<DirectoryReaderBase> reader, const String& path, PassRefPtr<EntriesCallback> successCallback, PassRefPtr<ErrorCallback> errorCallback)
 {
     ASSERT(DOMFilePath::isAbsolute(path));
-    m_asyncFileSystem->readDirectory(path, EntriesCallbacks::create(successCallback, errorCallback, reader, path));
+    m_asyncFileSystem->readDirectory(createFileSystemURL(path), EntriesCallbacks::create(successCallback, errorCallback, reader, path));
     return true;
 }
 
index 42f0db5..8ea4fe2 100644 (file)
@@ -34,6 +34,8 @@
 #if ENABLE(FILE_SYSTEM)
 
 #include "AsyncFileSystem.h"
+#include "FileSystemType.h"
+#include "KURL.h"
 #include "PlatformString.h"
 #include "WebKitFlags.h"
 #include <wtf/PassRefPtr.h>
@@ -47,7 +49,6 @@ class EntriesCallback;
 class EntryBase;
 class EntryCallback;
 class ErrorCallback;
-class KURL;
 class MetadataCallback;
 class ScriptExecutionContext;
 class SecurityOrigin;
@@ -56,16 +57,31 @@ class VoidCallback;
 // A common base class for DOMFileSystem and DOMFileSystemSync.
 class DOMFileSystemBase : public RefCounted<DOMFileSystemBase> {
 public:
-    static PassRefPtr<DOMFileSystemBase> create(ScriptExecutionContext* context, const String& name, PassOwnPtr<AsyncFileSystem> asyncFileSystem)
+    // Path prefixes that are used in the filesystem URLs (that can be obtained by toURL()).
+    // http://www.w3.org/TR/file-system-api/#widl-Entry-toURL
+    static const char persistentPathPrefix[];
+    static const size_t persistentPathPrefixLength;
+    static const char temporaryPathPrefix[];
+    static const size_t temporaryPathPrefixLength;
+
+    static PassRefPtr<DOMFileSystemBase> create(ScriptExecutionContext* context, const String& name, FileSystemType type, const KURL& rootURL, PassOwnPtr<AsyncFileSystem> asyncFileSystem)
     {
-        return adoptRef(new DOMFileSystemBase(context, name, asyncFileSystem));
+        return adoptRef(new DOMFileSystemBase(context, name, type, rootURL, asyncFileSystem));
     }
     virtual ~DOMFileSystemBase();
 
     const String& name() const { return m_name; }
+    FileSystemType type() const { return m_type; }
+    KURL rootURL() const { return m_filesystemRootURL; }
     AsyncFileSystem* asyncFileSystem() const { return m_asyncFileSystem.get(); }
     SecurityOrigin* securityOrigin() const;
 
+    static bool isValidType(FileSystemType);
+    static bool crackFileSystemURL(const KURL&, FileSystemType&, String& filePath);
+    bool supportsToURL() const;
+    KURL createFileSystemURL(const EntryBase*) const;
+    KURL createFileSystemURL(const String& fullPath) const;
+
     // Actual FileSystem API implementations. All the validity checks on virtual paths are done at this level.
     // They return false for immediate errors that don't involve lower AsyncFileSystem layer (e.g. for name validation errors). Otherwise they return true (but later may call back with an runtime error).
     bool getMetadata(const EntryBase*, PassRefPtr<MetadataCallback>, PassRefPtr<ErrorCallback>);
@@ -79,14 +95,19 @@ public:
     bool readDirectory(PassRefPtr<DirectoryReaderBase>, const String& path, PassRefPtr<EntriesCallback>, PassRefPtr<ErrorCallback>);
 
 protected:
-    DOMFileSystemBase(ScriptExecutionContext*, const String& name, PassOwnPtr<AsyncFileSystem>);
+    DOMFileSystemBase(ScriptExecutionContext*, const String& name, FileSystemType, const KURL& rootURL, PassOwnPtr<AsyncFileSystem>);
     friend class DOMFileSystemSync;
 
     ScriptExecutionContext* m_context;
     String m_name;
+    FileSystemType m_type;
+    KURL m_filesystemRootURL;
+
     mutable OwnPtr<AsyncFileSystem> m_asyncFileSystem;
 };
 
+inline bool operator==(const DOMFileSystemBase& a, const DOMFileSystemBase& b) { return a.name() == b.name() && a.type() == b.type() && a.rootURL() == b.rootURL(); }
+
 } // namespace WebCore
 
 #endif // ENABLE(FILE_SYSTEM)
index 8b772bb..8a57d00 100644 (file)
@@ -53,11 +53,11 @@ class FileWriterBase;
 
 PassRefPtr<DOMFileSystemSync> DOMFileSystemSync::create(DOMFileSystemBase* fileSystem)
 {
-    return adoptRef(new DOMFileSystemSync(fileSystem->m_context, fileSystem->m_name, fileSystem->m_asyncFileSystem.release()));
+    return adoptRef(new DOMFileSystemSync(fileSystem->m_context, fileSystem->name(), fileSystem->type(), fileSystem->rootURL(), fileSystem->m_asyncFileSystem.release()));
 }
 
-DOMFileSystemSync::DOMFileSystemSync(ScriptExecutionContext* context, const String& name, PassOwnPtr<AsyncFileSystem> asyncFileSystem)
-    : DOMFileSystemBase(context, name, asyncFileSystem)
+DOMFileSystemSync::DOMFileSystemSync(ScriptExecutionContext* context, const String& name, FileSystemType type, const KURL& rootURL, PassOwnPtr<AsyncFileSystem> asyncFileSystem)
+    : DOMFileSystemBase(context, name, type, rootURL, asyncFileSystem)
 {
 }
 
@@ -134,7 +134,7 @@ PassRefPtr<File> DOMFileSystemSync::createFile(const FileEntrySync* fileEntry, E
 {
     ec = 0;
     RefPtr<CreateFileHelper::CreateFileResult> result(CreateFileHelper::CreateFileResult::create());
-    m_asyncFileSystem->createSnapshotFileAndReadMetadata(fileEntry->fullPath(), CreateFileHelper::create(result, fileEntry->name()));
+    m_asyncFileSystem->createSnapshotFileAndReadMetadata(createFileSystemURL(fileEntry), CreateFileHelper::create(result, fileEntry->name()));
     if (!m_asyncFileSystem->waitForOperationToComplete()) {
         ec = FileException::ABORT_ERR;
         return 0;
@@ -223,7 +223,7 @@ PassRefPtr<FileWriterSync> DOMFileSystemSync::createWriter(const FileEntrySync*
     RefPtr<LocalErrorCallback> errorCallback = LocalErrorCallback::create();
 
     OwnPtr<FileWriterBaseCallbacks> callbacks = FileWriterBaseCallbacks::create(fileWriter, successCallback, errorCallback);
-    m_asyncFileSystem->createWriter(fileWriter.get(), fileEntry->fullPath(), callbacks.release());
+    m_asyncFileSystem->createWriter(fileWriter.get(), createFileSystemURL(fileEntry), callbacks.release());
     if (!m_asyncFileSystem->waitForOperationToComplete()) {
         ec = FileException::ABORT_ERR;
         return 0;
index 0120fb0..24fbd15 100644 (file)
@@ -46,9 +46,9 @@ typedef int ExceptionCode;
 
 class DOMFileSystemSync : public DOMFileSystemBase {
 public:
-    static PassRefPtr<DOMFileSystemSync> create(ScriptExecutionContext* context, const String& name, PassOwnPtr<AsyncFileSystem> asyncFileSystem)
+    static PassRefPtr<DOMFileSystemSync> create(ScriptExecutionContext* context, const String& name, FileSystemType type, const KURL& rootURL, PassOwnPtr<AsyncFileSystem> asyncFileSystem)
     {
-        return adoptRef(new DOMFileSystemSync(context, name, asyncFileSystem));
+        return adoptRef(new DOMFileSystemSync(context, name, type, rootURL, asyncFileSystem));
     }
 
     static PassRefPtr<DOMFileSystemSync> create(DOMFileSystemBase*);
@@ -61,7 +61,7 @@ public:
     PassRefPtr<FileWriterSync> createWriter(const FileEntrySync*, ExceptionCode&);
 
 private:
-    DOMFileSystemSync(ScriptExecutionContext*, const String& name, PassOwnPtr<AsyncFileSystem>);
+    DOMFileSystemSync(ScriptExecutionContext*, const String& name, FileSystemType, const KURL& rootURL, PassOwnPtr<AsyncFileSystem>);
 };
 
 }
index 5e012a2..179ece6 100644 (file)
@@ -66,12 +66,12 @@ void DOMWindowFileSystem::webkitRequestFileSystem(DOMWindow* window, int type, l
     }
 
     FileSystemType fileSystemType = static_cast<FileSystemType>(type);
-    if (!AsyncFileSystem::isValidType(fileSystemType)) {
+    if (!DOMFileSystemBase::isValidType(fileSystemType)) {
         DOMFileSystem::scheduleCallback(document, errorCallback, FileError::create(FileError::INVALID_MODIFICATION_ERR));
         return;
     }
 
-    LocalFileSystem::localFileSystem().requestFileSystem(document, fileSystemType, size, FileSystemCallbacks::create(successCallback, errorCallback, document), AsynchronousFileSystem);
+    LocalFileSystem::localFileSystem().requestFileSystem(document, fileSystemType, size, FileSystemCallbacks::create(successCallback, errorCallback, document, fileSystemType), AsynchronousFileSystem);
 }
 
 void DOMWindowFileSystem::webkitResolveLocalFileSystemURL(DOMWindow* window, const String& url, PassRefPtr<EntryCallback> successCallback, PassRefPtr<ErrorCallback> errorCallback)
@@ -92,12 +92,12 @@ void DOMWindowFileSystem::webkitResolveLocalFileSystemURL(DOMWindow* window, con
 
     FileSystemType type;
     String filePath;
-    if (!completedURL.isValid() || !AsyncFileSystem::crackFileSystemURL(completedURL, type, filePath)) {
+    if (!completedURL.isValid() || !DOMFileSystemBase::crackFileSystemURL(completedURL, type, filePath)) {
         DOMFileSystem::scheduleCallback(document, errorCallback, FileError::create(FileError::ENCODING_ERR));
         return;
     }
 
-    LocalFileSystem::localFileSystem().readFileSystem(document, type, ResolveURICallbacks::create(successCallback, errorCallback, document, filePath));
+    LocalFileSystem::localFileSystem().readFileSystem(document, type, ResolveURICallbacks::create(successCallback, errorCallback, document, type, filePath));
 }
 
 COMPILE_ASSERT(static_cast<int>(DOMWindowFileSystem::TEMPORARY) == static_cast<int>(FileSystemTypeTemporary), enum_mismatch);
index 72a22bd..62d05d3 100644 (file)
@@ -56,7 +56,11 @@ EntryBase::~EntryBase()
 
 KURL EntryBase::toURL() const
 {
-    return m_fileSystem->asyncFileSystem()->toURL(m_fileSystem->securityOrigin()->toString(), m_fullPath);
+    // Some filesystem type may not support toURL.
+    if (!m_fileSystem->supportsToURL())
+        return KURL();
+
+    return m_fileSystem->createFileSystemURL(this);
 }
 
 } // namespace WebCore
index 1e9a99d..ab0834b 100644 (file)
@@ -134,23 +134,24 @@ void EntriesCallbacks::didReadDirectoryEntries(bool hasMore)
 
 // FileSystemCallbacks --------------------------------------------------------
 
-PassOwnPtr<FileSystemCallbacks> FileSystemCallbacks::create(PassRefPtr<FileSystemCallback> successCallback, PassRefPtr<ErrorCallback> errorCallback, ScriptExecutionContext* scriptExecutionContext)
+PassOwnPtr<FileSystemCallbacks> FileSystemCallbacks::create(PassRefPtr<FileSystemCallback> successCallback, PassRefPtr<ErrorCallback> errorCallback, ScriptExecutionContext* scriptExecutionContext, FileSystemType type)
 {
-    return adoptPtr(new FileSystemCallbacks(successCallback, errorCallback, scriptExecutionContext));
+    return adoptPtr(new FileSystemCallbacks(successCallback, errorCallback, scriptExecutionContext, type));
 }
 
-FileSystemCallbacks::FileSystemCallbacks(PassRefPtr<FileSystemCallback> successCallback, PassRefPtr<ErrorCallback> errorCallback, ScriptExecutionContext* context)
+FileSystemCallbacks::FileSystemCallbacks(PassRefPtr<FileSystemCallback> successCallback, PassRefPtr<ErrorCallback> errorCallback, ScriptExecutionContext* context, FileSystemType type)
     : FileSystemCallbacksBase(errorCallback)
     , m_successCallback(successCallback)
     , m_scriptExecutionContext(context)
+    , m_type(type)
 {
 }
 
-void FileSystemCallbacks::didOpenFileSystem(const String& name, PassOwnPtr<AsyncFileSystem> asyncFileSystem)
+void FileSystemCallbacks::didOpenFileSystem(const String& name, const KURL& rootURL, PassOwnPtr<AsyncFileSystem> asyncFileSystem)
 {
     if (m_successCallback) {
         ASSERT(asyncFileSystem);
-        RefPtr<DOMFileSystem> fileSystem = DOMFileSystem::create(m_scriptExecutionContext.get(), name, asyncFileSystem);
+        RefPtr<DOMFileSystem> fileSystem = DOMFileSystem::create(m_scriptExecutionContext.get(), name, m_type, rootURL, asyncFileSystem);
         m_successCallback->handleEvent(fileSystem.get());
         m_scriptExecutionContext.clear();
     }
@@ -196,23 +197,24 @@ private:
 
 } // namespace
 
-PassOwnPtr<ResolveURICallbacks> ResolveURICallbacks::create(PassRefPtr<EntryCallback> successCallback, PassRefPtr<ErrorCallback> errorCallback, ScriptExecutionContext* scriptExecutionContext, const String& filePath)
+PassOwnPtr<ResolveURICallbacks> ResolveURICallbacks::create(PassRefPtr<EntryCallback> successCallback, PassRefPtr<ErrorCallback> errorCallback, ScriptExecutionContext* scriptExecutionContext, FileSystemType type, const String& filePath)
 {
-    return adoptPtr(new ResolveURICallbacks(successCallback, errorCallback, scriptExecutionContext, filePath));
+    return adoptPtr(new ResolveURICallbacks(successCallback, errorCallback, scriptExecutionContext, type, filePath));
 }
 
-ResolveURICallbacks::ResolveURICallbacks(PassRefPtr<EntryCallback> successCallback, PassRefPtr<ErrorCallback> errorCallback, ScriptExecutionContext* context, const String& filePath)
+ResolveURICallbacks::ResolveURICallbacks(PassRefPtr<EntryCallback> successCallback, PassRefPtr<ErrorCallback> errorCallback, ScriptExecutionContext* context, FileSystemType type, const String& filePath)
     : FileSystemCallbacksBase(errorCallback)
     , m_successCallback(successCallback)
     , m_scriptExecutionContext(context)
+    , m_type(type)
     , m_filePath(filePath)
 {
 }
 
-void ResolveURICallbacks::didOpenFileSystem(const String& name, PassOwnPtr<AsyncFileSystem> asyncFileSystem)
+void ResolveURICallbacks::didOpenFileSystem(const String& name, const KURL& rootURL, PassOwnPtr<AsyncFileSystem> asyncFileSystem)
 {
     ASSERT(asyncFileSystem);
-    RefPtr<DirectoryEntry> root = DOMFileSystem::create(m_scriptExecutionContext.get(), name, asyncFileSystem)->root();
+    RefPtr<DirectoryEntry> root = DOMFileSystem::create(m_scriptExecutionContext.get(), name, m_type, rootURL, asyncFileSystem)->root();
     root->getDirectory(m_filePath, 0, m_successCallback, ErrorCallbackWrapper::create(m_successCallback, m_errorCallback, root, m_filePath));
 }
 
index 2d19b6a..ac32926 100644 (file)
@@ -34,6 +34,7 @@
 #if ENABLE(FILE_SYSTEM)
 
 #include "AsyncFileSystemCallbacks.h"
+#include "FileSystemType.h"
 #include "PlatformString.h"
 #include <wtf/PassRefPtr.h>
 #include <wtf/Vector.h>
@@ -100,24 +101,26 @@ private:
 
 class FileSystemCallbacks : public FileSystemCallbacksBase {
 public:
-    static PassOwnPtr<FileSystemCallbacks> create(PassRefPtr<FileSystemCallback>, PassRefPtr<ErrorCallback>, ScriptExecutionContext*);
-    virtual void didOpenFileSystem(const String& name, PassOwnPtr<AsyncFileSystem>);
+    static PassOwnPtr<FileSystemCallbacks> create(PassRefPtr<FileSystemCallback>, PassRefPtr<ErrorCallback>, ScriptExecutionContext*, FileSystemType);
+    virtual void didOpenFileSystem(const String& name, const KURL& rootURL, PassOwnPtr<AsyncFileSystem>);
 
 private:
-    FileSystemCallbacks(PassRefPtr<FileSystemCallback>, PassRefPtr<ErrorCallback>, ScriptExecutionContext*);
+    FileSystemCallbacks(PassRefPtr<FileSystemCallback>, PassRefPtr<ErrorCallback>, ScriptExecutionContext*, FileSystemType);
     RefPtr<FileSystemCallback> m_successCallback;
     RefPtr<ScriptExecutionContext> m_scriptExecutionContext;
+    FileSystemType m_type;
 };
 
 class ResolveURICallbacks : public FileSystemCallbacksBase {
 public:
-    static PassOwnPtr<ResolveURICallbacks> create(PassRefPtr<EntryCallback>, PassRefPtr<ErrorCallback>, ScriptExecutionContext*, const String& filePath);
-    virtual void didOpenFileSystem(const String& name, PassOwnPtr<AsyncFileSystem>);
+    static PassOwnPtr<ResolveURICallbacks> create(PassRefPtr<EntryCallback>, PassRefPtr<ErrorCallback>, ScriptExecutionContext*, FileSystemType, const String& filePath);
+    virtual void didOpenFileSystem(const String& name, const KURL& rootURL, PassOwnPtr<AsyncFileSystem>);
 
 private:
-    ResolveURICallbacks(PassRefPtr<EntryCallback>, PassRefPtr<ErrorCallback>, ScriptExecutionContext*, const String& filePath);
+    ResolveURICallbacks(PassRefPtr<EntryCallback>, PassRefPtr<ErrorCallback>, ScriptExecutionContext*, FileSystemType, const String& filePath);
     RefPtr<EntryCallback> m_successCallback;
     RefPtr<ScriptExecutionContext> m_scriptExecutionContext;
+    FileSystemType m_type;
     String m_filePath;
 };
 
index 03c7101..0eaafae 100644 (file)
@@ -77,21 +77,21 @@ String LocalFileSystem::fileSystemBasePath() const
     return m_basePath;
 }
 
-static void openFileSystem(ScriptExecutionContext*, const String& basePath, const String& identifier, AsyncFileSystem::Type type, bool create, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
+static void openFileSystem(ScriptExecutionContext*, const String& basePath, const String& identifier, bool create, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
 {
-    AsyncFileSystem::openFileSystem(basePath, identifier, type, create, callbacks);
+    AsyncFileSystem::openFileSystem(basePath, identifier, create, callbacks);
 }
 
-void LocalFileSystem::readFileSystem(ScriptExecutionContext* context, AsyncFileSystem::Type type, PassOwnPtr<AsyncFileSystemCallbacks> callbacks, bool)
+void LocalFileSystem::readFileSystem(ScriptExecutionContext* context, DOMFileSystemBase::Type, PassOwnPtr<AsyncFileSystemCallbacks> callbacks, FileSystemSynchronousMode)
 {
     // AsyncFileSystem::openFileSystem calls callbacks synchronously, so the method needs to be called asynchronously.
-    context->postTask(createCallbackTask(&openFileSystem, fileSystemBasePath(), context->securityOrigin()->databaseIdentifier(), type, false, callbacks));
+    context->postTask(createCallbackTask(&openFileSystem, fileSystemBasePath(), context->securityOrigin()->databaseIdentifier(), false, callbacks));
 }
 
-void LocalFileSystem::requestFileSystem(ScriptExecutionContext* context, AsyncFileSystem::Type type, long long, PassOwnPtr<AsyncFileSystemCallbacks> callbacks, FileSystemSynchronousType)
+void LocalFileSystem::requestFileSystem(ScriptExecutionContext* context, DOMFileSystemBase::Type, long long, PassOwnPtr<AsyncFileSystemCallbacks> callbacks, FileSystemSynchronousType)
 {
     // AsyncFileSystem::openFileSystem calls callbacks synchronously, so the method needs to be called asynchronously.
-    context->postTask(createCallbackTask(&openFileSystem, fileSystemBasePath(), context->securityOrigin()->databaseIdentifier(), type, true, callbacks));
+    context->postTask(createCallbackTask(&openFileSystem, fileSystemBasePath(), context->securityOrigin()->databaseIdentifier(), true, callbacks));
 }
 
 } // namespace
index 4855886..bd71e3e 100644 (file)
@@ -33,7 +33,7 @@
 
 #if ENABLE(FILE_SYSTEM)
 
-#include "AsyncFileSystemCallbacks.h"
+#include "DOMFileSystemBase.h"
 #include "FileSystemType.h"
 #include "PlatformString.h"
 #include <wtf/PassRefPtr.h>
index f42c80a..d62ee32 100644 (file)
@@ -31,7 +31,6 @@
 #if ENABLE(FILE_SYSTEM)
 
 #include "AsyncFileSystem.h"
-#include "DOMFileSystem.h"
 #include "DOMFileSystemBase.h"
 #include "DOMFileSystemSync.h"
 #include "DirectoryEntrySync.h"
@@ -58,12 +57,12 @@ void WorkerContextFileSystem::webkitRequestFileSystem(WorkerContext* worker, int
     }
 
     FileSystemType fileSystemType = static_cast<FileSystemType>(type);
-    if (!AsyncFileSystem::isValidType(fileSystemType)) {
+    if (!DOMFileSystemBase::isValidType(fileSystemType)) {
         DOMFileSystem::scheduleCallback(worker, errorCallback, FileError::create(FileError::INVALID_MODIFICATION_ERR));
         return;
     }
 
-    LocalFileSystem::localFileSystem().requestFileSystem(worker, fileSystemType, size, FileSystemCallbacks::create(successCallback, errorCallback, worker), AsynchronousFileSystem);
+    LocalFileSystem::localFileSystem().requestFileSystem(worker, fileSystemType, size, FileSystemCallbacks::create(successCallback, errorCallback, worker, fileSystemType), AsynchronousFileSystem);
 }
 
 PassRefPtr<DOMFileSystemSync> WorkerContextFileSystem::webkitRequestFileSystemSync(WorkerContext* worker, int type, long long size, ExceptionCode& ec)
@@ -76,13 +75,13 @@ PassRefPtr<DOMFileSystemSync> WorkerContextFileSystem::webkitRequestFileSystemSy
     }
 
     FileSystemType fileSystemType = static_cast<FileSystemType>(type);
-    if (!AsyncFileSystem::isValidType(fileSystemType)) {
+    if (!DOMFileSystemBase::isValidType(fileSystemType)) {
         ec = FileException::INVALID_MODIFICATION_ERR;
         return 0;
     }
 
     FileSystemSyncCallbackHelper helper;
-    LocalFileSystem::localFileSystem().requestFileSystem(worker, fileSystemType, size, FileSystemCallbacks::create(helper.successCallback(), helper.errorCallback(), worker), SynchronousFileSystem);
+    LocalFileSystem::localFileSystem().requestFileSystem(worker, fileSystemType, size, FileSystemCallbacks::create(helper.successCallback(), helper.errorCallback(), worker, fileSystemType), SynchronousFileSystem);
     return helper.getResult(ec);
 }
 
@@ -97,12 +96,12 @@ void WorkerContextFileSystem::webkitResolveLocalFileSystemURL(WorkerContext* wor
 
     FileSystemType type;
     String filePath;
-    if (!completedURL.isValid() || !AsyncFileSystem::crackFileSystemURL(completedURL, type, filePath)) {
+    if (!completedURL.isValid() || !DOMFileSystemBase::crackFileSystemURL(completedURL, type, filePath)) {
         DOMFileSystem::scheduleCallback(worker, errorCallback, FileError::create(FileError::ENCODING_ERR));
         return;
     }
 
-    LocalFileSystem::localFileSystem().readFileSystem(worker, type, ResolveURICallbacks::create(successCallback, errorCallback, worker, filePath));
+    LocalFileSystem::localFileSystem().readFileSystem(worker, type, ResolveURICallbacks::create(successCallback, errorCallback, worker, type, filePath));
 }
 
 PassRefPtr<EntrySync> WorkerContextFileSystem::webkitResolveLocalFileSystemSyncURL(WorkerContext* worker, const String& url, ExceptionCode& ec)
@@ -117,13 +116,13 @@ PassRefPtr<EntrySync> WorkerContextFileSystem::webkitResolveLocalFileSystemSyncU
 
     FileSystemType type;
     String filePath;
-    if (!completedURL.isValid() || !AsyncFileSystem::crackFileSystemURL(completedURL, type, filePath)) {
+    if (!completedURL.isValid() || !DOMFileSystemBase::crackFileSystemURL(completedURL, type, filePath)) {
         ec = FileException::ENCODING_ERR;
         return 0;
     }
 
     FileSystemSyncCallbackHelper readFileSystemHelper;
-    LocalFileSystem::localFileSystem().readFileSystem(worker, type, FileSystemCallbacks::create(readFileSystemHelper.successCallback(), readFileSystemHelper.errorCallback(), worker), SynchronousFileSystem);
+    LocalFileSystem::localFileSystem().readFileSystem(worker, type, FileSystemCallbacks::create(readFileSystemHelper.successCallback(), readFileSystemHelper.errorCallback(), worker, type), SynchronousFileSystem);
     RefPtr<DOMFileSystemSync> fileSystem = readFileSystemHelper.getResult(ec);
     if (!fileSystem)
         return 0;
diff --git a/Source/WebCore/Modules/filesystem/chromium/DOMFileSystemChromium.cpp b/Source/WebCore/Modules/filesystem/chromium/DOMFileSystemChromium.cpp
new file mode 100644 (file)
index 0000000..17d15f2
--- /dev/null
@@ -0,0 +1,133 @@
+/*
+ * Copyright (C) 2012 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *     * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "DOMFileSystemChromium.h"
+
+#if ENABLE(FILE_SYSTEM)
+
+#include "DOMFilePath.h"
+#include "FileSystemType.h"
+#include "PlatformSupport.h"
+#include "ScriptExecutionContext.h"
+#include "SecurityOrigin.h"
+#include <wtf/text/StringBuilder.h>
+#include <wtf/text/WTFString.h>
+
+namespace WebCore {
+
+const char isolatedPathPrefix[] = "isolated";
+const char externalPathPrefix[] = "external";
+
+// static
+bool DOMFileSystemBase::isValidType(FileSystemType type)
+{
+    return type == FileSystemTypeTemporary || type == FileSystemTypePersistent || type == FileSystemTypeIsolated || type == FileSystemTypeExternal;
+}
+
+// static
+bool DOMFileSystemBase::crackFileSystemURL(const KURL& url, FileSystemType& type, String& filePath)
+{
+    if (!url.protocolIs("filesystem"))
+        return false;
+
+    if (!url.innerURL())
+        return false;
+
+    String typeString = url.innerURL()->path().substring(1);
+    if (typeString == temporaryPathPrefix)
+        type = FileSystemTypeTemporary;
+    else if (typeString == persistentPathPrefix)
+        type = FileSystemTypePersistent;
+    else if (typeString == externalPathPrefix)
+        type = FileSystemTypeExternal;
+    else
+        return false;
+
+    filePath = decodeURLEscapeSequences(url.path());
+    return true;
+}
+
+bool DOMFileSystemBase::supportsToURL() const
+{
+    ASSERT(isValidType(m_type));
+    return m_type != FileSystemTypeIsolated;
+}
+
+KURL DOMFileSystemBase::createFileSystemURL(const String& fullPath) const
+{
+    ASSERT(DOMFilePath::isAbsolute(fullPath));
+
+    if (type() == FileSystemTypeExternal) {
+        // For external filesystem originString could be different from what we have in m_filesystemRootURL.
+        StringBuilder result;
+        result.append("filesystem:");
+        result.append(securityOrigin()->toString());
+        result.append("/");
+        result.append(externalPathPrefix);
+        result.append(encodeWithURLEscapeSequences(fullPath));
+        return KURL(ParsedURLString, result.toString());
+    }
+
+    // For regular types we can just append the entry's fullPath to the m_filesystemRootURL that should look like 'filesystem:<origin>/<typePrefix>'.
+    ASSERT(!m_filesystemRootURL.isEmpty());
+    KURL url = m_filesystemRootURL;
+    // Remove the extra leading slash.
+    url.setPath(url.path() + encodeWithURLEscapeSequences(fullPath.substring(1)));
+    return url;
+}
+
+// static
+PassRefPtr<DOMFileSystem> DOMFileSystemChromium::createIsolatedFileSystem(ScriptExecutionContext* context, const String& filesystemId)
+{
+    StringBuilder filesystemName;
+    filesystemName.append(context->securityOrigin()->databaseIdentifier());
+    filesystemName.append(":");
+    filesystemName.append(isolatedPathPrefix);
+    filesystemName.append("_");
+    filesystemName.append(filesystemId);
+
+    // The rootURL created here is going to be attached to each filesystem request and
+    // is to be validated each time the request is being handled.
+    StringBuilder rootURL;
+    rootURL.append("filesystem:");
+    rootURL.append(context->securityOrigin()->toString());
+    rootURL.append("/");
+    rootURL.append(isolatedPathPrefix);
+    rootURL.append("/");
+    rootURL.append(filesystemId);
+    rootURL.append("/");
+
+    return DOMFileSystem::create(context, filesystemName.toString(), FileSystemTypeIsolated, KURL(ParsedURLString, rootURL.toString()), PlatformSupport::createAsyncFileSystem());
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(FILE_SYSTEM)
diff --git a/Source/WebCore/Modules/filesystem/chromium/DOMFileSystemChromium.h b/Source/WebCore/Modules/filesystem/chromium/DOMFileSystemChromium.h
new file mode 100644 (file)
index 0000000..914081c
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2012 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *     * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef DOMFileSystemChromium_h
+#define DOMFileSystemChromium_h
+
+#if ENABLE(FILE_SYSTEM)
+
+#include "DOMFileSystem.h"
+
+namespace WebCore {
+
+class DOMFileSystemChromium {
+public:
+    static PassRefPtr<DOMFileSystem> createIsolatedFileSystem(ScriptExecutionContext*, const String& filesystemId);
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(FILE_SYSTEM)
+
+#endif // DOMFileSystemChromium_h
index c75554c..a6bb3cd 100644 (file)
@@ -120,7 +120,7 @@ void DataTransferItemFileSystem::webkitGetAsEntry(DataTransferItem* item, Script
 
     // The dropped entries are mapped as top-level entries in the isolated filesystem.
     String virtualPath = DOMFilePath::append("/", static_cast<File*>(file)->name());
-    domFileSystem->asyncFileSystem()->readMetadata(virtualPath, GetAsEntryCallbacks::create(domFileSystem, virtualPath, callback));
+    domFileSystem->asyncFileSystem()->readMetadata(domFileSystem->createFileSystemURL(virtualPath), GetAsEntryCallbacks::create(domFileSystem, virtualPath, callback));
 }
 
 } // namespace WebCore
index df5c14c..079514f 100644 (file)
@@ -33,7 +33,7 @@
 
 #if ENABLE(FILE_SYSTEM)
 
-#include "DOMFileSystem.h"
+#include "DOMFileSystemChromium.h"
 #include "PlatformSupport.h"
 #include "ScriptExecutionContext.h"
 #include "SecurityOrigin.h"
@@ -51,9 +51,7 @@ DOMFileSystem* DraggedIsolatedFileSystem::getDOMFileSystem(ScriptExecutionContex
     ASSERT(!m_filesystemId.isEmpty());
     if (!m_filesystem) {
         ASSERT(scriptExecutionContext);
-        SecurityOrigin* securityOrigin = scriptExecutionContext->securityOrigin();
-        String filesystemName = PlatformSupport::createIsolatedFileSystemName(securityOrigin->databaseIdentifier(), m_filesystemId);
-        m_filesystem = DOMFileSystem::create(scriptExecutionContext, filesystemName, PlatformSupport::createIsolatedFileSystem(securityOrigin->toString(), m_filesystemId));
+        m_filesystem = DOMFileSystemChromium::createIsolatedFileSystem(scriptExecutionContext, m_filesystemId);
     }
     return m_filesystem.get();
 }
index 7829e85..45175bc 100644 (file)
             'Modules/filesystem/FileSystemCallback.h',
             'Modules/filesystem/FileSystemCallbacks.cpp',
             'Modules/filesystem/FileSystemCallbacks.h',
+            'Modules/filesystem/FileSystemType.h',
             'Modules/filesystem/FileWriter.cpp',
             'Modules/filesystem/FileWriter.h',
             'Modules/filesystem/FileWriterBase.cpp',
             'Modules/filesystem/WebKitFlags.h',
             'Modules/filesystem/WorkerContextFileSystem.cpp',
             'Modules/filesystem/WorkerContextFileSystem.h',
+            'Modules/filesystem/chromium/DOMFileSystemChromium.cpp',
+            'Modules/filesystem/chromium/DOMFileSystemChromium.h',
             'Modules/filesystem/chromium/DataTransferItemFileSystemChromium.cpp',
+            'Modules/filesystem/chromium/DOMFileSystemChromium.cpp',
             'Modules/filesystem/chromium/DraggedIsolatedFileSystem.cpp',
             'Modules/filesystem/chromium/DraggedIsolatedFileSystem.h',
             'Modules/gamepad/Gamepad.cpp',
index 0d53635..675f41d 100755 (executable)
                                        >
                                </File>
                                <File
+                                       RelativePath="..\Modules\filesystem\FileSystemType.h"
+                                       >
+                               </File>
+                               <File
                                        RelativePath="..\Modules\filesystem\FileWriter.cpp"
                                        >
                                </File>
index 317514c..d178682 100644 (file)
                898785F5122E1EAC003AABDA /* JSFileReaderSync.h in Headers */ = {isa = PBXBuildFile; fileRef = 898785F3122E1EAC003AABDA /* JSFileReaderSync.h */; };
                89B5EAA111E8003D00F2367E /* LineEnding.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 89B5EA9F11E8003D00F2367E /* LineEnding.cpp */; };
                89B5EAA211E8003D00F2367E /* LineEnding.h in Headers */ = {isa = PBXBuildFile; fileRef = 89B5EAA011E8003D00F2367E /* LineEnding.h */; settings = {ATTRIBUTES = (Private, ); }; };
+               89C7C2E1155804F4007D5A7B /* FileSystemType.h in Headers */ = {isa = PBXBuildFile; fileRef = 89C7C2E0155804F4007D5A7B /* FileSystemType.h */; };
                89CD029311C85B870070B791 /* JSWebKitBlobBuilder.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 89CD029111C85B870070B791 /* JSWebKitBlobBuilder.cpp */; };
                89CD029411C85B870070B791 /* JSWebKitBlobBuilder.h in Headers */ = {isa = PBXBuildFile; fileRef = 89CD029211C85B870070B791 /* JSWebKitBlobBuilder.h */; };
                89D08D9F12228451001241DF /* AsyncFileSystem.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 89D08D9C12228451001241DF /* AsyncFileSystem.cpp */; };
                898785F3122E1EAC003AABDA /* JSFileReaderSync.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSFileReaderSync.h; sourceTree = "<group>"; };
                89B5EA9F11E8003D00F2367E /* LineEnding.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LineEnding.cpp; sourceTree = "<group>"; };
                89B5EAA011E8003D00F2367E /* LineEnding.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LineEnding.h; sourceTree = "<group>"; };
+               89C7C2E0155804F4007D5A7B /* FileSystemType.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = FileSystemType.h; path = Modules/filesystem/FileSystemType.h; sourceTree = "<group>"; };
                89CD029111C85B870070B791 /* JSWebKitBlobBuilder.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSWebKitBlobBuilder.cpp; sourceTree = "<group>"; };
                89CD029211C85B870070B791 /* JSWebKitBlobBuilder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSWebKitBlobBuilder.h; sourceTree = "<group>"; };
                89D08D9C12228451001241DF /* AsyncFileSystem.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AsyncFileSystem.cpp; sourceTree = "<group>"; };
                                E1AB1EBE14E9E3B200449E13 /* FileSystemCallback.idl */,
                                8987854B122CA064003AABDA /* FileSystemCallbacks.cpp */,
                                8987854C122CA064003AABDA /* FileSystemCallbacks.h */,
+                               89C7C2E0155804F4007D5A7B /* FileSystemType.h */,
                                976D6C6E122B8A3D001FD1F7 /* FileThread.cpp */,
                                976D6C6F122B8A3D001FD1F7 /* FileThread.h */,
                                976D6C70122B8A3D001FD1F7 /* FileThreadTask.h */,
                                89878563122CA064003AABDA /* FileSystemCallback.h in Headers */,
                                89878565122CA064003AABDA /* FileSystemCallbacks.h in Headers */,
                                26C17A3E1491D2D400D12BA2 /* FileSystemIOS.h in Headers */,
+                               89C7C2E1155804F4007D5A7B /* FileSystemType.h in Headers */,
                                976D6C8E122B8A3D001FD1F7 /* FileThread.h in Headers */,
                                976D6C8F122B8A3D001FD1F7 /* FileThreadTask.h in Headers */,
                                976D6C91122B8A3D001FD1F7 /* FileWriter.h in Headers */,
index 13c282e..a3fb07f 100644 (file)
 
 #include "AsyncFileSystemCallbacks.h"
 #include "ExceptionCode.h"
-#include "FileSystem.h"
 #include "NotImplemented.h"
 
 namespace WebCore {
 
-const char AsyncFileSystem::persistentPathPrefix[] = "persistent";
-const size_t AsyncFileSystem::persistentPathPrefixLength = sizeof(AsyncFileSystem::persistentPathPrefix) - 1;
-const char AsyncFileSystem::temporaryPathPrefix[] = "temporary";
-const size_t AsyncFileSystem::temporaryPathPrefixLength = sizeof(AsyncFileSystem::temporaryPathPrefix) - 1;
-
 #if !PLATFORM(CHROMIUM) && !PLATFORM(GTK) && !PLATFORM(BLACKBERRY)
 bool AsyncFileSystem::isAvailable()
 {
@@ -52,18 +46,7 @@ bool AsyncFileSystem::isAvailable()
     return false;
 }
 
-bool AsyncFileSystem::isValidType(FileSystemType type)
-{
-    return type == FileSystemTypeTemporary || type == FileSystemTypePersistent;
-}
-
-PassOwnPtr<AsyncFileSystem> AsyncFileSystem::create(FileSystemType)
-{
-    notImplemented();
-    return nullptr;
-}
-
-void AsyncFileSystem::openFileSystem(const String& basePath, const String& storageIdentifier, FileSystemType, bool, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
+void AsyncFileSystem::openFileSystem(const String& basePath, const String& storageIdentifier, bool, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
 {
     notImplemented();
     callbacks->didFail(NOT_SUPPORTED_ERR);
index 6832979..6e53a9a 100644 (file)
@@ -51,106 +51,86 @@ class AsyncFileSystem {
 public:
     virtual ~AsyncFileSystem() { }
 
-    // Path prefixes that are used in the filesystem URLs (that can be obtained by toURL()).
-    // http://www.w3.org/TR/file-system-api/#widl-Entry-toURL
-    static const char persistentPathPrefix[];
-    static const size_t persistentPathPrefixLength;
-    static const char temporaryPathPrefix[];
-    static const size_t temporaryPathPrefixLength;
-
     virtual void stop() { }
     virtual bool hasPendingActivity() { return false; }
 
     static bool isAvailable();
 
-    static bool isValidType(FileSystemType);
-
-    static bool crackFileSystemURL(const KURL&, FileSystemType&, String& filePath);
-
-    virtual KURL toURL(const String& originString, const String& fullPath) const = 0;
-
     // Subclass must implement this if it supports synchronous operations.
     // This should return false if there are no pending operations.
     virtual bool waitForOperationToComplete() { return false; }
 
     // Creates and returns a new platform-specific AsyncFileSystem instance if the platform has its own implementation.
-    static PassOwnPtr<AsyncFileSystem> create(FileSystemType);
+    static PassOwnPtr<AsyncFileSystem> create();
 
     // Opens a new file system. The create parameter specifies whether or not to create the path if it does not already exists.
-    static void openFileSystem(const String& basePath, const String& storageIdentifier, FileSystemType, bool create, PassOwnPtr<AsyncFileSystemCallbacks>);
+    static void openFileSystem(const String& basePath, const String& storageIdentifier, bool create, PassOwnPtr<AsyncFileSystemCallbacks>);
 
     // Moves a file or directory from srcPath to destPath.
     // AsyncFileSystemCallbacks::didSucceed() is called when the operation is completed successfully.
     // AsyncFileSystemCallbacks::didFail() is called otherwise.
-    virtual void move(const String& srcPath, const String& destPath, PassOwnPtr<AsyncFileSystemCallbacks>) = 0;
+    virtual void move(const KURL& srcPath, const KURL& destPath, PassOwnPtr<AsyncFileSystemCallbacks>) = 0;
 
     // Copies a file or directory from srcPath to destPath.
     // AsyncFileSystemCallbacks::didSucceed() is called when the operation is completed successfully.
     // AsyncFileSystemCallbacks::didFail() is called otherwise.
-    virtual void copy(const String& srcPath, const String& destPath, PassOwnPtr<AsyncFileSystemCallbacks>) = 0;
+    virtual void copy(const KURL& srcPath, const KURL& destPath, PassOwnPtr<AsyncFileSystemCallbacks>) = 0;
 
     // Deletes a file or directory at a given path.
     // It is an error to try to remove a directory that is not empty.
     // AsyncFileSystemCallbacks::didSucceed() is called when the operation is completed successfully.
     // AsyncFileSystemCallbacks::didFail() is called otherwise.
-    virtual void remove(const String& path, PassOwnPtr<AsyncFileSystemCallbacks>) = 0;
+    virtual void remove(const KURL& path, PassOwnPtr<AsyncFileSystemCallbacks>) = 0;
 
     // Recursively deletes a directory at a given path.
     // AsyncFileSystemCallbacks::didSucceed() is called when the operation is completed successfully.
     // AsyncFileSystemCallbacks::didFail() is called otherwise.
-    virtual void removeRecursively(const String& path, PassOwnPtr<AsyncFileSystemCallbacks>) = 0;
+    virtual void removeRecursively(const KURL& path, PassOwnPtr<AsyncFileSystemCallbacks>) = 0;
 
     // Retrieves the metadata information of the file or directory at a given path.
     // AsyncFileSystemCallbacks::didReadMetadata() is called when the operation is completed successfully.
     // AsyncFileSystemCallbacks::didFail() is called otherwise.
-    virtual void readMetadata(const String& path, PassOwnPtr<AsyncFileSystemCallbacks>) = 0;
+    virtual void readMetadata(const KURL& path, PassOwnPtr<AsyncFileSystemCallbacks>) = 0;
 
     // Creates a file at a given path.  If exclusive flag is true, it fails if the path already exists.
     // AsyncFileSystemCallbacks::didSucceed() is called when the operation is completed successfully.
     // AsyncFileSystemCallbacks::didFail() is called otherwise.
-    virtual void createFile(const String& path, bool exclusive, PassOwnPtr<AsyncFileSystemCallbacks>) = 0;
+    virtual void createFile(const KURL& path, bool exclusive, PassOwnPtr<AsyncFileSystemCallbacks>) = 0;
 
     // Creates a directory at a given path.  If exclusive flag is true, it fails if the path already exists.
     // AsyncFileSystemCallbacks::didSucceed() is called when the operation is completed successfully.
     // AsyncFileSystemCallbacks::didFail() is called otherwise.
-    virtual void createDirectory(const String& path, bool exclusive, PassOwnPtr<AsyncFileSystemCallbacks>) = 0;
+    virtual void createDirectory(const KURL& path, bool exclusive, PassOwnPtr<AsyncFileSystemCallbacks>) = 0;
 
     // Checks if a file exists at a given path.
     // AsyncFileSystemCallbacks::didSucceed() is called if the file exists.
     // AsyncFileSystemCallbacks::didFail() is called otherwise.
-    virtual void fileExists(const String& path, PassOwnPtr<AsyncFileSystemCallbacks>) = 0;
+    virtual void fileExists(const KURL& path, PassOwnPtr<AsyncFileSystemCallbacks>) = 0;
 
     // Checks if a directory exists at a given path.
     // AsyncFileSystemCallbacks::didSucceed() is called if the directory exists.
     // AsyncFileSystemCallbacks::didFail() is called otherwise.
-    virtual void directoryExists(const String& path, PassOwnPtr<AsyncFileSystemCallbacks>) = 0;
+    virtual void directoryExists(const KURL& path, PassOwnPtr<AsyncFileSystemCallbacks>) = 0;
 
     // Reads directory entries of a given directory at path.
     // AsyncFileSystemCallbacks::didReadDirectoryEntry() is called when each directory entry is called. AsyncFileSystemCallbacks::didReadDirectoryEntries() is called after a chunk of directory entries have been read.
     // AsyncFileSystemCallbacks::didFail() is when there is an error.
-    virtual void readDirectory(const String& path, PassOwnPtr<AsyncFileSystemCallbacks>) = 0;
+    virtual void readDirectory(const KURL& path, PassOwnPtr<AsyncFileSystemCallbacks>) = 0;
 
     // Creates an AsyncFileWriter for a given file path.
     // AsyncFileSystemCallbacks::didCreateFileWriter() is called when an AsyncFileWriter is created successfully.
     // AsyncFileSystemCallbacks::didFail() is called otherwise.
-    virtual void createWriter(AsyncFileWriterClient* client, const String& path, PassOwnPtr<AsyncFileSystemCallbacks>) = 0;
+    virtual void createWriter(AsyncFileWriterClient*, const KURL& path, PassOwnPtr<AsyncFileSystemCallbacks>) = 0;
 
     // Creates a snapshot file and read its metadata for a new File object.
     // In local filesystem cases the backend may simply return the metadata of the file itself (as well as readMetadata does),
     // while in remote filesystem case the backend may download the file into a temporary snapshot file and return the metadata of the temporary file.
     // AsyncFileSystemCallbacks::didReadMetadata() is called when the metadata for the snapshot file is successfully returned.
     // AsyncFileSystemCallbacks::didFail() is called otherwise.
-    virtual void createSnapshotFileAndReadMetadata(const String& path, PassOwnPtr<AsyncFileSystemCallbacks>) = 0;
-
-    FileSystemType type() const { return m_type; }
+    virtual void createSnapshotFileAndReadMetadata(const KURL& path, PassOwnPtr<AsyncFileSystemCallbacks>) = 0;
 
 protected:
-    AsyncFileSystem(FileSystemType type)
-        : m_type(type)
-    {
-    }
-
-    FileSystemType m_type;
+    AsyncFileSystem() { }
 };
 
 } // namespace WebCore
index d8a85e7..61b3386 100644 (file)
@@ -49,7 +49,7 @@ public:
     virtual void didSucceed() { ASSERT_NOT_REACHED(); }
 
     // Called when a requested file system is opened.
-    virtual void didOpenFileSystem(const String& name, PassOwnPtr<AsyncFileSystem>) { ASSERT_NOT_REACHED(); }
+    virtual void didOpenFileSystem(const String& name, const KURL& rootURL, PassOwnPtr<AsyncFileSystem>) { ASSERT_NOT_REACHED(); }
 
     // Called when a file metadata is read successfully.
     virtual void didReadMetadata(const FileMetadata&) { ASSERT_NOT_REACHED(); }
index dc26bb5..71601ec 100644 (file)
@@ -35,42 +35,22 @@ bool AsyncFileSystem::isAvailable()
     return false;
 }
 
-bool AsyncFileSystem::isValidType(FileSystemType type)
+PassOwnPtr<AsyncFileSystem> AsyncFileSystem::create()
 {
-    UNUSED_PARAM(type);
-
-    notImplemented();
-    return false;
+    return adoptPtr(new AsyncFileSystemBlackBerry());
 }
 
-PassOwnPtr<AsyncFileSystem> AsyncFileSystem::create(FileSystemType type)
-{
-    return adoptPtr(new AsyncFileSystemBlackBerry(type));
-}
-
-void AsyncFileSystem::openFileSystem(const String& basePath, const String& storageIdentifier, FileSystemType type, bool, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
+void AsyncFileSystem::openFileSystem(const KURL& basePath, const String& storageIdentifier, bool, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
 {
     UNUSED_PARAM(basePath);
     UNUSED_PARAM(storageIdentifier);
-    UNUSED_PARAM(type);
     UNUSED_PARAM(callbacks);
 
     notImplemented();
     callbacks->didFail(NOT_SUPPORTED_ERR);
 }
 
-bool AsyncFileSystem::crackFileSystemURL(const KURL& url, FileSystemType& type, String& filePath)
-{
-    UNUSED_PARAM(url);
-    UNUSED_PARAM(type);
-    UNUSED_PARAM(filePath);
-
-    notImplemented();
-    return false;
-}
-
-AsyncFileSystemBlackBerry::AsyncFileSystemBlackBerry(FileSystemType type)
-    : AsyncFileSystem(type)
+AsyncFileSystemBlackBerry::AsyncFileSystemBlackBerry()
 {
     notImplemented();
 }
@@ -80,16 +60,7 @@ AsyncFileSystemBlackBerry::~AsyncFileSystemBlackBerry()
     notImplemented();
 }
 
-KURL AsyncFileSystemBlackBerry::toURL(const String& originString, const String& fullPath) const
-{
-    UNUSED_PARAM(originString);
-    UNUSED_PARAM(fullPath);
-
-    notImplemented();
-    return KURL();
-}
-
-void AsyncFileSystemBlackBerry::move(const String& sourcePath, const String& destinationPath, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
+void AsyncFileSystemBlackBerry::move(const KURL& sourcePath, const KURL& destinationPath, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
 {
     UNUSED_PARAM(sourcePath);
     UNUSED_PARAM(destinationPath);
@@ -98,7 +69,7 @@ void AsyncFileSystemBlackBerry::move(const String& sourcePath, const String& des
     notImplemented();
 }
 
-void AsyncFileSystemBlackBerry::copy(const String& sourcePath, const String& destinationPath, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
+void AsyncFileSystemBlackBerry::copy(const KURL& sourcePath, const KURL& destinationPath, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
 {
     UNUSED_PARAM(sourcePath);
     UNUSED_PARAM(destinationPath);
@@ -107,7 +78,7 @@ void AsyncFileSystemBlackBerry::copy(const String& sourcePath, const String& des
     notImplemented();
 }
 
-void AsyncFileSystemBlackBerry::remove(const String& path, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
+void AsyncFileSystemBlackBerry::remove(const KURL& path, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
 {
     UNUSED_PARAM(path);
     UNUSED_PARAM(callbacks);
@@ -115,7 +86,7 @@ void AsyncFileSystemBlackBerry::remove(const String& path, PassOwnPtr<AsyncFileS
     notImplemented();
 }
 
-void AsyncFileSystemBlackBerry::removeRecursively(const String& path, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
+void AsyncFileSystemBlackBerry::removeRecursively(const KURL& path, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
 {
     UNUSED_PARAM(path);
     UNUSED_PARAM(callbacks);
@@ -123,7 +94,7 @@ void AsyncFileSystemBlackBerry::removeRecursively(const String& path, PassOwnPtr
     notImplemented();
 }
 
-void AsyncFileSystemBlackBerry::readMetadata(const String& path, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
+void AsyncFileSystemBlackBerry::readMetadata(const KURL& path, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
 {
     UNUSED_PARAM(path);
     UNUSED_PARAM(callbacks);
@@ -131,7 +102,7 @@ void AsyncFileSystemBlackBerry::readMetadata(const String& path, PassOwnPtr<Asyn
     notImplemented();
 }
 
-void AsyncFileSystemBlackBerry::createFile(const String& path, bool exclusive, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
+void AsyncFileSystemBlackBerry::createFile(const KURL& path, bool exclusive, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
 {
     UNUSED_PARAM(path);
     UNUSED_PARAM(exclusive);
@@ -140,7 +111,7 @@ void AsyncFileSystemBlackBerry::createFile(const String& path, bool exclusive, P
     notImplemented();
 }
 
-void AsyncFileSystemBlackBerry::createDirectory(const String& path, bool exclusive, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
+void AsyncFileSystemBlackBerry::createDirectory(const KURL& path, bool exclusive, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
 {
     UNUSED_PARAM(path);
     UNUSED_PARAM(exclusive);
@@ -149,7 +120,7 @@ void AsyncFileSystemBlackBerry::createDirectory(const String& path, bool exclusi
     notImplemented();
 }
 
-void AsyncFileSystemBlackBerry::fileExists(const String& path, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
+void AsyncFileSystemBlackBerry::fileExists(const KURL& path, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
 {
     UNUSED_PARAM(path);
     UNUSED_PARAM(callbacks);
@@ -157,7 +128,7 @@ void AsyncFileSystemBlackBerry::fileExists(const String& path, PassOwnPtr<AsyncF
     notImplemented();
 }
 
-void AsyncFileSystemBlackBerry::directoryExists(const String& path, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
+void AsyncFileSystemBlackBerry::directoryExists(const KURL& path, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
 {
     UNUSED_PARAM(path);
     UNUSED_PARAM(callbacks);
@@ -165,7 +136,7 @@ void AsyncFileSystemBlackBerry::directoryExists(const String& path, PassOwnPtr<A
     notImplemented();
 }
 
-void AsyncFileSystemBlackBerry::readDirectory(const String& path, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
+void AsyncFileSystemBlackBerry::readDirectory(const KURL& path, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
 {
     UNUSED_PARAM(path);
     UNUSED_PARAM(callbacks);
@@ -174,7 +145,7 @@ void AsyncFileSystemBlackBerry::readDirectory(const String& path, PassOwnPtr<Asy
 }
 
 
-void AsyncFileSystemBlackBerry::createWriter(AsyncFileWriterClient* client, const String& path, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
+void AsyncFileSystemBlackBerry::createWriter(AsyncFileWriterClient* client, const KURL& path, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
 {
     UNUSED_PARAM(client);
     UNUSED_PARAM(path);
@@ -183,7 +154,7 @@ void AsyncFileSystemBlackBerry::createWriter(AsyncFileWriterClient* client, cons
     notImplemented();
 }
 
-void AsyncFileSystemBlackBerry::createSnapshotFileAndReadMetadata(const String& path, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
+void AsyncFileSystemBlackBerry::createSnapshotFileAndReadMetadata(const KURL& path, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
 {
     UNUSED_PARAM(path);
     UNUSED_PARAM(callbacks);
index 38b17c7..e477bdc 100644 (file)
@@ -27,21 +27,20 @@ namespace WebCore {
 
 class AsyncFileSystemBlackBerry : public AsyncFileSystem {
 public:
-    AsyncFileSystemBlackBerry(FileSystemType);
+    AsyncFileSystemBlackBerry();
     virtual ~AsyncFileSystemBlackBerry();
-    virtual KURL toURL(const String& originString, const String& fullPath) const;
-    virtual void move(const String& sourcePath, const String& destinationPath, PassOwnPtr<AsyncFileSystemCallbacks>);
-    virtual void copy(const String& sourcePath, const String& destinationPath, PassOwnPtr<AsyncFileSystemCallbacks>);
-    virtual void remove(const String& path, PassOwnPtr<AsyncFileSystemCallbacks>);
-    virtual void removeRecursively(const String& path, PassOwnPtr<AsyncFileSystemCallbacks>);
-    virtual void readMetadata(const String& path, PassOwnPtr<AsyncFileSystemCallbacks>);
-    virtual void createFile(const String& path, bool exclusive, PassOwnPtr<AsyncFileSystemCallbacks>);
-    virtual void createDirectory(const String& path, bool exclusive, PassOwnPtr<AsyncFileSystemCallbacks>);
-    virtual void fileExists(const String& path, PassOwnPtr<AsyncFileSystemCallbacks>);
-    virtual void directoryExists(const String& path, PassOwnPtr<AsyncFileSystemCallbacks>);
-    virtual void readDirectory(const String& path, PassOwnPtr<AsyncFileSystemCallbacks>);
-    virtual void createWriter(AsyncFileWriterClient*, const String& path, PassOwnPtr<AsyncFileSystemCallbacks>);
-    virtual void createSnapshotFileAndReadMetadata(const String& path, PassOwnPtr<AsyncFileSystemCallbacks>);
+    virtual void move(const KURL& sourcePath, const KURL& destinationPath, PassOwnPtr<AsyncFileSystemCallbacks>);
+    virtual void copy(const KURL& sourcePath, const KURL& destinationPath, PassOwnPtr<AsyncFileSystemCallbacks>);
+    virtual void remove(const KURL& path, PassOwnPtr<AsyncFileSystemCallbacks>);
+    virtual void removeRecursively(const KURL& path, PassOwnPtr<AsyncFileSystemCallbacks>);
+    virtual void readMetadata(const KURL& path, PassOwnPtr<AsyncFileSystemCallbacks>);
+    virtual void createFile(const KURL& path, bool exclusive, PassOwnPtr<AsyncFileSystemCallbacks>);
+    virtual void createDirectory(const KURL& path, bool exclusive, PassOwnPtr<AsyncFileSystemCallbacks>);
+    virtual void fileExists(const KURL& path, PassOwnPtr<AsyncFileSystemCallbacks>);
+    virtual void directoryExists(const KURL& path, PassOwnPtr<AsyncFileSystemCallbacks>);
+    virtual void readDirectory(const KURL& path, PassOwnPtr<AsyncFileSystemCallbacks>);
+    virtual void createWriter(AsyncFileWriterClient*, const KURL& path, PassOwnPtr<AsyncFileSystemCallbacks>);
+    virtual void createSnapshotFileAndReadMetadata(const KURL& path, PassOwnPtr<AsyncFileSystemCallbacks>);
 };
 
 } // namespace WebCore
index baeab05..1febf33 100644 (file)
@@ -142,8 +142,7 @@ public:
     static int writeToFile(PlatformFileHandle, const char* data, int length);
 
 #if ENABLE(FILE_SYSTEM)
-    static String createIsolatedFileSystemName(const String& storageIdentifier, const String& filesystemId);
-    static PassOwnPtr<AsyncFileSystem> createIsolatedFileSystem(const String& originString, const String& filesystemId);
+    static PassOwnPtr<AsyncFileSystem> createAsyncFileSystem();
 #endif
 
     // Font ---------------------------------------------------------------
index 6b01884..aa60ba4 100644 (file)
@@ -35,31 +35,18 @@ bool AsyncFileSystem::isAvailable()
     return false;
 }
 
-bool AsyncFileSystem::isValidType(FileSystemType type)
+PassOwnPtr<AsyncFileSystem> AsyncFileSystem::create()
 {
-    notImplemented();
-    return false;
+    return adoptPtr(new AsyncFileSystemGtk());
 }
 
-PassOwnPtr<AsyncFileSystem> AsyncFileSystem::create(FileSystemType type)
-{
-    return adoptPtr(new AsyncFileSystemGtk(type));
-}
-
-void AsyncFileSystem::openFileSystem(const String& basePath, const String& storageIdentifier, FileSystemType type, bool, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
+void AsyncFileSystem::openFileSystem(const KURL& basePath, const String& storageIdentifier, bool, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
 {
     notImplemented();
     callbacks->didFail(NOT_SUPPORTED_ERR);
 }
 
-bool AsyncFileSystem::crackFileSystemURL(const KURL& url, FileSystemType& type, String& filePath)
-{
-    notImplemented();
-    return false;
-}
-
-AsyncFileSystemGtk::AsyncFileSystemGtk(FileSystemType type)
-    : AsyncFileSystem(type)
+AsyncFileSystemGtk::AsyncFileSystemGtk()
 {
     notImplemented();
 }
@@ -69,64 +56,58 @@ AsyncFileSystemGtk::~AsyncFileSystemGtk()
     notImplemented();
 }
 
-KURL AsyncFileSystemGtk::toURL(const String& originString, const String& fullPath) const
-{
-    notImplemented();
-    return KURL();
-}
-
-void AsyncFileSystemGtk::move(const String& sourcePath, const String& destinationPath, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
+void AsyncFileSystemGtk::move(const KURL& sourcePath, const KURL& destinationPath, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
 {
     notImplemented();
 }
 
-void AsyncFileSystemGtk::copy(const String& sourcePath, const String& destinationPath, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
+void AsyncFileSystemGtk::copy(const KURL& sourcePath, const KURL& destinationPath, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
 {
     notImplemented();
 }
 
-void AsyncFileSystemGtk::remove(const String& path, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
+void AsyncFileSystemGtk::remove(const KURL& path, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
 {
     notImplemented();
 }
 
-void AsyncFileSystemGtk::removeRecursively(const String& path, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
+void AsyncFileSystemGtk::removeRecursively(const KURL& path, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
 {
     notImplemented();
 }
 
-void AsyncFileSystemGtk::readMetadata(const String& path, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
+void AsyncFileSystemGtk::readMetadata(const KURL& path, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
 {
     notImplemented();
 }
 
-void AsyncFileSystemGtk::createFile(const String& path, bool exclusive, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
+void AsyncFileSystemGtk::createFile(const KURL& path, bool exclusive, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
 {
     notImplemented();
 }
 
-void AsyncFileSystemGtk::createDirectory(const String& path, bool exclusive, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
+void AsyncFileSystemGtk::createDirectory(const KURL& path, bool exclusive, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
 {
     notImplemented();
 }
 
-void AsyncFileSystemGtk::fileExists(const String& path, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
+void AsyncFileSystemGtk::fileExists(const KURL& path, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
 {
     notImplemented();
 }
 
-void AsyncFileSystemGtk::directoryExists(const String& path, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
+void AsyncFileSystemGtk::directoryExists(const KURL& path, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
 {
     notImplemented();
 }
 
-void AsyncFileSystemGtk::readDirectory(const String& path, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
+void AsyncFileSystemGtk::readDirectory(const KURL& path, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
 {
     notImplemented();
 }
 
 
-void AsyncFileSystemGtk::createWriter(AsyncFileWriterClient* client, const String& path, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
+void AsyncFileSystemGtk::createWriter(AsyncFileWriterClient* client, const KURL& path, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
 {
     notImplemented();
 }
index 0bda367..39f5737 100644 (file)
@@ -31,21 +31,20 @@ class AsyncFileSystemCallbacks;
 
 class AsyncFileSystemGtk : public AsyncFileSystem {
 public:
-    AsyncFileSystemGtk(FileSystemType);
+    AsyncFileSystemGtk();
     virtual ~AsyncFileSystemGtk();
 
-    virtual KURL toURL(const String& originString, const String& fullPath) const;
-    virtual void move(const String& sourcePath, const String& destinationPath, PassOwnPtr<AsyncFileSystemCallbacks>);
-    virtual void copy(const String& sourcePath, const String& destinationPath, PassOwnPtr<AsyncFileSystemCallbacks>);
-    virtual void remove(const String& path, PassOwnPtr<AsyncFileSystemCallbacks>);
-    virtual void removeRecursively(const String& path, PassOwnPtr<AsyncFileSystemCallbacks>);
-    virtual void readMetadata(const String& path, PassOwnPtr<AsyncFileSystemCallbacks>);
-    virtual void createFile(const String& path, bool exclusive, PassOwnPtr<AsyncFileSystemCallbacks>);
-    virtual void createDirectory(const String& path, bool exclusive, PassOwnPtr<AsyncFileSystemCallbacks>);
-    virtual void fileExists(const String& path, PassOwnPtr<AsyncFileSystemCallbacks>);
-    virtual void directoryExists(const String& path, PassOwnPtr<AsyncFileSystemCallbacks>);
-    virtual void readDirectory(const String& path, PassOwnPtr<AsyncFileSystemCallbacks>);
-    virtual void createWriter(AsyncFileWriterClient*, const String& path, PassOwnPtr<AsyncFileSystemCallbacks>);
+    virtual void move(const KURL& sourcePath, const KURL& destinationPath, PassOwnPtr<AsyncFileSystemCallbacks>);
+    virtual void copy(const KURL& sourcePath, const KURL& destinationPath, PassOwnPtr<AsyncFileSystemCallbacks>);
+    virtual void remove(const KURL& path, PassOwnPtr<AsyncFileSystemCallbacks>);
+    virtual void removeRecursively(const KURL& path, PassOwnPtr<AsyncFileSystemCallbacks>);
+    virtual void readMetadata(const KURL& path, PassOwnPtr<AsyncFileSystemCallbacks>);
+    virtual void createFile(const KURL& path, bool exclusive, PassOwnPtr<AsyncFileSystemCallbacks>);
+    virtual void createDirectory(const KURL& path, bool exclusive, PassOwnPtr<AsyncFileSystemCallbacks>);
+    virtual void fileExists(const KURL& path, PassOwnPtr<AsyncFileSystemCallbacks>);
+    virtual void directoryExists(const KURL& path, PassOwnPtr<AsyncFileSystemCallbacks>);
+    virtual void readDirectory(const KURL& path, PassOwnPtr<AsyncFileSystemCallbacks>);
+    virtual void createWriter(AsyncFileWriterClient*, const KURL& path, PassOwnPtr<AsyncFileSystemCallbacks>);
 };
 
 } // namespace WebCore
index 146ad0d..d956abe 100644 (file)
@@ -1,3 +1,70 @@
+2012-05-07  Kinuko Yasuda  <kinuko@chromium.org>
+
+        Support cross-filesystem operations in FileSystem API
+        https://bugs.webkit.org/show_bug.cgi?id=84135
+
+        Reviewed by David Levin.
+
+        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):
+
 2012-05-07  Greg Billock  <gbillock@google.com>
 
         [Web Intents] Flagged-off implementation of an intent tag for registration.
index d391ba5..d8b1ab3 100644 (file)
@@ -51,12 +51,6 @@ namespace WebCore {
 
 namespace {
 
-// For isolated filesystem.
-const char isolatedPathPrefix[] = "isolated";
-
-// For external filesystem.
-const char externalPathPrefix[] = "external";
-
 // Specialized callback class for createSnapshotFileAndReadMetadata.
 class SnapshotFileCallbacks : public AsyncFileSystemCallbacks {
 public:
@@ -101,149 +95,64 @@ bool AsyncFileSystem::isAvailable()
     return true;
 }
 
-// static
-bool AsyncFileSystem::crackFileSystemURL(const KURL& url, FileSystemType& type, String& filePath)
-{
-    if (!url.protocolIs("filesystem"))
-        return false;
-
-    if (url.innerURL()) {
-        String typeString = url.innerURL()->path().substring(1);
-        if (typeString == temporaryPathPrefix)
-            type = FileSystemTypeTemporary;
-        else if (typeString == persistentPathPrefix)
-            type = FileSystemTypePersistent;
-        else if (typeString == externalPathPrefix)
-            type = FileSystemTypeExternal;
-        else
-            return false;
-
-        filePath = decodeURLEscapeSequences(url.path());
-    }
-    return true;
-}
-
-// static
-bool AsyncFileSystem::isValidType(FileSystemType type)
-{
-    return type == FileSystemTypeTemporary || type == FileSystemTypePersistent || type == FileSystemTypeExternal;
-}
-
-AsyncFileSystemChromium::AsyncFileSystemChromium(FileSystemType type, const KURL& rootURL)
-    : AsyncFileSystem(type)
-    , m_webFileSystem(WebKit::Platform::current()->fileSystem())
-    , m_filesystemRootURL(rootURL)
+AsyncFileSystemChromium::AsyncFileSystemChromium()
+    : m_webFileSystem(WebKit::webKitPlatformSupport()->fileSystem())
 {
     ASSERT(m_webFileSystem);
 }
 
-// static
-String AsyncFileSystemChromium::createIsolatedFileSystemName(const String& storageIdentifier, const String& filesystemId)
-{
-    StringBuilder filesystemName;
-    filesystemName.append(storageIdentifier);
-    filesystemName.append(":");
-    filesystemName.append(isolatedPathPrefix);
-    filesystemName.append("_");
-    filesystemName.append(filesystemId);
-    return filesystemName.toString();
-}
-
-// static
-PassOwnPtr<AsyncFileSystem> AsyncFileSystemChromium::createIsolatedFileSystem(const String& originString, const String& filesystemId)
-{
-    // The rootURL is used in succeeding filesystem requests sent to the
-    // chromium and is validated each time in the browser process.
-    StringBuilder rootURL;
-    rootURL.append("filesystem:");
-    rootURL.append(originString);
-    rootURL.append("/");
-    rootURL.append(isolatedPathPrefix);
-    rootURL.append("/");
-    rootURL.append(filesystemId);
-    rootURL.append("/");
-
-    return AsyncFileSystemChromium::create(FileSystemTypeIsolated, KURL(ParsedURLString, rootURL.toString()));
-}
-
 AsyncFileSystemChromium::~AsyncFileSystemChromium()
 {
 }
 
-KURL AsyncFileSystemChromium::toURL(const String& originString, const String& fullPath) const
-{
-    ASSERT(!originString.isEmpty());
-    if (originString == "null")
-        return KURL();
-
-    // For now we don't support toURL for isolated filesystem (until we resolve the isolated filesystem lifetime issue).
-    if (type() == FileSystemTypeIsolated)
-        return KURL();
-
-    if (type() == FileSystemTypeExternal) {
-        // For external filesystem originString could be different from what we have in m_filesystemRootURL.
-        StringBuilder result;
-        result.append("filesystem:");
-        result.append(originString);
-        result.append("/");
-        result.append(externalPathPrefix);
-        result.append(encodeWithURLEscapeSequences(fullPath));
-        return KURL(ParsedURLString, result.toString());
-    }
-
-    // For regular types we can just call virtualPathToFileSystemURL which appends the fullPath to the m_filesystemRootURL that should look like 'filesystem:<origin>/<typePrefix>'.
-    ASSERT(SecurityOrigin::create(m_filesystemRootURL)->toString() == originString);
-    return KURL(ParsedURLString, virtualPathToFileSystemURL(fullPath));
-}
-
-void AsyncFileSystemChromium::move(const String& sourcePath, const String& destinationPath, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
+void AsyncFileSystemChromium::move(const KURL& sourcePath, const KURL& destinationPath, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
 {
-    m_webFileSystem->move(virtualPathToFileSystemURL(sourcePath), virtualPathToFileSystemURL(destinationPath), new WebKit::WebFileSystemCallbacksImpl(callbacks));
+    m_webFileSystem->move(sourcePath, destinationPath, new WebKit::WebFileSystemCallbacksImpl(callbacks));
 }
 
-void AsyncFileSystemChromium::copy(const String& sourcePath, const String& destinationPath, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
+void AsyncFileSystemChromium::copy(const KURL& sourcePath, const KURL& destinationPath, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
 {
-    m_webFileSystem->copy(virtualPathToFileSystemURL(sourcePath), virtualPathToFileSystemURL(destinationPath), new WebKit::WebFileSystemCallbacksImpl(callbacks));
+    m_webFileSystem->copy(sourcePath, destinationPath, new WebKit::WebFileSystemCallbacksImpl(callbacks));
 }
 
-void AsyncFileSystemChromium::remove(const String& path, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
+void AsyncFileSystemChromium::remove(const KURL& path, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
 {
-    m_webFileSystem->remove(virtualPathToFileSystemURL(path), new WebKit::WebFileSystemCallbacksImpl(callbacks));
+    m_webFileSystem->remove(path, new WebKit::WebFileSystemCallbacksImpl(callbacks));
 }
 
-void AsyncFileSystemChromium::removeRecursively(const String& path, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
+void AsyncFileSystemChromium::removeRecursively(const KURL& path, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
 {
-    m_webFileSystem->removeRecursively(virtualPathToFileSystemURL(path), new WebKit::WebFileSystemCallbacksImpl(callbacks));
+    m_webFileSystem->removeRecursively(path, new WebKit::WebFileSystemCallbacksImpl(callbacks));
 }
 
-void AsyncFileSystemChromium::readMetadata(const String& path, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
+void AsyncFileSystemChromium::readMetadata(const KURL& path, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
 {
-    m_webFileSystem->readMetadata(virtualPathToFileSystemURL(path), new WebKit::WebFileSystemCallbacksImpl(callbacks));
+    m_webFileSystem->readMetadata(path, new WebKit::WebFileSystemCallbacksImpl(callbacks));
 }
 
-void AsyncFileSystemChromium::createFile(const String& path, bool exclusive, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
+void AsyncFileSystemChromium::createFile(const KURL& path, bool exclusive, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
 {
-    m_webFileSystem->createFile(virtualPathToFileSystemURL(path), exclusive, new WebKit::WebFileSystemCallbacksImpl(callbacks));
+    m_webFileSystem->createFile(path, exclusive, new WebKit::WebFileSystemCallbacksImpl(callbacks));
 }
 
-void AsyncFileSystemChromium::createDirectory(const String& path, bool exclusive, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
+void AsyncFileSystemChromium::createDirectory(const KURL& path, bool exclusive, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
 {
-    m_webFileSystem->createDirectory(virtualPathToFileSystemURL(path), exclusive, new WebKit::WebFileSystemCallbacksImpl(callbacks));
+    m_webFileSystem->createDirectory(path, exclusive, new WebKit::WebFileSystemCallbacksImpl(callbacks));
 }
 
-void AsyncFileSystemChromium::fileExists(const String& path, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
+void AsyncFileSystemChromium::fileExists(const KURL& path, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
 {
-    m_webFileSystem->fileExists(virtualPathToFileSystemURL(path), new WebKit::WebFileSystemCallbacksImpl(callbacks));
+    m_webFileSystem->fileExists(path, new WebKit::WebFileSystemCallbacksImpl(callbacks));
 }
 
-void AsyncFileSystemChromium::directoryExists(const String& path, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
+void AsyncFileSystemChromium::directoryExists(const KURL& path, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
 {
-    m_webFileSystem->directoryExists(virtualPathToFileSystemURL(path), new WebKit::WebFileSystemCallbacksImpl(callbacks));
+    m_webFileSystem->directoryExists(path, new WebKit::WebFileSystemCallbacksImpl(callbacks));
 }
 
-void AsyncFileSystemChromium::readDirectory(const String& path, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
+void AsyncFileSystemChromium::readDirectory(const KURL& path, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
 {
-    m_webFileSystem->readDirectory(virtualPathToFileSystemURL(path), new WebKit::WebFileSystemCallbacksImpl(callbacks));
+    m_webFileSystem->readDirectory(path, new WebKit::WebFileSystemCallbacksImpl(callbacks));
 }
 
 class FileWriterHelperCallbacks : public WebKit::WebFileSystemCallbacks {
@@ -300,28 +209,17 @@ private:
     OwnPtr<WebCore::AsyncFileSystemCallbacks> m_callbacks;
 };
 
-void AsyncFileSystemChromium::createWriter(AsyncFileWriterClient* client, const String& path, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
+void AsyncFileSystemChromium::createWriter(AsyncFileWriterClient* client, const KURL& path, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
 {
-    KURL pathAsURL = virtualPathToFileSystemURL(path);
-    m_webFileSystem->readMetadata(pathAsURL, new FileWriterHelperCallbacks(client, pathAsURL, m_webFileSystem, callbacks));
+    m_webFileSystem->readMetadata(path, new FileWriterHelperCallbacks(client, path, m_webFileSystem, callbacks));
 }
 
-void AsyncFileSystemChromium::createSnapshotFileAndReadMetadata(const String& path, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
+void AsyncFileSystemChromium::createSnapshotFileAndReadMetadata(const KURL& path, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
 {
-    KURL pathAsURL = virtualPathToFileSystemURL(path);
     KURL internalBlobURL = BlobURL::createInternalURL();
 
     // This will create a snapshot file and register the file to a blob using the given internalBlobURL.
-    m_webFileSystem->createSnapshotFileAndReadMetadata(internalBlobURL, pathAsURL, new WebKit::WebFileSystemCallbacksImpl(createSnapshotFileCallback(internalBlobURL, callbacks)));
-}
-
-KURL AsyncFileSystemChromium::virtualPathToFileSystemURL(const String& virtualPath) const
-{
-    ASSERT(!m_filesystemRootURL.isEmpty());
-    KURL url = m_filesystemRootURL;
-    // Remove the extra leading slash.
-    url.setPath(url.path() + encodeWithURLEscapeSequences(virtualPath.substring(1)));
-    return url;
+    m_webFileSystem->createSnapshotFileAndReadMetadata(internalBlobURL, path, new WebKit::WebFileSystemCallbacksImpl(createSnapshotFileCallback(internalBlobURL, callbacks)));
 }
 
 PassOwnPtr<AsyncFileSystemCallbacks> AsyncFileSystemChromium::createSnapshotFileCallback(const KURL& internalBlobURL, PassOwnPtr<AsyncFileSystemCallbacks> callbacks) const
index e827855..7e1af32 100644 (file)
@@ -43,45 +43,35 @@ class WebFileSystem;
 namespace WebCore {
 
 class AsyncFileSystemCallbacks;
-class KURL;
 
 class AsyncFileSystemChromium : public AsyncFileSystem {
 public:
-    static PassOwnPtr<AsyncFileSystem> create(FileSystemType type, const KURL& rootURL)
+    static PassOwnPtr<AsyncFileSystem> create()
     {
-        return adoptPtr(new AsyncFileSystemChromium(type, rootURL));
+        return adoptPtr(new AsyncFileSystemChromium());
     }
 
-    static String createIsolatedFileSystemName(const String& storageIdentifier, const String& filesystemId);
-    static PassOwnPtr<AsyncFileSystem> createIsolatedFileSystem(const String& originString, const String& filesystemId);
-
     virtual ~AsyncFileSystemChromium();
 
-    virtual KURL toURL(const String& originString, const String& fullPath) const;
-    virtual void move(const String& sourcePath, const String& destinationPath, PassOwnPtr<AsyncFileSystemCallbacks>);
-    virtual void copy(const String& sourcePath, const String& destinationPath, PassOwnPtr<AsyncFileSystemCallbacks>);
-    virtual void remove(const String& path, PassOwnPtr<AsyncFileSystemCallbacks>);
-    virtual void removeRecursively(const String& path, PassOwnPtr<AsyncFileSystemCallbacks>);
-    virtual void readMetadata(const String& path, PassOwnPtr<AsyncFileSystemCallbacks>);
-    virtual void createFile(const String& path, bool exclusive, PassOwnPtr<AsyncFileSystemCallbacks>);
-    virtual void createDirectory(const String& path, bool exclusive, PassOwnPtr<AsyncFileSystemCallbacks>);
-    virtual void fileExists(const String& path, PassOwnPtr<AsyncFileSystemCallbacks>);
-    virtual void directoryExists(const String& path, PassOwnPtr<AsyncFileSystemCallbacks>);
-    virtual void readDirectory(const String& path, PassOwnPtr<AsyncFileSystemCallbacks>);
-    virtual void createWriter(AsyncFileWriterClient* client, const String& path, PassOwnPtr<AsyncFileSystemCallbacks>);
-    virtual void createSnapshotFileAndReadMetadata(const String& path, PassOwnPtr<AsyncFileSystemCallbacks>);
+    virtual void move(const KURL& sourcePath, const KURL& destinationPath, PassOwnPtr<AsyncFileSystemCallbacks>);
+    virtual void copy(const KURL& sourcePath, const KURL& destinationPath, PassOwnPtr<AsyncFileSystemCallbacks>);
+    virtual void remove(const KURL& path, PassOwnPtr<AsyncFileSystemCallbacks>);
+    virtual void removeRecursively(const KURL& path, PassOwnPtr<AsyncFileSystemCallbacks>);
+    virtual void readMetadata(const KURL& path, PassOwnPtr<AsyncFileSystemCallbacks>);
+    virtual void createFile(const KURL& path, bool exclusive, PassOwnPtr<AsyncFileSystemCallbacks>);
+    virtual void createDirectory(const KURL& path, bool exclusive, PassOwnPtr<AsyncFileSystemCallbacks>);
+    virtual void fileExists(const KURL& path, PassOwnPtr<AsyncFileSystemCallbacks>);
+    virtual void directoryExists(const KURL& path, PassOwnPtr<AsyncFileSystemCallbacks>);
+    virtual void readDirectory(const KURL& path, PassOwnPtr<AsyncFileSystemCallbacks>);
+    virtual void createWriter(AsyncFileWriterClient*, const KURL& path, PassOwnPtr<AsyncFileSystemCallbacks>);
+    virtual void createSnapshotFileAndReadMetadata(const KURL& path, PassOwnPtr<AsyncFileSystemCallbacks>);
 
 protected:
-    AsyncFileSystemChromium(FileSystemType, const KURL& rootURL);
+    AsyncFileSystemChromium();
 
     PassOwnPtr<AsyncFileSystemCallbacks> createSnapshotFileCallback(const KURL& internalBlobURL, PassOwnPtr<AsyncFileSystemCallbacks>) const;
 
     WebKit::WebFileSystem* m_webFileSystem;
-
-    // Converts a given absolute virtual path to a full origin-qualified FileSystem URL.
-    KURL virtualPathToFileSystemURL(const String& virtualPath) const;
-
-    KURL m_filesystemRootURL;
 };
 
 } // namespace WebCore
index a2448c2..6fded29 100644 (file)
@@ -194,7 +194,7 @@ static void openFileSystemHelper(ScriptExecutionContext* context, FileSystemType
         if (webView->permissionClient() && !webView->permissionClient()->allowFileSystem(webFrame))
             allowed = false;
         else
-            webFrame->client()->openFileSystem(webFrame, static_cast<WebFileSystem::Type>(type), size, create == CreateIfNotPresent, new WebFileSystemCallbacksImpl(callbacks, type));
+            webFrame->client()->openFileSystem(webFrame, static_cast<WebFileSystem::Type>(type), size, create == CreateIfNotPresent, new WebFileSystemCallbacksImpl(callbacks));
     } else {
 #if ENABLE(WORKERS)
         WorkerContext* workerContext = static_cast<WorkerContext*>(context);
@@ -203,7 +203,7 @@ static void openFileSystemHelper(ScriptExecutionContext* context, FileSystemType
         if (!allowFileSystemForWorker(webWorker->commonClient()))
             allowed = false;
         else
-            openFileSystemForWorker(webWorker->commonClient(), static_cast<WebFileSystem::Type>(type), size, create == CreateIfNotPresent, new WebFileSystemCallbacksImpl(callbacks, type, context, synchronousType), synchronousType);
+            openFileSystemForWorker(webWorker->commonClient(), static_cast<WebFileSystem::Type>(type), size, create == CreateIfNotPresent, new WebFileSystemCallbacksImpl(callbacks, context, synchronousType), synchronousType);
 
 #else
         ASSERT_NOT_REACHED();
index de9810d..4b6ef27 100644 (file)
@@ -404,14 +404,9 @@ int PlatformSupport::writeToFile(PlatformFileHandle handle, const char* data, in
 }
 
 #if ENABLE(FILE_SYSTEM)
-String PlatformSupport::createIsolatedFileSystemName(const String& storageIdentifier, const String& filesystemId)
+PassOwnPtr<AsyncFileSystem> PlatformSupport::createAsyncFileSystem()
 {
-    return AsyncFileSystemChromium::createIsolatedFileSystemName(storageIdentifier, filesystemId);
-}
-
-PassOwnPtr<AsyncFileSystem> PlatformSupport::createIsolatedFileSystem(const String& originString, const String& filesystemId)
-{
-    return AsyncFileSystemChromium::createIsolatedFileSystem(originString, filesystemId);
+    return AsyncFileSystemChromium::create();
 }
 #endif
 
index 52776c5..06809e5 100644 (file)
@@ -47,9 +47,8 @@ using namespace WebCore;
 
 namespace WebKit {
 
-WebFileSystemCallbacksImpl::WebFileSystemCallbacksImpl(PassOwnPtr<AsyncFileSystemCallbacks> callbacks, WebCore::FileSystemType type, WebCore::ScriptExecutionContext* context, FileSystemSynchronousType synchronousType)
+WebFileSystemCallbacksImpl::WebFileSystemCallbacksImpl(PassOwnPtr<AsyncFileSystemCallbacks> callbacks, ScriptExecutionContext* context, FileSystemSynchronousType synchronousType)
     : m_callbacks(callbacks)
-    , m_type(type)
     , m_context(context)
     , m_synchronousType(synchronousType)
 {
@@ -92,11 +91,11 @@ void WebFileSystemCallbacksImpl::didOpenFileSystem(const WebString& name, const
 
 #if ENABLE(WORKERS)
     if (m_context && m_context->isWorkerContext()) {
-        m_callbacks->didOpenFileSystem(name, WorkerAsyncFileSystemChromium::create(m_context, m_type, rootURL, m_synchronousType));
+        m_callbacks->didOpenFileSystem(name, rootURL, WorkerAsyncFileSystemChromium::create(m_context, m_synchronousType));
         return;
     }
 #endif
-    m_callbacks->didOpenFileSystem(name, AsyncFileSystemChromium::create(m_type, rootURL));
+    m_callbacks->didOpenFileSystem(name, rootURL, AsyncFileSystemChromium::create());
 }
 
 void WebFileSystemCallbacksImpl::didFail(WebFileError error)
index 86c8776..e5f0408 100644 (file)
@@ -52,7 +52,7 @@ class WebURL;
 
 class WebFileSystemCallbacksImpl : public WebFileSystemCallbacks {
 public:
-    WebFileSystemCallbacksImpl(PassOwnPtr<WebCore::AsyncFileSystemCallbacks>, WebCore::FileSystemType = WebCore::FileSystemTypeTemporary, WebCore::ScriptExecutionContext* = 0, WebCore::FileSystemSynchronousType = WebCore::AsynchronousFileSystem);
+    WebFileSystemCallbacksImpl(PassOwnPtr<WebCore::AsyncFileSystemCallbacks>, WebCore::ScriptExecutionContext* = 0, WebCore::FileSystemSynchronousType = WebCore::AsynchronousFileSystem);
     virtual ~WebFileSystemCallbacksImpl();
 
     virtual void didSucceed();
@@ -64,9 +64,6 @@ public:
 private:
     OwnPtr<WebCore::AsyncFileSystemCallbacks> m_callbacks;
 
-    // Used for openFileSystem callbacks.
-    WebCore::FileSystemType m_type;
-
     // Used for worker's openFileSystem callbacks.
     WebCore::ScriptExecutionContext* m_context;
     WebCore::FileSystemSynchronousType m_synchronousType;
index d3ceef2..3d5aa5a 100644 (file)
@@ -939,7 +939,7 @@ v8::Handle<v8::Value> WebFrameImpl::createFileSystem(WebFileSystem::Type type,
                                                      const WebString& name,
                                                      const WebString& path)
 {
-    return toV8(DOMFileSystem::create(frame()->document(), name, AsyncFileSystemChromium::create(static_cast<WebCore::FileSystemType>(type), KURL(ParsedURLString, path.utf8().data()))));
+    return toV8(DOMFileSystem::create(frame()->document(), name, static_cast<WebCore::FileSystemType>(type), KURL(ParsedURLString, path.utf8().data()), AsyncFileSystemChromium::create()));
 }
 
 v8::Handle<v8::Value> WebFrameImpl::createFileEntry(WebFileSystem::Type type,
@@ -948,7 +948,7 @@ v8::Handle<v8::Value> WebFrameImpl::createFileEntry(WebFileSystem::Type type,
                                                     const WebString& filePath,
                                                     bool isDirectory)
 {
-    RefPtr<DOMFileSystemBase> fileSystem = DOMFileSystem::create(frame()->document(), fileSystemName, AsyncFileSystemChromium::create(static_cast<WebCore::FileSystemType>(type), KURL(ParsedURLString, fileSystemPath.utf8().data())));
+    RefPtr<DOMFileSystemBase> fileSystem = DOMFileSystem::create(frame()->document(), fileSystemName, static_cast<WebCore::FileSystemType>(type), KURL(ParsedURLString, fileSystemPath.utf8().data()), AsyncFileSystemChromium::create());
     if (isDirectory)
         return toV8(DirectoryEntry::create(fileSystem, filePath));
     return toV8(FileEntry::create(fileSystem, filePath));
index a554438..044e8f4 100644 (file)
@@ -57,9 +57,8 @@ namespace WebCore {
 
 static const char fileSystemOperationsMode[] = "fileSystemOperationsMode";
 
-WorkerAsyncFileSystemChromium::WorkerAsyncFileSystemChromium(ScriptExecutionContext* context, FileSystemType type, const WebKit::WebURL& rootURL, FileSystemSynchronousType synchronousType)
-    : AsyncFileSystemChromium(type, rootURL)
-    , m_scriptExecutionContext(context)
+WorkerAsyncFileSystemChromium::WorkerAsyncFileSystemChromium(ScriptExecutionContext* context, FileSystemSynchronousType synchronousType)
+    : m_scriptExecutionContext(context)
     , m_workerContext(static_cast<WorkerContext*>(context))
     , m_synchronousType(synchronousType)
 {
@@ -86,54 +85,54 @@ bool WorkerAsyncFileSystemChromium::waitForOperationToComplete()
     return true;
 }
 
-void WorkerAsyncFileSystemChromium::move(const String& sourcePath, const String& destinationPath, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
+void WorkerAsyncFileSystemChromium::move(const KURL& sourcePath, const KURL& destinationPath, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
 {
-    createWorkerFileSystemCallbacksBridge(callbacks)->postMoveToMainThread(m_webFileSystem, virtualPathToFileSystemURL(sourcePath), virtualPathToFileSystemURL(destinationPath), m_modeForCurrentOperation);
+    createWorkerFileSystemCallbacksBridge(callbacks)->postMoveToMainThread(m_webFileSystem, sourcePath, destinationPath, m_modeForCurrentOperation);
 }
 
-void WorkerAsyncFileSystemChromium::copy(const String& sourcePath, const String& destinationPath, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
+void WorkerAsyncFileSystemChromium::copy(const KURL& sourcePath, const KURL& destinationPath, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
 {
-    createWorkerFileSystemCallbacksBridge(callbacks)->postCopyToMainThread(m_webFileSystem, virtualPathToFileSystemURL(sourcePath), virtualPathToFileSystemURL(destinationPath), m_modeForCurrentOperation);
+    createWorkerFileSystemCallbacksBridge(callbacks)->postCopyToMainThread(m_webFileSystem, sourcePath, destinationPath, m_modeForCurrentOperation);
 }
 
-void WorkerAsyncFileSystemChromium::remove(const String& path, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
+void WorkerAsyncFileSystemChromium::remove(const KURL& path, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
 {
-    createWorkerFileSystemCallbacksBridge(callbacks)->postRemoveToMainThread(m_webFileSystem, virtualPathToFileSystemURL(path), m_modeForCurrentOperation);
+    createWorkerFileSystemCallbacksBridge(callbacks)->postRemoveToMainThread(m_webFileSystem, path, m_modeForCurrentOperation);
 }
 
-void WorkerAsyncFileSystemChromium::removeRecursively(const String& path, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
+void WorkerAsyncFileSystemChromium::removeRecursively(const KURL& path, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
 {
-    createWorkerFileSystemCallbacksBridge(callbacks)->postRemoveRecursivelyToMainThread(m_webFileSystem, virtualPathToFileSystemURL(path), m_modeForCurrentOperation);
+    createWorkerFileSystemCallbacksBridge(callbacks)->postRemoveRecursivelyToMainThread(m_webFileSystem, path, m_modeForCurrentOperation);
 }
 
-void WorkerAsyncFileSystemChromium::readMetadata(const String& path, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
+void WorkerAsyncFileSystemChromium::readMetadata(const KURL& path, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
 {
-    createWorkerFileSystemCallbacksBridge(callbacks)->postReadMetadataToMainThread(m_webFileSystem, virtualPathToFileSystemURL(path), m_modeForCurrentOperation);
+    createWorkerFileSystemCallbacksBridge(callbacks)->postReadMetadataToMainThread(m_webFileSystem, path, m_modeForCurrentOperation);
 }
 
-void WorkerAsyncFileSystemChromium::createFile(const String& path, bool exclusive, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
+void WorkerAsyncFileSystemChromium::createFile(const KURL& path, bool exclusive, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
 {
-    createWorkerFileSystemCallbacksBridge(callbacks)->postCreateFileToMainThread(m_webFileSystem, virtualPathToFileSystemURL(path), exclusive, m_modeForCurrentOperation);
+    createWorkerFileSystemCallbacksBridge(callbacks)->postCreateFileToMainThread(m_webFileSystem, path, exclusive, m_modeForCurrentOperation);
 }
 
-void WorkerAsyncFileSystemChromium::createDirectory(const String& path, bool exclusive, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
+void WorkerAsyncFileSystemChromium::createDirectory(const KURL& path, bool exclusive, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
 {
-    createWorkerFileSystemCallbacksBridge(callbacks)->postCreateDirectoryToMainThread(m_webFileSystem, virtualPathToFileSystemURL(path), exclusive, m_modeForCurrentOperation);
+    createWorkerFileSystemCallbacksBridge(callbacks)->postCreateDirectoryToMainThread(m_webFileSystem, path, exclusive, m_modeForCurrentOperation);
 }
 
-void WorkerAsyncFileSystemChromium::fileExists(const String& path, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
+void WorkerAsyncFileSystemChromium::fileExists(const KURL& path, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
 {
-    createWorkerFileSystemCallbacksBridge(callbacks)->postFileExistsToMainThread(m_webFileSystem, virtualPathToFileSystemURL(path), m_modeForCurrentOperation);
+    createWorkerFileSystemCallbacksBridge(callbacks)->postFileExistsToMainThread(m_webFileSystem, path, m_modeForCurrentOperation);
 }
 
-void WorkerAsyncFileSystemChromium::directoryExists(const String& path, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
+void WorkerAsyncFileSystemChromium::directoryExists(const KURL& path, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
 {
-    createWorkerFileSystemCallbacksBridge(callbacks)->postDirectoryExistsToMainThread(m_webFileSystem, virtualPathToFileSystemURL(path), m_modeForCurrentOperation);
+    createWorkerFileSystemCallbacksBridge(callbacks)->postDirectoryExistsToMainThread(m_webFileSystem, path, m_modeForCurrentOperation);
 }
 
-void WorkerAsyncFileSystemChromium::readDirectory(const String& path, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
+void WorkerAsyncFileSystemChromium::readDirectory(const KURL& path, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
 {
-    createWorkerFileSystemCallbacksBridge(callbacks)->postReadDirectoryToMainThread(m_webFileSystem, virtualPathToFileSystemURL(path), m_modeForCurrentOperation);
+    createWorkerFileSystemCallbacksBridge(callbacks)->postReadDirectoryToMainThread(m_webFileSystem, path, m_modeForCurrentOperation);
 }
 
 class WorkerFileWriterHelperCallbacks : public AsyncFileSystemCallbacks {
@@ -203,18 +202,16 @@ private:
     WorkerContext* m_workerContext;
 };
 
-void WorkerAsyncFileSystemChromium::createWriter(AsyncFileWriterClient* client, const String& path, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
+void WorkerAsyncFileSystemChromium::createWriter(AsyncFileWriterClient* client, const KURL& path, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
 {
-    KURL pathAsURL = virtualPathToFileSystemURL(path);
-    createWorkerFileSystemCallbacksBridge(WorkerFileWriterHelperCallbacks::create(client, pathAsURL, m_webFileSystem, callbacks, m_workerContext))->postReadMetadataToMainThread(m_webFileSystem, pathAsURL, m_modeForCurrentOperation);
+    createWorkerFileSystemCallbacksBridge(WorkerFileWriterHelperCallbacks::create(client, path, m_webFileSystem, callbacks, m_workerContext))->postReadMetadataToMainThread(m_webFileSystem, path, m_modeForCurrentOperation);
 }
 
-void WorkerAsyncFileSystemChromium::createSnapshotFileAndReadMetadata(const String& path, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
+void WorkerAsyncFileSystemChromium::createSnapshotFileAndReadMetadata(const KURL& path, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
 {
-    KURL pathAsURL = virtualPathToFileSystemURL(path);
     KURL internalBlobURL = BlobURL::createInternalURL();
 
-    createWorkerFileSystemCallbacksBridge(createSnapshotFileCallback(internalBlobURL, callbacks))->postCreateSnapshotFileToMainThread(m_webFileSystem, internalBlobURL, pathAsURL, m_modeForCurrentOperation);
+    createWorkerFileSystemCallbacksBridge(createSnapshotFileCallback(internalBlobURL, callbacks))->postCreateSnapshotFileToMainThread(m_webFileSystem, internalBlobURL, path, m_modeForCurrentOperation);
 }
 
 PassRefPtr<WorkerFileSystemCallbacksBridge> WorkerAsyncFileSystemChromium::createWorkerFileSystemCallbacksBridge(PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
index 2618c48..6727d1e 100644 (file)
@@ -53,9 +53,9 @@ class WorkerContext;
 
 class WorkerAsyncFileSystemChromium : public AsyncFileSystemChromium {
 public:
-    static PassOwnPtr<AsyncFileSystem> create(ScriptExecutionContext* context, FileSystemType type, const WebKit::WebURL& rootURL, FileSystemSynchronousType synchronousType)
+    static PassOwnPtr<AsyncFileSystem> create(ScriptExecutionContext* context, FileSystemSynchronousType synchronousType)
     {
-        return adoptPtr(new WorkerAsyncFileSystemChromium(context, type, rootURL, synchronousType));
+        return adoptPtr(new WorkerAsyncFileSystemChromium(context, synchronousType));
     }
 
     virtual ~WorkerAsyncFileSystemChromium();
@@ -63,21 +63,21 @@ public:
     // Runs one pending operation (to wait for completion in the sync-mode).
     virtual bool waitForOperationToComplete();
 
-    virtual void move(const String& sourcePath, const String& destinationPath, PassOwnPtr<AsyncFileSystemCallbacks>);
-    virtual void copy(const String& sourcePath, const String& destinationPath, PassOwnPtr<AsyncFileSystemCallbacks>);
-    virtual void remove(const String& path, PassOwnPtr<AsyncFileSystemCallbacks>);
-    virtual void removeRecursively(const String& path, PassOwnPtr<AsyncFileSystemCallbacks>);
-    virtual void readMetadata(const String& path, PassOwnPtr<AsyncFileSystemCallbacks>);
-    virtual void createFile(const String& path, bool exclusive, PassOwnPtr<AsyncFileSystemCallbacks>);
-    virtual void createDirectory(const String& path, bool exclusive, PassOwnPtr<AsyncFileSystemCallbacks>);
-    virtual void fileExists(const String& path, PassOwnPtr<AsyncFileSystemCallbacks>);
-    virtual void directoryExists(const String& path, PassOwnPtr<AsyncFileSystemCallbacks>);
-    virtual void readDirectory(const String& path, PassOwnPtr<AsyncFileSystemCallbacks>);
-    virtual void createWriter(AsyncFileWriterClient* client, const String& path, PassOwnPtr<AsyncFileSystemCallbacks>);
-    virtual void createSnapshotFileAndReadMetadata(const String& path, PassOwnPtr<AsyncFileSystemCallbacks>);
+    virtual void move(const KURL& sourcePath, const KURL& destinationPath, PassOwnPtr<AsyncFileSystemCallbacks>);
+    virtual void copy(const KURL& sourcePath, const KURL& destinationPath, PassOwnPtr<AsyncFileSystemCallbacks>);
+    virtual void remove(const KURL& path, PassOwnPtr<AsyncFileSystemCallbacks>);
+    virtual void removeRecursively(const KURL& path, PassOwnPtr<AsyncFileSystemCallbacks>);
+    virtual void readMetadata(const KURL& path, PassOwnPtr<AsyncFileSystemCallbacks>);
+    virtual void createFile(const KURL& path, bool exclusive, PassOwnPtr<AsyncFileSystemCallbacks>);
+    virtual void createDirectory(const KURL& path, bool exclusive, PassOwnPtr<AsyncFileSystemCallbacks>);
+    virtual void fileExists(const KURL& path, PassOwnPtr<AsyncFileSystemCallbacks>);
+    virtual void directoryExists(const KURL& path, PassOwnPtr<AsyncFileSystemCallbacks>);
+    virtual void readDirectory(const KURL& path, PassOwnPtr<AsyncFileSystemCallbacks>);
+    virtual void createWriter(AsyncFileWriterClient*, const KURL& path, PassOwnPtr<AsyncFileSystemCallbacks>);
+    virtual void createSnapshotFileAndReadMetadata(const KURL& path, PassOwnPtr<AsyncFileSystemCallbacks>);
 
 private:
-    WorkerAsyncFileSystemChromium(ScriptExecutionContext*, FileSystemType, const WebKit::WebURL& rootURL, FileSystemSynchronousType);
+    WorkerAsyncFileSystemChromium(ScriptExecutionContext*, FileSystemSynchronousType);
 
     PassRefPtr<WebKit::WorkerFileSystemCallbacksBridge> createWorkerFileSystemCallbacksBridge(PassOwnPtr<AsyncFileSystemCallbacks>);