Changeset 69485 in webkit


Ignore:
Timestamp:
Oct 11, 2010 4:21:28 AM (14 years ago)
Author:
kinuko@chromium.org
Message:

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:
Location:
trunk
Files:
31 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r69484 r69485  
     12010-10-11  Kinuko Yasuda  <kinuko@chromium.org>
     2
     3        Reviewed by David Levin.
     4
     5        Support DirectoryEntry.removeRecursively for FileSystem API
     6        https://bugs.webkit.org/show_bug.cgi?id=47400
     7
     8        * fast/filesystem/resources/async-operations.js:
     9        * fast/filesystem/resources/fs-test-util.js:
     10        (removeAllInDirectory): renamed from removeRecursively and changed
     11        the implemntation to use DirectoryEntry.removeRecursively.
     12        * fast/filesystem/resources/fs-worker-common.js:
     13        (removeAllInDirectorySync): ditto.
     14        * fast/filesystem/resources/op-remove.js: Added removeRecursively test.
     15        * fast/filesystem/resources/op-tests-helper.js:
     16        (runOperationTest.OperationTestHelper.this.removeRecursively): Added.
     17        * fast/filesystem/resources/sync-operations.js:
     18        * fast/filesystem/script-tests/file-from-file-entry.js:
     19        * fast/filesystem/script-tests/read-directory.js:
     20
    1212010-10-11  Alexander Pavlov  <apavlov@chromium.org>
    222
  • trunk/LayoutTests/fast/filesystem/op-remove-expected.txt

    r69339 r69485  
    22PASS Succeeded: "/a".remove()
    33PASS Succeeded: "/b".remove()
     4PASS this.expectedErrorCode + "" is "13"
    45PASS Verified entry does NOT exist: /a
    56PASS Verified entry does NOT exist: /b
     
    910PASS Verified entry: ENTRY {path:/a/b name:b type:DIRECTORY}
    1011PASS Verified entry: ENTRY {path:/a/c name:c type:FILE}
     12* Running: RemoveRecursiveWithoutChildren
     13PASS Succeeded: "/a".removeRecursively()
     14PASS Verified entry does NOT exist: /a
     15* Running: RemoveRecursiveWithChildren
     16PASS Succeeded: "/a".removeRecursively()
     17PASS this.expectedErrorCode + "" is "13"
     18PASS Verified entry does NOT exist: /a
    1119Finished running tests.
    1220PASS successfullyParsed is true
  • trunk/LayoutTests/fast/filesystem/resources/async-operations.js

    r69249 r69485  
    1919function errorCallback(error) {
    2020    debug("Got error: " + error.code);
    21     removeRecursively(fileSystem.root);
     21    removeAllInDirectory(fileSystem.root);
    2222    finishJSTest();
    2323}
     
    3535        shouldBe('"' + paths.join(',') + '"', '"/a,/b,/c,/d2,/e,/f"');
    3636        shouldBe("dirsCount", "3");
    37         removeRecursively(fileSystem.root);
     37        removeAllInDirectory(fileSystem.root);
    3838        finishJSTest();
    3939    }
     
    9898        debug("Got FileSystem:" + fs.name);
    9999        fileSystem = fs;
    100         removeRecursively(fileSystem.root, function(){ helper.done(); }, errorCallback);
     100        removeAllInDirectory(fileSystem.root, function(){ helper.done(); }, errorCallback);
    101101    }, errorCallback]); });
    102102    debug("requested FileSystem.");
  • trunk/LayoutTests/fast/filesystem/resources/fs-test-util.js

    r69249 r69485  
    4747};
    4848
    49 // FIXME: replace this code with the equivalent File API method once it fully supports removeRecursively.
    50 function removeRecursively(directory, successCallback, errorCallback) {
    51     var RemoveRecursiveHelper = function(successCallback, errorCallback) {
    52         this.removeDirMap = {};
     49// Remove everything in the given directory.
     50function removeAllInDirectory(directory, successCallback, errorCallback) {
     51    var RemoveAllInDirectoryHelper = function(successCallback, errorCallback) {
     52        this.entriesCount = 0;
     53        this.reader = null;
    5354        this.successCallback = successCallback;
    5455        this.errorCallback = errorCallback;
    5556
    56         this.removeRecursively = function(directory)
     57        this.entryRemovedCallback = bindCallback(this, function(entry)
    5758        {
    58             this.removeRecursivelyInternal(directory);
    59         };
     59            if (--this.entriesCount == 0 && this.successCallback)
     60                this.successCallback();
     61        });
    6062
    61         this.hasMoreEntries = function(hash)
    62         {
    63             for (k in hash)
    64                 return true;
    65             return false;
    66         };
    67 
    68         this.removeDirectory = function(directory, parentDirectory)
    69         {
    70             if (directory.fullPath != '/') {
    71                 // Ok to remove the parent directory.
    72                 directory.remove(bindCallback(this, this.entryRemovedCallback, parentDirectory, directory), bindCallback(this, this.ErrorCallback));
    73             } else
    74                 delete this.removeDirMap[directory.fullPath];
    75             if (!this.hasMoreEntries(this.removeDirMap) && this.successCallback)
    76                 this.successCallback();
    77         };
    78 
    79         this.entryRemovedCallback = function(directory, entry)
    80         {
    81             if (entry.isDirectory)
    82                 delete this.removeDirMap[entry.fullPath];
    83 
    84             if (directory) {
    85                 var dirInfo = this.removeDirMap[directory.fullPath];
    86                 if (--dirInfo.entries == 0 && dirInfo.hasMore == false)
    87                     this.removeDirectory(directory, dirInfo.parentDirectory);
    88             }
    89         };
    90 
    91         this.removeRecursivelyCallback = function(entries, directory)
     63        this.entriesCallback = bindCallback(this, function(entries)
    9264        {
    9365            for (var i = 0; i < entries.length; ++i) {
    94                 this.removeDirMap[directory.fullPath].entries++;
     66                this.entriesCount++;
    9567                if (entries[i].isDirectory)
    96                     this.removeRecursivelyInternal(entries[i], directory);
     68                    entries[i].removeRecursively(this.entryRemovedCallback, this.errorCallback);
    9769                else {
    98                     var entry = entries[i];
    99                     entry.remove(bindCallback(this, this.entryRemovedCallback, directory, entry), bindCallback(this, this.errorCallback));
     70                    entries[i].remove(this.entryRemovedCallback, this.errorCallback);
    10071                }
    10172            }
    102             if (entries.length) {
    103                 this.removeDirMap[directory.fullPath].reader.readEntries(bindCallback(this, this.removeRecursivelyCallback, directory), bindCallback(this, this.errorCallback));
    104             } else {
    105                 var dirInfo = this.removeDirMap[directory.fullPath];
    106                 dirInfo.hasMore = false;
    107                 if (dirInfo.entries == 0)
    108                     this.removeDirectory(directory, dirInfo.parentDirectory);
    109             }
    110         };
     73            if (entries.length)
     74                this.reader.readEntries(this.entriesCallback, this.errorCallback);
     75            else if (this.entriesCount == 0 && this.successCallback)
     76                this.successCallback();
     77        });
    11178
    112         this.removeRecursivelyInternal = function(directory, parentDirectory)
     79        this.removeAllInDirectory = function(directory)
    11380        {
    114             directoryReader = directory.createReader();
    115             this.removeDirMap[directory.fullPath] = {
    116                 hasMore: true,
    117                 parentDirectory: parentDirectory,
    118                 entries: 0,
    119                 reader: directoryReader,
    120             };
    121             directoryReader.readEntries(bindCallback(this, this.removeRecursivelyCallback, directory), bindCallback(this, this.errorCallback));
     81            this.reader = directory.createReader();
     82            this.reader.readEntries(this.entriesCallback, this.errorCallback);
    12283        };
    12384    };
    12485
    125     var helper = new RemoveRecursiveHelper(successCallback, errorCallback);
    126     helper.removeRecursively(directory);
     86    var helper = new RemoveAllInDirectoryHelper(successCallback, errorCallback);
     87    helper.removeAllInDirectory(directory);
    12788}
  • trunk/LayoutTests/fast/filesystem/resources/fs-worker-common.js

    r69249 r69485  
    2828function shouldBeTrue(_a) { shouldBe(_a, "true"); }
    2929
    30 function removeRecursivelySync(directory) {
     30function removeAllInDirectorySync(directory) {
    3131    if (!directory)
    3232        return;
     
    3636        for (var i = 0; i < entries.length; ++i) {
    3737            if (entries[i].isDirectory)
    38                 removeRecursivelySync(entries[i]);
     38                entries[i].removeRecursively();
    3939            else
    4040                entries[i].remove();
    4141        }
    4242    } while (entries.length);
    43     if (directory.fullPath != '/')
    44         directory.remove();
    4543}
    4644
  • trunk/LayoutTests/fast/filesystem/resources/op-remove.js

    r69339 r69485  
    88        tests: [
    99            function(helper) { helper.remove('/a'); },
    10             function(helper) { helper.remove('/b'); }
     10            function(helper) { helper.remove('/b'); },
     11            function(helper) { helper.remove('/', FileError.INVALID_MODIFICATION_ERR); }
    1112        ],
    1213        postcondition: [
     
    3132        ],
    3233    },
     34    {
     35        name: 'RemoveRecursiveWithoutChildren',
     36        precondition: [
     37            {fullPath:'/a', isDirectory:true},
     38        ],
     39        tests: [
     40            function(helper) { helper.removeRecursively('/a'); }
     41        ],
     42        postcondition: [
     43            {fullPath:'/a', nonexistent:true},
     44        ],
     45    },
     46    {
     47        name: 'RemoveRecursiveWithChildren',
     48        precondition: [
     49            {fullPath:'/a', isDirectory:true},
     50            {fullPath:'/a/b', isDirectory:true},
     51            {fullPath:'/a/c',}
     52        ],
     53        tests: [
     54            function(helper) { helper.removeRecursively('/a'); },
     55            function(helper) { helper.removeRecursively('/', FileError.INVALID_MODIFICATION_ERR); }
     56        ],
     57        postcondition: [
     58            {fullPath:'/a', nonexistent:true},
     59        ],
     60    },
    3361];
    3462
  • trunk/LayoutTests/fast/filesystem/resources/op-tests-helper.js

    r69339 r69485  
    264264        };
    265265
     266        this.removeRecursively = function(entry, expectedErrorCode)
     267        {
     268            this.expectedErrorCode = expectedErrorCode;
     269            this.stage = '"' + entry + '".removeRecursively()';
     270            this.environment[entry].removeRecursively(bindCallback(this, this.testSuccessCallback), bindCallback(this, this.testErrorCallback));
     271        };
     272
    266273        this.readDirectory = function(entry, expectedErrorCode)
    267274        {
     
    292299            this.expectedErrorCode = '';
    293300            this.stage = 'resetting filesystem';
    294             removeRecursively(this.fileSystem.root, bindCallback(this, this.setUp), bindCallback(this, this.testErrorCallback));
     301            removeAllInDirectory(this.fileSystem.root, bindCallback(this, this.setUp), bindCallback(this, this.testErrorCallback));
    295302        };
    296303
  • trunk/LayoutTests/fast/filesystem/resources/sync-operations.js

    r69249 r69485  
    77
    88var fileSystem = requestFileSystemSync(this.TEMPORARY, 100);
    9 removeRecursivelySync(fileSystem.root);
     9removeAllInDirectorySync(fileSystem.root);
    1010
    1111// Stage 1 (prepare)
     
    3939shouldBe('"' + paths.join(',') + '"', '"/a,/b,/c,/d2,/e,/f"');
    4040shouldBe("dirsCount", "3");
    41 removeRecursivelySync(fileSystem.root);
     41removeAllInDirectorySync(fileSystem.root);
    4242finishJSTest();
    4343
  • trunk/LayoutTests/fast/filesystem/script-tests/file-from-file-entry.js

    r69165 r69485  
    3030function fileSystemCallback(fs) {
    3131    fileSystem = fs;
    32     removeRecursively(fileSystem.root, createTestFile, errorCallback);
     32    removeAllInDirectory(fileSystem.root, createTestFile, errorCallback);
    3333}
    3434
  • trunk/LayoutTests/fast/filesystem/script-tests/read-directory.js

    r68735 r69485  
    2020function endTest()
    2121{
    22     removeRecursively(fileSystem.root);
     22    removeAllInDirectory(fileSystem.root);
    2323    finishJSTest();
    2424}
     
    8686    fileSystem = fs;
    8787    debug("Successfully obtained Persistent FileSystem:" + fileSystem.name);
    88     removeRecursively(fileSystem.root, prepareForTest, errorCallback);
     88    removeAllInDirectory(fileSystem.root, prepareForTest, errorCallback);
    8989}
    9090
  • trunk/LayoutTests/platform/chromium-linux/fast/filesystem/async-operations-expected.txt

    r69337 r69485  
    1414
    1515TEST COMPLETE
     16
  • trunk/WebCore/ChangeLog

    r69482 r69485  
     12010-10-11  Kinuko Yasuda  <kinuko@chromium.org>
     2
     3        Reviewed by David Levin.
     4
     5        Support DirectoryEntry.removeRecursively for FileSystem API
     6        https://bugs.webkit.org/show_bug.cgi?id=47400
     7
     8        Also disallows remove/removeRecursively on the root directory.
     9
     10        Test: fast/filesystem/op-remove.html
     11
     12        * fileapi/DOMFileSystemBase.cpp:
     13        (WebCore::DOMFileSystemBase::removeRecursively): Added.
     14        * fileapi/DOMFileSystemBase.h:
     15        * fileapi/DirectoryEntry.cpp:
     16        (WebCore::DirectoryEntry::removeRecursively): Added.
     17        * fileapi/DirectoryEntry.h:
     18        * fileapi/DirectoryEntry.idl:
     19        * fileapi/DirectoryEntrySync.cpp:
     20        (WebCore::DirectoryEntrySync::removeRecursively): Added.
     21        * fileapi/DirectoryEntrySync.h:
     22        * fileapi/DirectoryEntrySync.idl:
     23        * platform/AsyncFileSystem.h:
     24
    1252010-10-11  Dirk Schulze  <krit@webkit.org>
    226
  • trunk/WebCore/fileapi/DOMFileSystemBase.cpp

    r69382 r69485  
    133133{
    134134    ASSERT(entry);
     135    // We don't allow calling remove() on the root directory.
     136    if (entry->fullPath() == String(DOMFilePath::root))
     137        return false;
    135138    String platformPath = m_asyncFileSystem->virtualToPlatformPath(entry->fullPath());
    136139    m_asyncFileSystem->remove(platformPath, VoidCallbacks::create(successCallback, errorCallback));
     140    return true;
     141}
     142
     143bool DOMFileSystemBase::removeRecursively(const EntryBase* entry, PassRefPtr<VoidCallback> successCallback, PassRefPtr<ErrorCallback> errorCallback)
     144{
     145    ASSERT(entry && entry->isDirectory());
     146    // We don't allow calling remove() on the root directory.
     147    if (entry->fullPath() == String(DOMFilePath::root))
     148        return false;
     149    String platformPath = m_asyncFileSystem->virtualToPlatformPath(entry->fullPath());
     150    m_asyncFileSystem->removeRecursively(platformPath, VoidCallbacks::create(successCallback, errorCallback));
    137151    return true;
    138152}
  • trunk/WebCore/fileapi/DOMFileSystemBase.h

    r69249 r69485  
    6969    bool copy(const EntryBase* source, EntryBase* parent, const String& name, PassRefPtr<EntryCallback>, PassRefPtr<ErrorCallback>);
    7070    bool remove(const EntryBase*, PassRefPtr<VoidCallback>, PassRefPtr<ErrorCallback>);
     71    bool removeRecursively(const EntryBase*, PassRefPtr<VoidCallback>, PassRefPtr<ErrorCallback>);
    7172    bool getParent(const EntryBase*, PassRefPtr<EntryCallback>, PassRefPtr<ErrorCallback>);
    7273    bool getFile(const EntryBase*, const String& path, PassRefPtr<Flags>, PassRefPtr<EntryCallback>, PassRefPtr<ErrorCallback>);
  • trunk/WebCore/fileapi/DirectoryEntry.cpp

    r69249 r69485  
    3838#include "ErrorCallback.h"
    3939#include "FileError.h"
     40#include "VoidCallback.h"
    4041
    4142namespace WebCore {
     
    6566}
    6667
     68void DirectoryEntry::removeRecursively(PassRefPtr<VoidCallback> successCallback, PassRefPtr<ErrorCallback> errorCallbackRef) const
     69{
     70    RefPtr<ErrorCallback> errorCallback(errorCallbackRef);
     71    if (!m_fileSystem->removeRecursively(this, successCallback, errorCallback))
     72        filesystem()->scheduleCallback(errorCallback.release(), FileError::create(INVALID_MODIFICATION_ERR));
     73}
     74
    6775}
    6876
  • trunk/WebCore/fileapi/DirectoryEntry.h

    r69249 r69485  
    4646class EntryCallback;
    4747class ErrorCallback;
     48class VoidCallback;
    4849
    4950class DirectoryEntry : public Entry {
     
    5859    void getFile(const String& path, PassRefPtr<Flags> = 0, PassRefPtr<EntryCallback> = 0, PassRefPtr<ErrorCallback> = 0);
    5960    void getDirectory(const String& path, PassRefPtr<Flags> = 0, PassRefPtr<EntryCallback> = 0, PassRefPtr<ErrorCallback> = 0);
     61    void removeRecursively(PassRefPtr<VoidCallback> successCallback = 0, PassRefPtr<ErrorCallback> = 0) const;
    6062
    6163private:
  • trunk/WebCore/fileapi/DirectoryEntry.idl

    r67917 r69485  
    3939        [Custom] void getFile(in [ConvertUndefinedOrNullToNullString] DOMString path, in [Optional] Flags flags, in [Optional, Callback] EntryCallback successCallback, in [Optional, Callback] ErrorCallback errorCallback);
    4040        [Custom] void getDirectory(in [ConvertUndefinedOrNullToNullString] DOMString path, in [Optional] Flags flags, in [Optional, Callback] EntryCallback successCallback, in [Optional, Callback] ErrorCallback errorCallback);
     41        void removeRecursively(in [Optional, Callback] VoidCallback successCallback, in [Optional, Callback] ErrorCallback errorCallback);
    4142    };
    4243}
  • trunk/WebCore/fileapi/DirectoryEntrySync.cpp

    r69249 r69485  
    7373}
    7474
     75void DirectoryEntrySync::removeRecursively(ExceptionCode& ec)
     76{
     77    ec = 0;
     78    VoidSyncCallbackHelper helper(m_fileSystem->asyncFileSystem());
     79    if (!m_fileSystem->removeRecursively(this, helper.successCallback(), helper.errorCallback())) {
     80        ec = INVALID_MODIFICATION_ERR;
     81        return;
     82    }
     83    helper.getResult(ec);
     84}
     85
    7586}
    7687
  • trunk/WebCore/fileapi/DirectoryEntrySync.h

    r69178 r69485  
    5656    PassRefPtr<FileEntrySync> getFile(const String& path, PassRefPtr<Flags>, ExceptionCode&);
    5757    PassRefPtr<DirectoryEntrySync> getDirectory(const String& path, PassRefPtr<Flags>, ExceptionCode&);
     58    void removeRecursively(ExceptionCode&);
    5859
    5960private:
  • trunk/WebCore/fileapi/DirectoryEntrySync.idl

    r69178 r69485  
    3939        [Custom] FileEntrySync getFile(in [ConvertUndefinedOrNullToNullString] DOMString path, in Flags flags) raises (FileException);
    4040        [Custom] DirectoryEntrySync getDirectory(in [ConvertUndefinedOrNullToNullString] DOMString path, in Flags flags) raises (FileException);
     41        void removeRecursively() raises (FileException);
    4142    };
    4243}
  • trunk/WebCore/fileapi/Entry.h

    r69249 r69485  
    5252    DOMFileSystem* filesystem() const { return static_cast<DOMFileSystem*>(m_fileSystem); }
    5353
    54     virtual void getMetadata(PassRefPtr<MetadataCallback> successCallback = 0, PassRefPtr<ErrorCallback> errorCallback = 0);
    55     virtual void moveTo(PassRefPtr<DirectoryEntry> parent, const String& name = String(), PassRefPtr<EntryCallback> successCallback = 0, PassRefPtr<ErrorCallback> errorCallback = 0) const;
    56     virtual void copyTo(PassRefPtr<DirectoryEntry> parent, const String& name = String(), PassRefPtr<EntryCallback> successCallback = 0, PassRefPtr<ErrorCallback> errorCallback = 0) const;
    57     virtual void remove(PassRefPtr<VoidCallback> successCallback = 0, PassRefPtr<ErrorCallback> errorCallback = 0) const;
    58     virtual void getParent(PassRefPtr<EntryCallback> successCallback = 0, PassRefPtr<ErrorCallback> errorCallback = 0) const;
     54    void getMetadata(PassRefPtr<MetadataCallback> successCallback = 0, PassRefPtr<ErrorCallback> errorCallback = 0);
     55    void moveTo(PassRefPtr<DirectoryEntry> parent, const String& name = String(), PassRefPtr<EntryCallback> successCallback = 0, PassRefPtr<ErrorCallback> errorCallback = 0) const;
     56    void copyTo(PassRefPtr<DirectoryEntry> parent, const String& name = String(), PassRefPtr<EntryCallback> successCallback = 0, PassRefPtr<ErrorCallback> errorCallback = 0) const;
     57    void remove(PassRefPtr<VoidCallback> successCallback = 0, PassRefPtr<ErrorCallback> errorCallback = 0) const;
     58    void getParent(PassRefPtr<EntryCallback> successCallback = 0, PassRefPtr<ErrorCallback> errorCallback = 0) const;
    5959
    60     virtual String toURI(const String& mimeType = String());
     60    String toURI(const String& mimeType = String());
    6161
    6262protected:
  • trunk/WebCore/fileapi/EntrySync.cpp

    r69249 r69485  
    8888    ec = 0;
    8989    VoidSyncCallbackHelper helper(m_fileSystem->asyncFileSystem());
    90     if (!m_fileSystem->remove(this, helper.successCallback(), helper.errorCallback()))
     90    if (!m_fileSystem->remove(this, helper.successCallback(), helper.errorCallback())) {
    9191        ec = INVALID_MODIFICATION_ERR;
     92        return;
     93    }
    9294    helper.getResult(ec);
    9395}
  • trunk/WebCore/fileapi/EntrySync.h

    r69249 r69485  
    5252    DOMFileSystemSync* filesystem() const { return static_cast<DOMFileSystemSync*>(m_fileSystem); }
    5353
    54     virtual PassRefPtr<Metadata> getMetadata(ExceptionCode&);
    55     virtual PassRefPtr<EntrySync> moveTo(PassRefPtr<DirectoryEntrySync> parent, const String& name, ExceptionCode&) const;
    56     virtual PassRefPtr<EntrySync> copyTo(PassRefPtr<DirectoryEntrySync> parent, const String& name, ExceptionCode&) const;
    57     virtual void remove(ExceptionCode&) const;
    58     virtual PassRefPtr<EntrySync> getParent() const;
     54    PassRefPtr<Metadata> getMetadata(ExceptionCode&);
     55    PassRefPtr<EntrySync> moveTo(PassRefPtr<DirectoryEntrySync> parent, const String& name, ExceptionCode&) const;
     56    PassRefPtr<EntrySync> copyTo(PassRefPtr<DirectoryEntrySync> parent, const String& name, ExceptionCode&) const;
     57    void remove(ExceptionCode&) const;
     58    PassRefPtr<EntrySync> getParent() const;
    5959
    6060protected:
  • trunk/WebCore/platform/AsyncFileSystem.h

    r69249 r69485  
    8181
    8282    // Deletes a file or directory at a given path.
     83    // It is an error to try to remove a directory that is not empty.
    8384    // AsyncFileSystemCallbacks::didSucceed() is called when the operation is completed successfully.
    8485    // AsyncFileSystemCallbacks::didFail() is called otherwise.
    8586    virtual void remove(const String& path, PassOwnPtr<AsyncFileSystemCallbacks>) = 0;
     87
     88    // Recursively deletes a directory at a given path.
     89    // AsyncFileSystemCallbacks::didSucceed() is called when the operation is completed successfully.
     90    // AsyncFileSystemCallbacks::didFail() is called otherwise.
     91    virtual void removeRecursively(const String& path, PassOwnPtr<AsyncFileSystemCallbacks>) = 0;
    8692
    8793    // Retrieves the metadata information of the file or directory at a given path.
  • trunk/WebKit/chromium/ChangeLog

    r69459 r69485  
     12010-10-11  Kinuko Yasuda  <kinuko@google.com>
     2
     3        Reviewed by David Levin.
     4
     5        Support DirectoryEntry.removeRecursively for FileSystem API
     6        https://bugs.webkit.org/show_bug.cgi?id=47400
     7
     8        * src/AsyncFileSystemChromium.cpp:
     9        (WebCore::AsyncFileSystemChromium::removeRecursively): Added.
     10        * src/AsyncFileSystemChromium.h:
     11        * src/WorkerAsyncFileSystemChromium.cpp:
     12        (WebCore::WorkerAsyncFileSystemChromium::removeRecursively): Added.
     13        * src/WorkerAsyncFileSystemChromium.h:
     14        * src/WorkerFileSystemCallbacksBridge.cpp:
     15        (WebKit::WorkerFileSystemCallbacksBridge::postRemoveRecursivelyToMainThread): Added.
     16        (WebKit::WorkerFileSystemCallbacksBridge::removeRecursivelyOnMainThread): Added.
     17        * src/WorkerFileSystemCallbacksBridge.h:
     18
    1192010-10-09  Varun Jain  <varunjain@chromium.org>
    220
  • trunk/WebKit/chromium/src/AsyncFileSystemChromium.cpp

    r68669 r69485  
    7575{
    7676    m_webFileSystem->remove(path, new WebKit::WebFileSystemCallbacksImpl(callbacks));
     77}
     78
     79void AsyncFileSystemChromium::removeRecursively(const String& path, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
     80{
     81    m_webFileSystem->removeRecursively(path, new WebKit::WebFileSystemCallbacksImpl(callbacks));
    7782}
    7883
  • trunk/WebKit/chromium/src/AsyncFileSystemChromium.h

    r68669 r69485  
    5757    virtual void copy(const String& sourcePath, const String& destinationPath, PassOwnPtr<AsyncFileSystemCallbacks>);
    5858    virtual void remove(const String& path, PassOwnPtr<AsyncFileSystemCallbacks>);
     59    virtual void removeRecursively(const String& path, PassOwnPtr<AsyncFileSystemCallbacks>);
    5960    virtual void readMetadata(const String& path, PassOwnPtr<AsyncFileSystemCallbacks>);
    6061    virtual void createFile(const String& path, bool exclusive, PassOwnPtr<AsyncFileSystemCallbacks>);
  • trunk/WebKit/chromium/src/WorkerAsyncFileSystemChromium.cpp

    r69249 r69485  
    100100}
    101101
     102void WorkerAsyncFileSystemChromium::removeRecursively(const String& path, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
     103{
     104    createWorkerFileSystemCallbacksBridge(callbacks)->postRemoveRecursivelyToMainThread(m_webFileSystem, path, m_modeForCurrentOperation);
     105}
     106
    102107void WorkerAsyncFileSystemChromium::readMetadata(const String& path, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
    103108{
  • trunk/WebKit/chromium/src/WorkerAsyncFileSystemChromium.h

    r69249 r69485  
    6666    virtual void copy(const String& sourcePath, const String& destinationPath, PassOwnPtr<AsyncFileSystemCallbacks>);
    6767    virtual void remove(const String& path, PassOwnPtr<AsyncFileSystemCallbacks>);
     68    virtual void removeRecursively(const String& path, PassOwnPtr<AsyncFileSystemCallbacks>);
    6869    virtual void readMetadata(const String& path, PassOwnPtr<AsyncFileSystemCallbacks>);
    6970    virtual void createFile(const String& path, bool exclusive, PassOwnPtr<AsyncFileSystemCallbacks>);
  • trunk/WebKit/chromium/src/WorkerFileSystemCallbacksBridge.cpp

    r68669 r69485  
    172172}
    173173
     174void WorkerFileSystemCallbacksBridge::postRemoveRecursivelyToMainThread(WebFileSystem* fileSystem, const String& path, const String& mode)
     175{
     176    ASSERT(fileSystem);
     177    dispatchTaskToMainThread(createCallbackTask(&removeRecursivelyOnMainThread, fileSystem, path, this, mode));
     178}
     179
    174180void WorkerFileSystemCallbacksBridge::postReadMetadataToMainThread(WebFileSystem* fileSystem, const String& path, const String& mode)
    175181{
     
    229235{
    230236    fileSystem->remove(path, MainThreadFileSystemCallbacks::createLeakedPtr(bridge, mode));
     237}
     238
     239void WorkerFileSystemCallbacksBridge::removeRecursivelyOnMainThread(WebCore::ScriptExecutionContext*, WebFileSystem* fileSystem, const String& path, WorkerFileSystemCallbacksBridge* bridge, const String& mode)
     240{
     241    fileSystem->removeRecursively(path, MainThreadFileSystemCallbacks::createLeakedPtr(bridge, mode));
    231242}
    232243
  • trunk/WebKit/chromium/src/WorkerFileSystemCallbacksBridge.h

    r68669 r69485  
    8989    void postCopyToMainThread(WebFileSystem*, const String& srcPath, const String& destPath, const String& mode);
    9090    void postRemoveToMainThread(WebFileSystem*, const String& path, const String& mode);
     91    void postRemoveRecursivelyToMainThread(WebFileSystem*, const String& path, const String& mode);
    9192    void postReadMetadataToMainThread(WebFileSystem*, const String& path, const String& mode);
    9293    void postCreateFileToMainThread(WebFileSystem*, const String& path, bool exclusive, const String& mode);
     
    111112    static void copyOnMainThread(WebCore::ScriptExecutionContext*, WebFileSystem*, const String& srcPath, const String& destPath, WorkerFileSystemCallbacksBridge*, const String& mode);
    112113    static void removeOnMainThread(WebCore::ScriptExecutionContext*, WebFileSystem*, const String& path, WorkerFileSystemCallbacksBridge*, const String& mode);
     114    static void removeRecursivelyOnMainThread(WebCore::ScriptExecutionContext*, WebFileSystem*, const String& path, WorkerFileSystemCallbacksBridge*, const String& mode);
    113115    static void readMetadataOnMainThread(WebCore::ScriptExecutionContext*, WebFileSystem*, const String& path, WorkerFileSystemCallbacksBridge*, const String& mode);
    114116    static void createFileOnMainThread(WebCore::ScriptExecutionContext*, WebFileSystem*, const String& path, bool exclusive, WorkerFileSystemCallbacksBridge*, const String& mode);
Note: See TracChangeset for help on using the changeset viewer.