[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc

kinuko at chromium.org kinuko at chromium.org
Wed Dec 22 14:28:36 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit b107ea23b68d99a8a826858cf8144f421d6a15d6
Author: kinuko at chromium.org <kinuko at chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Mon Oct 11 11:21:28 2010 +0000

    2010-10-11  Kinuko Yasuda  <kinuko at 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 at 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 at 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

diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index f884027..3440ed5 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,23 @@
+2010-10-11  Kinuko Yasuda  <kinuko at 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 at chromium.org>
 
         [Chromium] Unreviewed, build fix.
diff --git a/LayoutTests/fast/filesystem/op-remove-expected.txt b/LayoutTests/fast/filesystem/op-remove-expected.txt
index d362e2e..9368933 100644
--- a/LayoutTests/fast/filesystem/op-remove-expected.txt
+++ b/LayoutTests/fast/filesystem/op-remove-expected.txt
@@ -1,6 +1,7 @@
 * 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
 
diff --git a/LayoutTests/fast/filesystem/resources/async-operations.js b/LayoutTests/fast/filesystem/resources/async-operations.js
index 5c484fc..d3c915a 100644
--- a/LayoutTests/fast/filesystem/resources/async-operations.js
+++ b/LayoutTests/fast/filesystem/resources/async-operations.js
@@ -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);
diff --git a/LayoutTests/fast/filesystem/resources/fs-test-util.js b/LayoutTests/fast/filesystem/resources/fs-test-util.js
index 98768ce..7d8e6f4 100644
--- a/LayoutTests/fast/filesystem/resources/fs-test-util.js
+++ b/LayoutTests/fast/filesystem/resources/fs-test-util.js
@@ -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);
 }
diff --git a/LayoutTests/fast/filesystem/resources/fs-worker-common.js b/LayoutTests/fast/filesystem/resources/fs-worker-common.js
index ea9a194..aacdda2 100644
--- a/LayoutTests/fast/filesystem/resources/fs-worker-common.js
+++ b/LayoutTests/fast/filesystem/resources/fs-worker-common.js
@@ -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) {
diff --git a/LayoutTests/fast/filesystem/resources/op-remove.js b/LayoutTests/fast/filesystem/resources/op-remove.js
index 119ac82..bd168d6 100644
--- a/LayoutTests/fast/filesystem/resources/op-remove.js
+++ b/LayoutTests/fast/filesystem/resources/op-remove.js
@@ -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},
+        ],
+    },
 ];
 
diff --git a/LayoutTests/fast/filesystem/resources/op-tests-helper.js b/LayoutTests/fast/filesystem/resources/op-tests-helper.js
index bfb0729..50501ee 100644
--- a/LayoutTests/fast/filesystem/resources/op-tests-helper.js
+++ b/LayoutTests/fast/filesystem/resources/op-tests-helper.js
@@ -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()
diff --git a/LayoutTests/fast/filesystem/resources/sync-operations.js b/LayoutTests/fast/filesystem/resources/sync-operations.js
index e5963d6..57ae646 100644
--- a/LayoutTests/fast/filesystem/resources/sync-operations.js
+++ b/LayoutTests/fast/filesystem/resources/sync-operations.js
@@ -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;
diff --git a/LayoutTests/fast/filesystem/script-tests/file-from-file-entry.js b/LayoutTests/fast/filesystem/script-tests/file-from-file-entry.js
index 7552778..d7f86e6 100644
--- a/LayoutTests/fast/filesystem/script-tests/file-from-file-entry.js
+++ b/LayoutTests/fast/filesystem/script-tests/file-from-file-entry.js
@@ -29,7 +29,7 @@ function createTestFile() {
 
 function fileSystemCallback(fs) {
     fileSystem = fs;
-    removeRecursively(fileSystem.root, createTestFile, errorCallback);
+    removeAllInDirectory(fileSystem.root, createTestFile, errorCallback);
 }
 
 if (window.requestFileSystem) {
diff --git a/LayoutTests/fast/filesystem/script-tests/read-directory.js b/LayoutTests/fast/filesystem/script-tests/read-directory.js
index 3b4857f..2ffb264 100644
--- a/LayoutTests/fast/filesystem/script-tests/read-directory.js
+++ b/LayoutTests/fast/filesystem/script-tests/read-directory.js
@@ -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) {
diff --git a/LayoutTests/platform/chromium-linux/fast/filesystem/async-operations-expected.txt b/LayoutTests/platform/chromium-linux/fast/filesystem/async-operations-expected.txt
index 566401d..8fd9ead 100644
--- a/LayoutTests/platform/chromium-linux/fast/filesystem/async-operations-expected.txt
+++ b/LayoutTests/platform/chromium-linux/fast/filesystem/async-operations-expected.txt
@@ -13,3 +13,4 @@ PASS dirsCount is 3
 PASS successfullyParsed is true
 
 TEST COMPLETE
+
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 441e9b0..1450a21 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,27 @@
+2010-10-11  Kinuko Yasuda  <kinuko at 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 at webkit.org>
 
         Reviewed by Nikolas Zimmermann.
diff --git a/WebCore/fileapi/DOMFileSystemBase.cpp b/WebCore/fileapi/DOMFileSystemBase.cpp
index d4dd7a5..fefe99f 100644
--- a/WebCore/fileapi/DOMFileSystemBase.cpp
+++ b/WebCore/fileapi/DOMFileSystemBase.cpp
@@ -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);
diff --git a/WebCore/fileapi/DOMFileSystemBase.h b/WebCore/fileapi/DOMFileSystemBase.h
index ee8f8e5..36e35b4 100644
--- a/WebCore/fileapi/DOMFileSystemBase.h
+++ b/WebCore/fileapi/DOMFileSystemBase.h
@@ -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>);
diff --git a/WebCore/fileapi/DirectoryEntry.cpp b/WebCore/fileapi/DirectoryEntry.cpp
index ebeb95a..765fcd5 100644
--- a/WebCore/fileapi/DirectoryEntry.cpp
+++ b/WebCore/fileapi/DirectoryEntry.cpp
@@ -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)
diff --git a/WebCore/fileapi/DirectoryEntry.h b/WebCore/fileapi/DirectoryEntry.h
index 69a52ab..dd0159e 100644
--- a/WebCore/fileapi/DirectoryEntry.h
+++ b/WebCore/fileapi/DirectoryEntry.h
@@ -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);
diff --git a/WebCore/fileapi/DirectoryEntry.idl b/WebCore/fileapi/DirectoryEntry.idl
index 2880ed0..0e38153 100644
--- a/WebCore/fileapi/DirectoryEntry.idl
+++ b/WebCore/fileapi/DirectoryEntry.idl
@@ -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);
     };
 }
diff --git a/WebCore/fileapi/DirectoryEntrySync.cpp b/WebCore/fileapi/DirectoryEntrySync.cpp
index b228db5..d8d22c2 100644
--- a/WebCore/fileapi/DirectoryEntrySync.cpp
+++ b/WebCore/fileapi/DirectoryEntrySync.cpp
@@ -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)
diff --git a/WebCore/fileapi/DirectoryEntrySync.h b/WebCore/fileapi/DirectoryEntrySync.h
index 1d7fb9f..9a3e0df 100644
--- a/WebCore/fileapi/DirectoryEntrySync.h
+++ b/WebCore/fileapi/DirectoryEntrySync.h
@@ -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;
diff --git a/WebCore/fileapi/DirectoryEntrySync.idl b/WebCore/fileapi/DirectoryEntrySync.idl
index cc796bf..268b2a9 100644
--- a/WebCore/fileapi/DirectoryEntrySync.idl
+++ b/WebCore/fileapi/DirectoryEntrySync.idl
@@ -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);
     };
 }
diff --git a/WebCore/fileapi/Entry.h b/WebCore/fileapi/Entry.h
index 1b33f37..36f85eb 100644
--- a/WebCore/fileapi/Entry.h
+++ b/WebCore/fileapi/Entry.h
@@ -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);
diff --git a/WebCore/fileapi/EntrySync.cpp b/WebCore/fileapi/EntrySync.cpp
index b888613..ad007db 100644
--- a/WebCore/fileapi/EntrySync.cpp
+++ b/WebCore/fileapi/EntrySync.cpp
@@ -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);
 }
 
diff --git a/WebCore/fileapi/EntrySync.h b/WebCore/fileapi/EntrySync.h
index 618f12c..24a0101 100644
--- a/WebCore/fileapi/EntrySync.h
+++ b/WebCore/fileapi/EntrySync.h
@@ -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);
diff --git a/WebCore/platform/AsyncFileSystem.h b/WebCore/platform/AsyncFileSystem.h
index 27c6240..3104ebc 100644
--- a/WebCore/platform/AsyncFileSystem.h
+++ b/WebCore/platform/AsyncFileSystem.h
@@ -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.
diff --git a/WebKit/chromium/ChangeLog b/WebKit/chromium/ChangeLog
index e04fffd..86081ed 100644
--- a/WebKit/chromium/ChangeLog
+++ b/WebKit/chromium/ChangeLog
@@ -1,3 +1,21 @@
+2010-10-11  Kinuko Yasuda  <kinuko at 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 at chromium.org>
 
         Reviewed by Darin Fisher.
diff --git a/WebKit/chromium/src/AsyncFileSystemChromium.cpp b/WebKit/chromium/src/AsyncFileSystemChromium.cpp
index 59e6484..5975e72 100644
--- a/WebKit/chromium/src/AsyncFileSystemChromium.cpp
+++ b/WebKit/chromium/src/AsyncFileSystemChromium.cpp
@@ -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));
diff --git a/WebKit/chromium/src/AsyncFileSystemChromium.h b/WebKit/chromium/src/AsyncFileSystemChromium.h
index 91b1d9c..6205609 100644
--- a/WebKit/chromium/src/AsyncFileSystemChromium.h
+++ b/WebKit/chromium/src/AsyncFileSystemChromium.h
@@ -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>);
diff --git a/WebKit/chromium/src/WorkerAsyncFileSystemChromium.cpp b/WebKit/chromium/src/WorkerAsyncFileSystemChromium.cpp
index 6c2d4ae..1e70619 100644
--- a/WebKit/chromium/src/WorkerAsyncFileSystemChromium.cpp
+++ b/WebKit/chromium/src/WorkerAsyncFileSystemChromium.cpp
@@ -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);
diff --git a/WebKit/chromium/src/WorkerAsyncFileSystemChromium.h b/WebKit/chromium/src/WorkerAsyncFileSystemChromium.h
index 5fc7646..0b4b708 100644
--- a/WebKit/chromium/src/WorkerAsyncFileSystemChromium.h
+++ b/WebKit/chromium/src/WorkerAsyncFileSystemChromium.h
@@ -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>);
+    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>);
diff --git a/WebKit/chromium/src/WorkerFileSystemCallbacksBridge.cpp b/WebKit/chromium/src/WorkerFileSystemCallbacksBridge.cpp
index 901f137..6c31221 100644
--- a/WebKit/chromium/src/WorkerFileSystemCallbacksBridge.cpp
+++ b/WebKit/chromium/src/WorkerFileSystemCallbacksBridge.cpp
@@ -171,6 +171,12 @@ void WorkerFileSystemCallbacksBridge::postRemoveToMainThread(WebFileSystem* file
     dispatchTaskToMainThread(createCallbackTask(&removeOnMainThread, fileSystem, path, this, mode));
 }
 
+void WorkerFileSystemCallbacksBridge::postRemoveRecursivelyToMainThread(WebFileSystem* fileSystem, const String& path, const String& mode)
+{
+    ASSERT(fileSystem);
+    dispatchTaskToMainThread(createCallbackTask(&removeRecursivelyOnMainThread, fileSystem, path, this, mode));
+}
+
 void WorkerFileSystemCallbacksBridge::postReadMetadataToMainThread(WebFileSystem* fileSystem, const String& path, const String& mode)
 {
     ASSERT(fileSystem);
@@ -230,6 +236,11 @@ void WorkerFileSystemCallbacksBridge::removeOnMainThread(WebCore::ScriptExecutio
     fileSystem->remove(path, MainThreadFileSystemCallbacks::createLeakedPtr(bridge, mode));
 }
 
+void WorkerFileSystemCallbacksBridge::removeRecursivelyOnMainThread(WebCore::ScriptExecutionContext*, WebFileSystem* fileSystem, const String& path, WorkerFileSystemCallbacksBridge* bridge, const String& mode)
+{
+    fileSystem->removeRecursively(path, MainThreadFileSystemCallbacks::createLeakedPtr(bridge, mode));
+}
+
 void WorkerFileSystemCallbacksBridge::readMetadataOnMainThread(WebCore::ScriptExecutionContext*, WebFileSystem* fileSystem, const String& path, WorkerFileSystemCallbacksBridge* bridge, const String& mode)
 {
     fileSystem->readMetadata(path, MainThreadFileSystemCallbacks::createLeakedPtr(bridge, mode));
diff --git a/WebKit/chromium/src/WorkerFileSystemCallbacksBridge.h b/WebKit/chromium/src/WorkerFileSystemCallbacksBridge.h
index f692559..fa57f38 100644
--- a/WebKit/chromium/src/WorkerFileSystemCallbacksBridge.h
+++ b/WebKit/chromium/src/WorkerFileSystemCallbacksBridge.h
@@ -88,6 +88,7 @@ public:
     void postMoveToMainThread(WebFileSystem*, const String& srcPath, const String& destPath, const String& mode);
     void postCopyToMainThread(WebFileSystem*, const String& srcPath, const String& destPath, const String& mode);
     void postRemoveToMainThread(WebFileSystem*, const String& path, const String& mode);
+    void postRemoveRecursivelyToMainThread(WebFileSystem*, const String& path, const String& mode);
     void postReadMetadataToMainThread(WebFileSystem*, const String& path, const String& mode);
     void postCreateFileToMainThread(WebFileSystem*, const String& path, bool exclusive, const String& mode);
     void postCreateDirectoryToMainThread(WebFileSystem*, const String& path, bool exclusive, const String& mode);
@@ -110,6 +111,7 @@ private:
     static void moveOnMainThread(WebCore::ScriptExecutionContext*, WebFileSystem*, const String& srcPath, const String& destPath, WorkerFileSystemCallbacksBridge*, const String& mode);
     static void copyOnMainThread(WebCore::ScriptExecutionContext*, WebFileSystem*, const String& srcPath, const String& destPath, WorkerFileSystemCallbacksBridge*, const String& mode);
     static void removeOnMainThread(WebCore::ScriptExecutionContext*, WebFileSystem*, const String& path, WorkerFileSystemCallbacksBridge*, const String& mode);
+    static void removeRecursivelyOnMainThread(WebCore::ScriptExecutionContext*, WebFileSystem*, const String& path, WorkerFileSystemCallbacksBridge*, const String& mode);
     static void readMetadataOnMainThread(WebCore::ScriptExecutionContext*, WebFileSystem*, const String& path, WorkerFileSystemCallbacksBridge*, const String& mode);
     static void createFileOnMainThread(WebCore::ScriptExecutionContext*, WebFileSystem*, const String& path, bool exclusive, WorkerFileSystemCallbacksBridge*, const String& mode);
     static void createDirectoryOnMainThread(WebCore::ScriptExecutionContext*, WebFileSystem*, const String& path, bool exclusive, WorkerFileSystemCallbacksBridge*, const String& mode);

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list