Commit b107ea23 authored by kinuko@chromium.org's avatar kinuko@chromium.org

2010-10-11 Kinuko Yasuda <kinuko@google.com>

        Reviewed by David Levin.

        Support DirectoryEntry.removeRecursively for FileSystem API
        https://bugs.webkit.org/show_bug.cgi?id=47400

        * src/AsyncFileSystemChromium.cpp:
        (WebCore::AsyncFileSystemChromium::removeRecursively): Added.
        * src/AsyncFileSystemChromium.h:
        * src/WorkerAsyncFileSystemChromium.cpp:
        (WebCore::WorkerAsyncFileSystemChromium::removeRecursively): Added.
        * src/WorkerAsyncFileSystemChromium.h:
        * src/WorkerFileSystemCallbacksBridge.cpp:
        (WebKit::WorkerFileSystemCallbacksBridge::postRemoveRecursivelyToMainThread): Added.
        (WebKit::WorkerFileSystemCallbacksBridge::removeRecursivelyOnMainThread): Added.
        * src/WorkerFileSystemCallbacksBridge.h:
2010-10-11  Kinuko Yasuda  <kinuko@chromium.org>

        Reviewed by David Levin.

        Support DirectoryEntry.removeRecursively for FileSystem API
        https://bugs.webkit.org/show_bug.cgi?id=47400

        Also disallows remove/removeRecursively on the root directory.

        Test: fast/filesystem/op-remove.html

        * fileapi/DOMFileSystemBase.cpp:
        (WebCore::DOMFileSystemBase::removeRecursively): Added.
        * fileapi/DOMFileSystemBase.h:
        * fileapi/DirectoryEntry.cpp:
        (WebCore::DirectoryEntry::removeRecursively): Added.
        * fileapi/DirectoryEntry.h:
        * fileapi/DirectoryEntry.idl:
        * fileapi/DirectoryEntrySync.cpp:
        (WebCore::DirectoryEntrySync::removeRecursively): Added.
        * fileapi/DirectoryEntrySync.h:
        * fileapi/DirectoryEntrySync.idl:
        * platform/AsyncFileSystem.h:
2010-10-11  Kinuko Yasuda  <kinuko@chromium.org>

        Reviewed by David Levin.

        Support DirectoryEntry.removeRecursively for FileSystem API
        https://bugs.webkit.org/show_bug.cgi?id=47400

        * fast/filesystem/resources/async-operations.js:
        * fast/filesystem/resources/fs-test-util.js:
        (removeAllInDirectory): renamed from removeRecursively and changed
        the implemntation to use DirectoryEntry.removeRecursively.
        * fast/filesystem/resources/fs-worker-common.js:
        (removeAllInDirectorySync): ditto.
        * fast/filesystem/resources/op-remove.js: Added removeRecursively test.
        * fast/filesystem/resources/op-tests-helper.js:
        (runOperationTest.OperationTestHelper.this.removeRecursively): Added.
        * fast/filesystem/resources/sync-operations.js:
        * fast/filesystem/script-tests/file-from-file-entry.js:
        * fast/filesystem/script-tests/read-directory.js:


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@69485 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 7f0c03ee
2010-10-11 Kinuko Yasuda <kinuko@chromium.org>
Reviewed by David Levin.
Support DirectoryEntry.removeRecursively for FileSystem API
https://bugs.webkit.org/show_bug.cgi?id=47400
* fast/filesystem/resources/async-operations.js:
* fast/filesystem/resources/fs-test-util.js:
(removeAllInDirectory): renamed from removeRecursively and changed
the implemntation to use DirectoryEntry.removeRecursively.
* fast/filesystem/resources/fs-worker-common.js:
(removeAllInDirectorySync): ditto.
* fast/filesystem/resources/op-remove.js: Added removeRecursively test.
* fast/filesystem/resources/op-tests-helper.js:
(runOperationTest.OperationTestHelper.this.removeRecursively): Added.
* fast/filesystem/resources/sync-operations.js:
* fast/filesystem/script-tests/file-from-file-entry.js:
* fast/filesystem/script-tests/read-directory.js:
2010-10-11 Alexander Pavlov <apavlov@chromium.org>
[Chromium] Unreviewed, build fix.
* Running: RemoveSimple
PASS Succeeded: "/a".remove()
PASS Succeeded: "/b".remove()
PASS this.expectedErrorCode + "" is "13"
PASS Verified entry does NOT exist: /a
PASS Verified entry does NOT exist: /b
* Running: RemoveNonRecursiveWithChildren
......@@ -8,6 +9,13 @@ PASS this.expectedErrorCode + "" is "13"
PASS Verified entry: ENTRY {path:/a name:a type:DIRECTORY}
PASS Verified entry: ENTRY {path:/a/b name:b type:DIRECTORY}
PASS Verified entry: ENTRY {path:/a/c name:c type:FILE}
* Running: RemoveRecursiveWithoutChildren
PASS Succeeded: "/a".removeRecursively()
PASS Verified entry does NOT exist: /a
* Running: RemoveRecursiveWithChildren
PASS Succeeded: "/a".removeRecursively()
PASS this.expectedErrorCode + "" is "13"
PASS Verified entry does NOT exist: /a
Finished running tests.
PASS successfullyParsed is true
......
......@@ -18,7 +18,7 @@ var reader = null;
function errorCallback(error) {
debug("Got error: " + error.code);
removeRecursively(fileSystem.root);
removeAllInDirectory(fileSystem.root);
finishJSTest();
}
......@@ -34,7 +34,7 @@ function entriesCallback(entries) {
paths.sort();
shouldBe('"' + paths.join(',') + '"', '"/a,/b,/c,/d2,/e,/f"');
shouldBe("dirsCount", "3");
removeRecursively(fileSystem.root);
removeAllInDirectory(fileSystem.root);
finishJSTest();
}
}
......@@ -97,7 +97,7 @@ if (this.requestFileSystem) {
requestFileSystem.apply(this, [this.TEMPORARY, 100, function(fs) {
debug("Got FileSystem:" + fs.name);
fileSystem = fs;
removeRecursively(fileSystem.root, function(){ helper.done(); }, errorCallback);
removeAllInDirectory(fileSystem.root, function(){ helper.done(); }, errorCallback);
}, errorCallback]); });
debug("requested FileSystem.");
helper.join(asyncTest1);
......
......@@ -46,82 +46,43 @@ var JoinHelper = function()
};
};
// FIXME: replace this code with the equivalent File API method once it fully supports removeRecursively.
function removeRecursively(directory, successCallback, errorCallback) {
var RemoveRecursiveHelper = function(successCallback, errorCallback) {
this.removeDirMap = {};
// Remove everything in the given directory.
function removeAllInDirectory(directory, successCallback, errorCallback) {
var RemoveAllInDirectoryHelper = function(successCallback, errorCallback) {
this.entriesCount = 0;
this.reader = null;
this.successCallback = successCallback;
this.errorCallback = errorCallback;
this.removeRecursively = function(directory)
this.entryRemovedCallback = bindCallback(this, function(entry)
{
this.removeRecursivelyInternal(directory);
};
this.hasMoreEntries = function(hash)
{
for (k in hash)
return true;
return false;
};
this.removeDirectory = function(directory, parentDirectory)
{
if (directory.fullPath != '/') {
// Ok to remove the parent directory.
directory.remove(bindCallback(this, this.entryRemovedCallback, parentDirectory, directory), bindCallback(this, this.ErrorCallback));
} else
delete this.removeDirMap[directory.fullPath];
if (!this.hasMoreEntries(this.removeDirMap) && this.successCallback)
if (--this.entriesCount == 0 && this.successCallback)
this.successCallback();
};
});
this.entryRemovedCallback = function(directory, entry)
{
if (entry.isDirectory)
delete this.removeDirMap[entry.fullPath];
if (directory) {
var dirInfo = this.removeDirMap[directory.fullPath];
if (--dirInfo.entries == 0 && dirInfo.hasMore == false)
this.removeDirectory(directory, dirInfo.parentDirectory);
}
};
this.removeRecursivelyCallback = function(entries, directory)
this.entriesCallback = bindCallback(this, function(entries)
{
for (var i = 0; i < entries.length; ++i) {
this.removeDirMap[directory.fullPath].entries++;
this.entriesCount++;
if (entries[i].isDirectory)
this.removeRecursivelyInternal(entries[i], directory);
entries[i].removeRecursively(this.entryRemovedCallback, this.errorCallback);
else {
var entry = entries[i];
entry.remove(bindCallback(this, this.entryRemovedCallback, directory, entry), bindCallback(this, this.errorCallback));
entries[i].remove(this.entryRemovedCallback, this.errorCallback);
}
}
if (entries.length) {
this.removeDirMap[directory.fullPath].reader.readEntries(bindCallback(this, this.removeRecursivelyCallback, directory), bindCallback(this, this.errorCallback));
} else {
var dirInfo = this.removeDirMap[directory.fullPath];
dirInfo.hasMore = false;
if (dirInfo.entries == 0)
this.removeDirectory(directory, dirInfo.parentDirectory);
}
};
if (entries.length)
this.reader.readEntries(this.entriesCallback, this.errorCallback);
else if (this.entriesCount == 0 && this.successCallback)
this.successCallback();
});
this.removeRecursivelyInternal = function(directory, parentDirectory)
this.removeAllInDirectory = function(directory)
{
directoryReader = directory.createReader();
this.removeDirMap[directory.fullPath] = {
hasMore: true,
parentDirectory: parentDirectory,
entries: 0,
reader: directoryReader,
};
directoryReader.readEntries(bindCallback(this, this.removeRecursivelyCallback, directory), bindCallback(this, this.errorCallback));
this.reader = directory.createReader();
this.reader.readEntries(this.entriesCallback, this.errorCallback);
};
};
var helper = new RemoveRecursiveHelper(successCallback, errorCallback);
helper.removeRecursively(directory);
var helper = new RemoveAllInDirectoryHelper(successCallback, errorCallback);
helper.removeAllInDirectory(directory);
}
......@@ -27,7 +27,7 @@ function shouldBe(_a, _b)
function shouldBeTrue(_a) { shouldBe(_a, "true"); }
function removeRecursivelySync(directory) {
function removeAllInDirectorySync(directory) {
if (!directory)
return;
var reader = directory.createReader();
......@@ -35,13 +35,11 @@ function removeRecursivelySync(directory) {
var entries = reader.readEntries();
for (var i = 0; i < entries.length; ++i) {
if (entries[i].isDirectory)
removeRecursivelySync(entries[i]);
entries[i].removeRecursively();
else
entries[i].remove();
}
} while (entries.length);
if (directory.fullPath != '/')
directory.remove();
}
if (this.importScripts && !this.requestFileSystem) {
......
......@@ -7,7 +7,8 @@ var testCases = [
],
tests: [
function(helper) { helper.remove('/a'); },
function(helper) { helper.remove('/b'); }
function(helper) { helper.remove('/b'); },
function(helper) { helper.remove('/', FileError.INVALID_MODIFICATION_ERR); }
],
postcondition: [
{fullPath:'/a', nonexistent:true},
......@@ -30,5 +31,32 @@ var testCases = [
{fullPath:'/a/c',}
],
},
{
name: 'RemoveRecursiveWithoutChildren',
precondition: [
{fullPath:'/a', isDirectory:true},
],
tests: [
function(helper) { helper.removeRecursively('/a'); }
],
postcondition: [
{fullPath:'/a', nonexistent:true},
],
},
{
name: 'RemoveRecursiveWithChildren',
precondition: [
{fullPath:'/a', isDirectory:true},
{fullPath:'/a/b', isDirectory:true},
{fullPath:'/a/c',}
],
tests: [
function(helper) { helper.removeRecursively('/a'); },
function(helper) { helper.removeRecursively('/', FileError.INVALID_MODIFICATION_ERR); }
],
postcondition: [
{fullPath:'/a', nonexistent:true},
],
},
];
......@@ -263,6 +263,13 @@ function runOperationTest(fileSystem, testCase, successCallback, errorCallback)
this.environment[entry].remove(bindCallback(this, this.testSuccessCallback), bindCallback(this, this.testErrorCallback));
};
this.removeRecursively = function(entry, expectedErrorCode)
{
this.expectedErrorCode = expectedErrorCode;
this.stage = '"' + entry + '".removeRecursively()';
this.environment[entry].removeRecursively(bindCallback(this, this.testSuccessCallback), bindCallback(this, this.testErrorCallback));
};
this.readDirectory = function(entry, expectedErrorCode)
{
this.expectedErrorCode = expectedErrorCode;
......@@ -291,7 +298,7 @@ function runOperationTest(fileSystem, testCase, successCallback, errorCallback)
{
this.expectedErrorCode = '';
this.stage = 'resetting filesystem';
removeRecursively(this.fileSystem.root, bindCallback(this, this.setUp), bindCallback(this, this.testErrorCallback));
removeAllInDirectory(this.fileSystem.root, bindCallback(this, this.setUp), bindCallback(this, this.testErrorCallback));
};
this.setUp = function()
......
......@@ -6,7 +6,7 @@ if (this.importScripts) {
description("Test making multiple synchronous FileSystem operations.");
var fileSystem = requestFileSystemSync(this.TEMPORARY, 100);
removeRecursivelySync(fileSystem.root);
removeAllInDirectorySync(fileSystem.root);
// Stage 1 (prepare)
var a = fileSystem.root.getFile('a', {create:true});
......@@ -38,7 +38,7 @@ do {
paths.sort();
shouldBe('"' + paths.join(',') + '"', '"/a,/b,/c,/d2,/e,/f"');
shouldBe("dirsCount", "3");
removeRecursivelySync(fileSystem.root);
removeAllInDirectorySync(fileSystem.root);
finishJSTest();
var successfullyParsed = true;
......@@ -29,7 +29,7 @@ function createTestFile() {
function fileSystemCallback(fs) {
fileSystem = fs;
removeRecursively(fileSystem.root, createTestFile, errorCallback);
removeAllInDirectory(fileSystem.root, createTestFile, errorCallback);
}
if (window.requestFileSystem) {
......
......@@ -19,7 +19,7 @@ var testEntriesCount = 0;
function endTest()
{
removeRecursively(fileSystem.root);
removeAllInDirectory(fileSystem.root);
finishJSTest();
}
......@@ -85,7 +85,7 @@ function successCallback(fs)
{
fileSystem = fs;
debug("Successfully obtained Persistent FileSystem:" + fileSystem.name);
removeRecursively(fileSystem.root, prepareForTest, errorCallback);
removeAllInDirectory(fileSystem.root, prepareForTest, errorCallback);
}
if (window.requestFileSystem) {
......
......@@ -13,3 +13,4 @@ PASS dirsCount is 3
PASS successfullyParsed is true
TEST COMPLETE
2010-10-11 Kinuko Yasuda <kinuko@chromium.org>
Reviewed by David Levin.
Support DirectoryEntry.removeRecursively for FileSystem API
https://bugs.webkit.org/show_bug.cgi?id=47400
Also disallows remove/removeRecursively on the root directory.
Test: fast/filesystem/op-remove.html
* fileapi/DOMFileSystemBase.cpp:
(WebCore::DOMFileSystemBase::removeRecursively): Added.
* fileapi/DOMFileSystemBase.h:
* fileapi/DirectoryEntry.cpp:
(WebCore::DirectoryEntry::removeRecursively): Added.
* fileapi/DirectoryEntry.h:
* fileapi/DirectoryEntry.idl:
* fileapi/DirectoryEntrySync.cpp:
(WebCore::DirectoryEntrySync::removeRecursively): Added.
* fileapi/DirectoryEntrySync.h:
* fileapi/DirectoryEntrySync.idl:
* platform/AsyncFileSystem.h:
2010-10-11 Dirk Schulze <krit@webkit.org>
Reviewed by Nikolas Zimmermann.
......@@ -132,11 +132,25 @@ bool DOMFileSystemBase::copy(const EntryBase* source, EntryBase* parent, const S
bool DOMFileSystemBase::remove(const EntryBase* entry, PassRefPtr<VoidCallback> successCallback, PassRefPtr<ErrorCallback> errorCallback)
{
ASSERT(entry);
// We don't allow calling remove() on the root directory.
if (entry->fullPath() == String(DOMFilePath::root))
return false;
String platformPath = m_asyncFileSystem->virtualToPlatformPath(entry->fullPath());
m_asyncFileSystem->remove(platformPath, VoidCallbacks::create(successCallback, errorCallback));
return true;
}
bool DOMFileSystemBase::removeRecursively(const EntryBase* entry, PassRefPtr<VoidCallback> successCallback, PassRefPtr<ErrorCallback> errorCallback)
{
ASSERT(entry && entry->isDirectory());
// We don't allow calling remove() on the root directory.
if (entry->fullPath() == String(DOMFilePath::root))
return false;
String platformPath = m_asyncFileSystem->virtualToPlatformPath(entry->fullPath());
m_asyncFileSystem->removeRecursively(platformPath, VoidCallbacks::create(successCallback, errorCallback));
return true;
}
bool DOMFileSystemBase::getParent(const EntryBase* entry, PassRefPtr<EntryCallback> successCallback, PassRefPtr<ErrorCallback> errorCallback)
{
ASSERT(entry);
......
......@@ -68,6 +68,7 @@ public:
bool move(const EntryBase* source, EntryBase* parent, const String& name, PassRefPtr<EntryCallback>, PassRefPtr<ErrorCallback>);
bool copy(const EntryBase* source, EntryBase* parent, const String& name, PassRefPtr<EntryCallback>, PassRefPtr<ErrorCallback>);
bool remove(const EntryBase*, PassRefPtr<VoidCallback>, PassRefPtr<ErrorCallback>);
bool removeRecursively(const EntryBase*, PassRefPtr<VoidCallback>, PassRefPtr<ErrorCallback>);
bool getParent(const EntryBase*, PassRefPtr<EntryCallback>, PassRefPtr<ErrorCallback>);
bool getFile(const EntryBase*, const String& path, PassRefPtr<Flags>, PassRefPtr<EntryCallback>, PassRefPtr<ErrorCallback>);
bool getDirectory(const EntryBase*, const String& path, PassRefPtr<Flags>, PassRefPtr<EntryCallback>, PassRefPtr<ErrorCallback>);
......
......@@ -37,6 +37,7 @@
#include "EntryCallback.h"
#include "ErrorCallback.h"
#include "FileError.h"
#include "VoidCallback.h"
namespace WebCore {
......@@ -64,6 +65,13 @@ void DirectoryEntry::getDirectory(const String& path, PassRefPtr<Flags> flags, P
filesystem()->scheduleCallback(errorCallback.release(), FileError::create(INVALID_MODIFICATION_ERR));
}
void DirectoryEntry::removeRecursively(PassRefPtr<VoidCallback> successCallback, PassRefPtr<ErrorCallback> errorCallbackRef) const
{
RefPtr<ErrorCallback> errorCallback(errorCallbackRef);
if (!m_fileSystem->removeRecursively(this, successCallback, errorCallback))
filesystem()->scheduleCallback(errorCallback.release(), FileError::create(INVALID_MODIFICATION_ERR));
}
}
#endif // ENABLE(FILE_SYSTEM)
......@@ -45,6 +45,7 @@ class DOMFileSystemBase;
class DirectoryReader;
class EntryCallback;
class ErrorCallback;
class VoidCallback;
class DirectoryEntry : public Entry {
public:
......@@ -57,6 +58,7 @@ public:
PassRefPtr<DirectoryReader> createReader();
void getFile(const String& path, PassRefPtr<Flags> = 0, PassRefPtr<EntryCallback> = 0, PassRefPtr<ErrorCallback> = 0);
void getDirectory(const String& path, PassRefPtr<Flags> = 0, PassRefPtr<EntryCallback> = 0, PassRefPtr<ErrorCallback> = 0);
void removeRecursively(PassRefPtr<VoidCallback> successCallback = 0, PassRefPtr<ErrorCallback> = 0) const;
private:
DirectoryEntry(DOMFileSystemBase*, const String& fullPath);
......
......@@ -38,5 +38,6 @@ module storage {
DirectoryReader createReader();
[Custom] void getFile(in [ConvertUndefinedOrNullToNullString] DOMString path, in [Optional] Flags flags, in [Optional, Callback] EntryCallback successCallback, in [Optional, Callback] ErrorCallback errorCallback);
[Custom] void getDirectory(in [ConvertUndefinedOrNullToNullString] DOMString path, in [Optional] Flags flags, in [Optional, Callback] EntryCallback successCallback, in [Optional, Callback] ErrorCallback errorCallback);
void removeRecursively(in [Optional, Callback] VoidCallback successCallback, in [Optional, Callback] ErrorCallback errorCallback);
};
}
......@@ -72,6 +72,17 @@ PassRefPtr<DirectoryEntrySync> DirectoryEntrySync::getDirectory(const String& pa
return static_pointer_cast<DirectoryEntrySync>(helper.getResult(ec));
}
void DirectoryEntrySync::removeRecursively(ExceptionCode& ec)
{
ec = 0;
VoidSyncCallbackHelper helper(m_fileSystem->asyncFileSystem());
if (!m_fileSystem->removeRecursively(this, helper.successCallback(), helper.errorCallback())) {
ec = INVALID_MODIFICATION_ERR;
return;
}
helper.getResult(ec);
}
}
#endif // ENABLE(FILE_SYSTEM)
......@@ -55,6 +55,7 @@ public:
PassRefPtr<DirectoryReaderSync> createReader(ExceptionCode&);
PassRefPtr<FileEntrySync> getFile(const String& path, PassRefPtr<Flags>, ExceptionCode&);
PassRefPtr<DirectoryEntrySync> getDirectory(const String& path, PassRefPtr<Flags>, ExceptionCode&);
void removeRecursively(ExceptionCode&);
private:
friend class EntrySync;
......
......@@ -38,5 +38,6 @@ module storage {
DirectoryReaderSync createReader() raises (FileException);
[Custom] FileEntrySync getFile(in [ConvertUndefinedOrNullToNullString] DOMString path, in Flags flags) raises (FileException);
[Custom] DirectoryEntrySync getDirectory(in [ConvertUndefinedOrNullToNullString] DOMString path, in Flags flags) raises (FileException);
void removeRecursively() raises (FileException);
};
}
......@@ -51,13 +51,13 @@ class Entry : public EntryBase {
public:
DOMFileSystem* filesystem() const { return static_cast<DOMFileSystem*>(m_fileSystem); }
virtual void getMetadata(PassRefPtr<MetadataCallback> successCallback = 0, PassRefPtr<ErrorCallback> errorCallback = 0);
virtual void moveTo(PassRefPtr<DirectoryEntry> parent, const String& name = String(), PassRefPtr<EntryCallback> successCallback = 0, PassRefPtr<ErrorCallback> errorCallback = 0) const;
virtual void copyTo(PassRefPtr<DirectoryEntry> parent, const String& name = String(), PassRefPtr<EntryCallback> successCallback = 0, PassRefPtr<ErrorCallback> errorCallback = 0) const;
virtual void remove(PassRefPtr<VoidCallback> successCallback = 0, PassRefPtr<ErrorCallback> errorCallback = 0) const;
virtual void getParent(PassRefPtr<EntryCallback> successCallback = 0, PassRefPtr<ErrorCallback> errorCallback = 0) const;
void getMetadata(PassRefPtr<MetadataCallback> successCallback = 0, PassRefPtr<ErrorCallback> errorCallback = 0);
void moveTo(PassRefPtr<DirectoryEntry> parent, const String& name = String(), PassRefPtr<EntryCallback> successCallback = 0, PassRefPtr<ErrorCallback> errorCallback = 0) const;
void copyTo(PassRefPtr<DirectoryEntry> parent, const String& name = String(), PassRefPtr<EntryCallback> successCallback = 0, PassRefPtr<ErrorCallback> errorCallback = 0) const;
void remove(PassRefPtr<VoidCallback> successCallback = 0, PassRefPtr<ErrorCallback> errorCallback = 0) const;
void getParent(PassRefPtr<EntryCallback> successCallback = 0, PassRefPtr<ErrorCallback> errorCallback = 0) const;
virtual String toURI(const String& mimeType = String());
String toURI(const String& mimeType = String());
protected:
Entry(DOMFileSystemBase*, const String& fullPath);
......
......@@ -87,8 +87,10 @@ void EntrySync::remove(ExceptionCode& ec) const
{
ec = 0;
VoidSyncCallbackHelper helper(m_fileSystem->asyncFileSystem());
if (!m_fileSystem->remove(this, helper.successCallback(), helper.errorCallback()))
if (!m_fileSystem->remove(this, helper.successCallback(), helper.errorCallback())) {
ec = INVALID_MODIFICATION_ERR;
return;
}
helper.getResult(ec);
}
......
......@@ -51,11 +51,11 @@ public:
DOMFileSystemSync* filesystem() const { return static_cast<DOMFileSystemSync*>(m_fileSystem); }
virtual PassRefPtr<Metadata> getMetadata(ExceptionCode&);
virtual PassRefPtr<EntrySync> moveTo(PassRefPtr<DirectoryEntrySync> parent, const String& name, ExceptionCode&) const;
virtual PassRefPtr<EntrySync> copyTo(PassRefPtr<DirectoryEntrySync> parent, const String& name, ExceptionCode&) const;
virtual void remove(ExceptionCode&) const;
virtual PassRefPtr<EntrySync> getParent() const;
PassRefPtr<Metadata> getMetadata(ExceptionCode&);
PassRefPtr<EntrySync> moveTo(PassRefPtr<DirectoryEntrySync> parent, const String& name, ExceptionCode&) const;
PassRefPtr<EntrySync> copyTo(PassRefPtr<DirectoryEntrySync> parent, const String& name, ExceptionCode&) const;
void remove(ExceptionCode&) const;
PassRefPtr<EntrySync> getParent() const;
protected:
EntrySync(DOMFileSystemBase*, const String& fullPath);
......
......@@ -80,10 +80,16 @@ public:
virtual void copy(const String& srcPath, const String& 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;
// 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;
// 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.
......
2010-10-11 Kinuko Yasuda <kinuko@google.com>
Reviewed by David Levin.
Support DirectoryEntry.removeRecursively for FileSystem API
https://bugs.webkit.org/show_bug.cgi?id=47400
* src/AsyncFileSystemChromium.cpp:
(WebCore::AsyncFileSystemChromium::removeRecursively): Added.
* src/AsyncFileSystemChromium.h:
* src/WorkerAsyncFileSystemChromium.cpp:
(WebCore::WorkerAsyncFileSystemChromium::removeRecursively): Added.
* src/WorkerAsyncFileSystemChromium.h:
* src/WorkerFileSystemCallbacksBridge.cpp:
(WebKit::WorkerFileSystemCallbacksBridge::postRemoveRecursivelyToMainThread): Added.
(WebKit::WorkerFileSystemCallbacksBridge::removeRecursivelyOnMainThread): Added.
* src/WorkerFileSystemCallbacksBridge.h:
2010-10-09 Varun Jain <varunjain@chromium.org>
Reviewed by Darin Fisher.
......
......@@ -76,6 +76,11 @@ void AsyncFileSystemChromium::remove(const String& path, PassOwnPtr<AsyncFileSys
m_webFileSystem->remove(path, new WebKit::WebFileSystemCallbacksImpl(callbacks));
}
void AsyncFileSystemChromium::removeRecursively(const String& path, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
{
m_webFileSystem->removeRecursively(path, new WebKit::WebFileSystemCallbacksImpl(callbacks));
}
void AsyncFileSystemChromium::readMetadata(const String& path, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
{
m_webFileSystem->readMetadata(path, new WebKit::WebFileSystemCallbacksImpl(callbacks));
......
......@@ -56,6 +56,7 @@ public:
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>);
......
......@@ -99,6 +99,11 @@ void WorkerAsyncFileSystemChromium::remove(const String& path, PassOwnPtr<AsyncF
createWorkerFileSystemCallbacksBridge(callbacks)->postRemoveToMainThread(m_webFileSystem, path, m_modeForCurrentOperation);
}
void WorkerAsyncFileSystemChromium::removeRecursively(const String& path, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
{
createWorkerFileSystemCallbacksBridge(callbacks)->postRemoveRecursivelyToMainThread(m_webFileSystem, path, m_modeForCurrentOperation);
}
void WorkerAsyncFileSystemChromium::readMetadata(const String& path, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
{
createWorkerFileSystemCallbacksBridge(callbacks)->postReadMetadataToMainThread(m_webFileSystem, path, m_modeForCurrentOperation);
......
......@@ -65,6 +65,7 @@ public:
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>);