Changeset 66407 in webkit


Ignore:
Timestamp:
Aug 30, 2010 1:50:19 PM (14 years ago)
Author:
kinuko@chromium.org
Message:

2010-08-30 Kinuko Yasuda <kinuko@chromium.osrc>

Reviewed by Darin Fisher.

Add DOMFileSystem implementation to support Entry manipulation operations
https://bugs.webkit.org/show_bug.cgi?id=44732

Fixed virtual-path / platform-path conversion timing. (The conversion needs to be done before calling AsyncFileSystem methods to support cross-filesystem operations.)

  • src/AsyncFileSystemChromium.cpp: (WebCore::AsyncFileSystemChromium::move): (WebCore::AsyncFileSystemChromium::copy): (WebCore::AsyncFileSystemChromium::remove): (WebCore::AsyncFileSystemChromium::readMetadata): (WebCore::AsyncFileSystemChromium::createFile): (WebCore::AsyncFileSystemChromium::createDirectory): (WebCore::AsyncFileSystemChromium::fileExists): (WebCore::AsyncFileSystemChromium::directoryExists): (WebCore::AsyncFileSystemChromium::readDirectory):

2010-08-30 Kinuko Yasuda <kinuko@chromium.org>

Reviewed by Darin Fisher.

Add DOMFileSystem implementation to support Entry manipulation operations
https://bugs.webkit.org/show_bug.cgi?id=44732

No new tests; tests will be added later.

  • storage/DOMFileSystem.cpp: (WebCore::DOMFileSystem::root): (WebCore::checkValidityForForCopyOrMove): Added. (WebCore::DOMFileSystem::getMetadata): Added. (WebCore::DOMFileSystem::move): Added. (WebCore::DOMFileSystem::copy): Added. (WebCore::DOMFileSystem::remove): Added. (WebCore::DOMFileSystem::getParent): Added. (WebCore::DOMFileSystem::getFile): Added. (WebCore::DOMFileSystem::getDirectory): Added. (WebCore::DOMFileSystem::readDirectory): Added.
  • storage/DirectoryEntry.cpp: (WebCore::DirectoryEntry::getFile): Added implementation. (WebCore::DirectoryEntry::getDirectory): Added implementation.
  • storage/DirectoryReader.cpp: (WebCore::DirectoryReader::DirectoryReader): Added implementation. (WebCore::DirectoryReader::readEntries): Added implementation.
  • storage/DirectoryReader.h:
  • storage/Entry.cpp: (WebCore::Entry::getMetadata): Added implementation. (WebCore::Entry::moveTo): Added implementation. (WebCore::Entry::copyTo): Added implementation. (WebCore::Entry::remove): Added implementation. (WebCore::Entry::getParent): Added implementation.
  • storage/Entry.h:
  • storage/FileEntry.h:

Added a helper template to schedule callbacks.

  • storage/DOMFileSystem.h: (WebCore::DOMFileSystem::DispatchCallbackTask): Added to schedule callbacks. (WebCore::DOMFileSystem::scheduleCallback): Added to schedule callbacks.

Changed to fire callbacks asynchronously.

  • storage/LocalFileSystem.cpp: (WebCore::LocalFileSystem::requestFileSystem):
Location:
trunk
Files:
15 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r66404 r66407  
     12010-08-30  Kinuko Yasuda  <kinuko@chromium.org>
     2
     3        Reviewed by Darin Fisher.
     4
     5        Add DOMFileSystem implementation to support Entry manipulation operations
     6        https://bugs.webkit.org/show_bug.cgi?id=44732
     7
     8        No new tests; tests will be added later.
     9
     10        * storage/DOMFileSystem.cpp:
     11        (WebCore::DOMFileSystem::root):
     12        (WebCore::checkValidityForForCopyOrMove): Added.
     13        (WebCore::DOMFileSystem::getMetadata): Added.
     14        (WebCore::DOMFileSystem::move): Added.
     15        (WebCore::DOMFileSystem::copy): Added.
     16        (WebCore::DOMFileSystem::remove): Added.
     17        (WebCore::DOMFileSystem::getParent): Added.
     18        (WebCore::DOMFileSystem::getFile): Added.
     19        (WebCore::DOMFileSystem::getDirectory): Added.
     20        (WebCore::DOMFileSystem::readDirectory): Added.
     21        * storage/DirectoryEntry.cpp:
     22        (WebCore::DirectoryEntry::getFile): Added implementation.
     23        (WebCore::DirectoryEntry::getDirectory): Added implementation.
     24        * storage/DirectoryReader.cpp:
     25        (WebCore::DirectoryReader::DirectoryReader): Added implementation.
     26        (WebCore::DirectoryReader::readEntries): Added implementation.
     27        * storage/DirectoryReader.h:
     28        * storage/Entry.cpp:
     29        (WebCore::Entry::getMetadata): Added implementation.
     30        (WebCore::Entry::moveTo): Added implementation.
     31        (WebCore::Entry::copyTo): Added implementation.
     32        (WebCore::Entry::remove): Added implementation.
     33        (WebCore::Entry::getParent): Added implementation.
     34        * storage/Entry.h:
     35        * storage/FileEntry.h:
     36
     37        Added a helper template to schedule callbacks.
     38        * storage/DOMFileSystem.h:
     39        (WebCore::DOMFileSystem::DispatchCallbackTask): Added to schedule callbacks.
     40        (WebCore::DOMFileSystem::scheduleCallback): Added to schedule callbacks.
     41
     42        Changed to fire callbacks asynchronously.
     43        * storage/LocalFileSystem.cpp:
     44        (WebCore::LocalFileSystem::requestFileSystem):
     45
    1462010-08-30  Alejandro G. Castro  <alex@igalia.com>
    247
  • trunk/WebCore/platform/AsyncFileSystem.h

    r66255 r66407  
    3535
    3636#include "PlatformString.h"
     37#include "Timer.h"
    3738#include <wtf/PassOwnPtr.h>
    3839
     
    4243class AsyncFileSystemCallbacks;
    4344
    44 // This class provides async interface for platform-specific DOMFileSystem implementation. Note that all the methods take canonicalized virtual paths.
     45// This class provides async interface for platform-specific file system implementation.  Note that all the methods take platform paths.
    4546class AsyncFileSystem : public Noncopyable {
    4647public:
  • trunk/WebCore/storage/DOMFileSystem.cpp

    r66255 r66407  
    3535
    3636#include "AsyncFileSystem.h"
     37#include "DOMFilePath.h"
    3738#include "DirectoryEntry.h"
     39#include "EntriesCallback.h"
     40#include "Entry.h"
     41#include "EntryCallback.h"
     42#include "ErrorCallback.h"
     43#include "FileError.h"
     44#include "FileSystemCallbacks.h"
     45#include "MetadataCallback.h"
    3846#include "ScriptExecutionContext.h"
     47#include "VoidCallback.h"
     48#include <wtf/OwnPtr.h>
    3949
    4050namespace WebCore {
     
    5363PassRefPtr<DirectoryEntry> DOMFileSystem::root()
    5464{
    55     return DirectoryEntry::create(this, "/");
     65    return DirectoryEntry::create(this, DOMFilePath::root);
    5666}
    5767
     
    7181}
    7282
     83void DOMFileSystem::getMetadata(const Entry* entry, PassRefPtr<MetadataCallback> successCallback, PassRefPtr<ErrorCallback> errorCallback)
     84{
     85    String platformPath = m_asyncFileSystem->virtualToPlatformPath(entry->fullPath());
     86    m_asyncFileSystem->readMetadata(platformPath, new MetadataCallbacks(successCallback, errorCallback));
     87}
     88
     89static bool checkValidityForForCopyOrMove(const Entry* src, Entry* parent, const String& newName)
     90{
     91    ASSERT(src);
     92
     93    if (!parent || !parent->isDirectory())
     94        return false;
     95
     96    if (!newName.isEmpty() && !DOMFilePath::isValidName(newName))
     97        return false;
     98
     99    // It is an error to try to copy or move an entry inside itself at any depth if it is a directory.
     100    if (src->isDirectory() && DOMFilePath::isParentOf(src->fullPath(), parent->fullPath()))
     101        return false;
     102
     103    // It is an error to copy or move an entry into its parent if a name different from its current one isn't provided.
     104    if ((newName.isEmpty() || src->name() == newName) && DOMFilePath::getDirectory(src->fullPath()) == parent->fullPath())
     105        return false;
     106
     107    return true;
     108}
     109
     110void DOMFileSystem::move(const Entry* src, PassRefPtr<Entry> parent, const String& newName, PassRefPtr<EntryCallback> successCallback, PassRefPtr<ErrorCallback> errorCallback)
     111{
     112    if (!checkValidityForForCopyOrMove(src, parent.get(), newName)) {
     113        scheduleCallback(scriptExecutionContext(), errorCallback, FileError::create(INVALID_MODIFICATION_ERR));
     114        return;
     115    }
     116
     117    String destPath = parent->fullPath();
     118    if (!newName.isEmpty())
     119        destPath = DOMFilePath::append(destPath, newName);
     120    else
     121        destPath = DOMFilePath::append(destPath, src->name());
     122
     123    String srcPlatformPath = m_asyncFileSystem->virtualToPlatformPath(src->fullPath());
     124    String destPlatformPath = parent->filesystem()->asyncFileSystem()->virtualToPlatformPath(destPath);
     125    m_asyncFileSystem->move(srcPlatformPath, destPlatformPath, new EntryCallbacks(successCallback, errorCallback, this, destPath, src->isDirectory()));
     126}
     127
     128void DOMFileSystem::copy(const Entry* src, PassRefPtr<Entry> parent, const String& newName, PassRefPtr<EntryCallback> successCallback, PassRefPtr<ErrorCallback> errorCallback)
     129{
     130    if (!checkValidityForForCopyOrMove(src, parent.get(), newName)) {
     131        scheduleCallback(scriptExecutionContext(), errorCallback, FileError::create(INVALID_MODIFICATION_ERR));
     132        return;
     133    }
     134
     135    String destPath = parent->fullPath();
     136    if (!newName.isEmpty())
     137        destPath = DOMFilePath::append(destPath, newName);
     138    else
     139        destPath = DOMFilePath::append(destPath, src->name());
     140
     141    String srcPlatformPath = m_asyncFileSystem->virtualToPlatformPath(src->fullPath());
     142    String destPlatformPath = parent->filesystem()->asyncFileSystem()->virtualToPlatformPath(destPath);
     143    m_asyncFileSystem->copy(srcPlatformPath, destPlatformPath, new EntryCallbacks(successCallback, errorCallback, this, destPath, src->isDirectory()));
     144}
     145
     146void DOMFileSystem::remove(const Entry* entry, PassRefPtr<VoidCallback> successCallback, PassRefPtr<ErrorCallback> errorCallback)
     147{
     148    ASSERT(entry);
     149    String platformPath = m_asyncFileSystem->virtualToPlatformPath(entry->fullPath());
     150    m_asyncFileSystem->remove(platformPath, new VoidCallbacks(successCallback, errorCallback));
     151}
     152
     153void DOMFileSystem::getParent(const Entry* entry, PassRefPtr<EntryCallback> successCallback, PassRefPtr<ErrorCallback> errorCallback)
     154{
     155    ASSERT(entry);
     156    String path = DOMFilePath::getDirectory(entry->fullPath());
     157    String platformPath = m_asyncFileSystem->virtualToPlatformPath(path);
     158    m_asyncFileSystem->directoryExists(platformPath, new EntryCallbacks(successCallback, errorCallback, this, path, true));
     159}
     160
     161void DOMFileSystem::getFile(const Entry* base, const String& path, PassRefPtr<Flags> flags, PassRefPtr<EntryCallback> successCallback, PassRefPtr<ErrorCallback> errorCallback)
     162{
     163    ASSERT(base);
     164    if (!DOMFilePath::isValidPath(path)) {
     165        scheduleCallback(scriptExecutionContext(), errorCallback, FileError::create(INVALID_MODIFICATION_ERR));
     166        return;
     167    }
     168
     169    String absolutePath = path;
     170    if (!DOMFilePath::isAbsolute(path))
     171        absolutePath = DOMFilePath::removeExtraParentReferences(DOMFilePath::append(base->fullPath(), path));
     172    String platformPath = m_asyncFileSystem->virtualToPlatformPath(absolutePath);
     173
     174    OwnPtr<EntryCallbacks> callbacks = adoptPtr(new EntryCallbacks(successCallback, errorCallback, this, absolutePath, false));
     175    if (flags && flags->isCreate())
     176        m_asyncFileSystem->createFile(platformPath, flags->isExclusive(), callbacks.release());
     177    else
     178        m_asyncFileSystem->fileExists(platformPath, callbacks.release());
     179}
     180
     181void DOMFileSystem::getDirectory(const Entry* base, const String& path, PassRefPtr<Flags> flags, PassRefPtr<EntryCallback> successCallback, PassRefPtr<ErrorCallback> errorCallback)
     182{
     183    ASSERT(base);
     184    if (!DOMFilePath::isValidPath(path)) {
     185        scheduleCallback(scriptExecutionContext(), errorCallback, FileError::create(INVALID_MODIFICATION_ERR));
     186        return;
     187    }
     188
     189    String absolutePath = path;
     190    if (!DOMFilePath::isAbsolute(path))
     191        absolutePath = DOMFilePath::removeExtraParentReferences(DOMFilePath::append(base->fullPath(), path));
     192    String platformPath = m_asyncFileSystem->virtualToPlatformPath(absolutePath);
     193
     194    OwnPtr<EntryCallbacks> callbacks = adoptPtr(new EntryCallbacks(successCallback, errorCallback, this, absolutePath, true));
     195    if (flags && flags->isCreate())
     196        m_asyncFileSystem->createDirectory(platformPath, flags->isExclusive(), callbacks.release());
     197    else
     198        m_asyncFileSystem->directoryExists(platformPath, callbacks.release());
     199}
     200
     201void DOMFileSystem::readDirectory(const String& path, PassRefPtr<EntriesCallback> successCallback, PassRefPtr<ErrorCallback> errorCallback)
     202{
     203    ASSERT(DOMFilePath::isAbsolute(path));
     204    String platformPath = m_asyncFileSystem->virtualToPlatformPath(path);
     205    m_asyncFileSystem->readDirectory(platformPath, new EntriesCallbacks(successCallback, errorCallback, this, path));
     206}
     207
    73208} // namespace
    74209
  • trunk/WebCore/storage/DOMFileSystem.h

    r66255 r66407  
    3838#include "Flags.h"
    3939#include "PlatformString.h"
     40#include "ScriptExecutionContext.h"
    4041#include <wtf/PassRefPtr.h>
    4142#include <wtf/RefCounted.h>
     
    4445
    4546class DirectoryEntry;
    46 class ScriptExecutionContext;
     47class Entry;
     48class EntryCallback;
     49class EntriesCallback;
     50class ErrorCallback;
     51class MetadataCallback;
     52class VoidCallback;
    4753
    4854class DOMFileSystem : public RefCounted<DOMFileSystem>, public ActiveDOMObject {
     
    6369    virtual void contextDestroyed();
    6470
     71    // Actual FileSystem API implementations.  All the validity checks on virtual paths are done at DOMFileSystem level.
     72    void getMetadata(const Entry* entry, PassRefPtr<MetadataCallback> successCallback, PassRefPtr<ErrorCallback> errorCallback);
     73    void move(const Entry* src, PassRefPtr<Entry> parent, const String& name, PassRefPtr<EntryCallback>, PassRefPtr<ErrorCallback>);
     74    void copy(const Entry* src, PassRefPtr<Entry> parent, const String& name, PassRefPtr<EntryCallback>, PassRefPtr<ErrorCallback>);
     75    void remove(const Entry* entry, PassRefPtr<VoidCallback>, PassRefPtr<ErrorCallback>);
     76    void getParent(const Entry* entry, PassRefPtr<EntryCallback>, PassRefPtr<ErrorCallback>);
     77    void getFile(const Entry* base, const String& path, PassRefPtr<Flags>, PassRefPtr<EntryCallback>, PassRefPtr<ErrorCallback>);
     78    void getDirectory(const Entry* base, const String& path, PassRefPtr<Flags>, PassRefPtr<EntryCallback>, PassRefPtr<ErrorCallback>);
     79    void readDirectory(const String& path, PassRefPtr<EntriesCallback>, PassRefPtr<ErrorCallback>);
     80
     81    // Schedule a callback. This should not cross threads (should be called on the same context thread).
     82    template <typename CB, typename CBArg>
     83    static void scheduleCallback(ScriptExecutionContext*, PassRefPtr<CB>, PassRefPtr<CBArg>);
     84
    6585private:
    6686    DOMFileSystem(ScriptExecutionContext*, const String& name, PassOwnPtr<AsyncFileSystem>);
     87
     88    AsyncFileSystem* asyncFileSystem() const { return m_asyncFileSystem.get(); }
     89
     90    // A helper template to schedule a callback task.
     91    // FIXME: move this to a more generic place.
     92    template <typename CB, typename CBArg>
     93    class DispatchCallbackTask : public ScriptExecutionContext::Task {
     94    public:
     95        DispatchCallbackTask(PassRefPtr<CB> callback, PassRefPtr<CBArg> arg)
     96            : m_callback(callback)
     97            , m_callbackArg(arg)
     98        {
     99        }
     100
     101        virtual void performTask(ScriptExecutionContext*)
     102        {
     103            m_callback->handleEvent(m_callbackArg.get());
     104        }
     105
     106    private:
     107        RefPtr<CB> m_callback;
     108        RefPtr<CBArg> m_callbackArg;
     109    };
    67110
    68111    String m_name;
    69112    mutable OwnPtr<AsyncFileSystem> m_asyncFileSystem;
    70113};
     114
     115template <typename CB, typename CBArg>
     116void DOMFileSystem::scheduleCallback(ScriptExecutionContext* scriptExecutionContext, PassRefPtr<CB> callback, PassRefPtr<CBArg> arg)
     117{
     118    ASSERT(scriptExecutionContext->isContextThread());
     119    scriptExecutionContext->postTask(new DispatchCallbackTask<CB, CBArg>(callback, arg));
     120}
    71121
    72122} // namespace
  • trunk/WebCore/storage/DirectoryEntry.cpp

    r65474 r66407  
    4040namespace WebCore {
    4141
    42 DirectoryEntry::DirectoryEntry(PassRefPtr<DOMFileSystem> fileSystem, const String& fullPath)
     42DirectoryEntry::DirectoryEntry(DOMFileSystem* fileSystem, const String& fullPath)
    4343    : Entry(fileSystem, fullPath)
    4444{
     
    5050}
    5151
    52 void DirectoryEntry::getFile(const String&, PassRefPtr<Flags>, PassRefPtr<EntryCallback>, PassRefPtr<ErrorCallback>)
     52void DirectoryEntry::getFile(const String& path, PassRefPtr<Flags> flags, PassRefPtr<EntryCallback> successCallback, PassRefPtr<ErrorCallback> errorCallback)
    5353{
    54     // FIXME: to be implemented.
    55     ASSERT_NOT_REACHED();
     54    m_fileSystem->getFile(this, path, flags, successCallback, errorCallback);
    5655}
    5756
    58 void DirectoryEntry::getDirectory(const String&, PassRefPtr<Flags>, PassRefPtr<EntryCallback>, PassRefPtr<ErrorCallback>)
     57void DirectoryEntry::getDirectory(const String& path, PassRefPtr<Flags> flags, PassRefPtr<EntryCallback> successCallback, PassRefPtr<ErrorCallback> errorCallback)
    5958{
    60     // FIXME: to be implemented.
    61     ASSERT_NOT_REACHED();
     59    m_fileSystem->getDirectory(this, path, flags, successCallback, errorCallback);
    6260}
    6361
  • trunk/WebCore/storage/DirectoryEntry.h

    r65474 r66407  
    4848class DirectoryEntry : public Entry {
    4949public:
    50     static PassRefPtr<DirectoryEntry> create(PassRefPtr<DOMFileSystem> fileSystem, const String& fullPath)
     50    static PassRefPtr<DirectoryEntry> create(DOMFileSystem* fileSystem, const String& fullPath)
    5151    {
    5252        return adoptRef(new DirectoryEntry(fileSystem, fullPath));
     
    5959
    6060private:
    61     DirectoryEntry(PassRefPtr<DOMFileSystem> fileSystem, const String& fullPath);
     61    DirectoryEntry(DOMFileSystem* fileSystem, const String& fullPath);
    6262};
    6363
  • trunk/WebCore/storage/DirectoryReader.cpp

    r65474 r66407  
    4040namespace WebCore {
    4141
    42 DirectoryReader::DirectoryReader(PassRefPtr<DOMFileSystem> fileSystem, const String& path)
     42DirectoryReader::DirectoryReader(PassRefPtr<DOMFileSystem> fileSystem, const String& fullPath)
    4343    : m_fileSystem(fileSystem)
    44     , m_path(path)
     44    , m_fullPath(fullPath)
    4545{
    4646}
    4747
    48 void DirectoryReader::readEntries(PassRefPtr<EntriesCallback>, PassRefPtr<ErrorCallback>)
     48void DirectoryReader::readEntries(PassRefPtr<EntriesCallback> entriesCallback, PassRefPtr<ErrorCallback> errorCallback)
    4949{
    50     // FIXME: to be implemented.
    51     ASSERT_NOT_REACHED();
     50    m_fileSystem->readDirectory(m_fullPath, entriesCallback, errorCallback);
    5251}
    5352
  • trunk/WebCore/storage/DirectoryReader.h

    r65474 r66407  
    5757
    5858    RefPtr<DOMFileSystem> m_fileSystem;
    59     String m_path;
     59    String m_fullPath;
    6060};
    6161
  • trunk/WebCore/storage/Entry.cpp

    r65474 r66407  
    3333#if ENABLE(FILE_SYSTEM)
    3434
     35#include "DOMFilePath.h"
    3536#include "DOMFileSystem.h"
    3637#include "EntryCallback.h"
    3738#include "ErrorCallback.h"
     39#include "FileError.h"
    3840#include "MetadataCallback.h"
    3941#include "VoidCallback.h"
     
    4143namespace WebCore {
    4244
    43 Entry::Entry(PassRefPtr<DOMFileSystem> fileSystem, const String& fullPath)
     45Entry::Entry(DOMFileSystem* fileSystem, const String& fullPath)
    4446    : m_fileSystem(fileSystem)
    4547    , m_fullPath(fullPath)
     
    5254}
    5355
    54 void Entry::getMetadata(PassRefPtr<MetadataCallback>, PassRefPtr<ErrorCallback>)
     56void Entry::getMetadata(PassRefPtr<MetadataCallback> successCallback, PassRefPtr<ErrorCallback> errorCallback)
    5557{
    56     // FIXME: to be implemented.
    57     ASSERT_NOT_REACHED();
     58    m_fileSystem->getMetadata(this, successCallback, errorCallback);
    5859}
    5960
    60 void Entry::moveTo(PassRefPtr<Entry>, const String&, PassRefPtr<EntryCallback>, PassRefPtr<ErrorCallback>)
     61void Entry::moveTo(PassRefPtr<Entry> parent, const String& name, PassRefPtr<EntryCallback> successCallback, PassRefPtr<ErrorCallback> errorCallback) const
    6162{
    62     // FIXME: to be implemented.
    63     ASSERT_NOT_REACHED();
     63    m_fileSystem->move(this, parent, name, successCallback, errorCallback);
    6464}
    6565
    66 void Entry::copyTo(PassRefPtr<Entry>, const String&, PassRefPtr<EntryCallback>, PassRefPtr<ErrorCallback>)
     66void Entry::copyTo(PassRefPtr<Entry> parent, const String& name, PassRefPtr<EntryCallback> successCallback, PassRefPtr<ErrorCallback> errorCallback) const
    6767{
    68     // FIXME: to be implemented.
    69     ASSERT_NOT_REACHED();
     68    m_fileSystem->copy(this, parent, name, successCallback, errorCallback);
    7069}
    7170
    72 void Entry::remove(PassRefPtr<VoidCallback>, PassRefPtr<ErrorCallback>)
     71void Entry::remove(PassRefPtr<VoidCallback> successCallback, PassRefPtr<ErrorCallback> errorCallback) const
    7372{
    74     // FIXME: to be implemented.
    75     ASSERT_NOT_REACHED();
     73    m_fileSystem->remove(this, successCallback, errorCallback);
    7674}
    7775
    78 void Entry::getParent(PassRefPtr<EntryCallback>, PassRefPtr<ErrorCallback>)
     76void Entry::getParent(PassRefPtr<EntryCallback> successCallback, PassRefPtr<ErrorCallback> errorCallback) const
    7977{
    80     // FIXME: to be implemented.
    81     ASSERT_NOT_REACHED();
     78    m_fileSystem->getParent(this, successCallback, errorCallback);
    8279}
    8380
  • trunk/WebCore/storage/Entry.h

    r65474 r66407  
    5555    const String& name() const { return m_name; }
    5656
    57     DOMFileSystem* filesystem() const { return m_fileSystem.get(); }
     57    DOMFileSystem* filesystem() const { return m_fileSystem; }
    5858
    5959    virtual void getMetadata(PassRefPtr<MetadataCallback> successCallback = 0, PassRefPtr<ErrorCallback> errorCallback = 0);
    60 
    61     virtual void moveTo(PassRefPtr<Entry> parent, const String& name = String(), PassRefPtr<EntryCallback> successCallback = 0, PassRefPtr<ErrorCallback> errorCallback = 0);
    62     virtual void copyTo(PassRefPtr<Entry> parent, const String& name = String(), PassRefPtr<EntryCallback> successCallback = 0, PassRefPtr<ErrorCallback> errorCallback = 0);
    63     virtual void remove(PassRefPtr<VoidCallback> successCallback = 0, PassRefPtr<ErrorCallback> errorCallback = 0);
    64     virtual void getParent(PassRefPtr<EntryCallback> successCallback = 0, PassRefPtr<ErrorCallback> errorCallback = 0);
     60    virtual void moveTo(PassRefPtr<Entry> parent, const String& name = String(), PassRefPtr<EntryCallback> successCallback = 0, PassRefPtr<ErrorCallback> errorCallback = 0) const;
     61    virtual void copyTo(PassRefPtr<Entry> parent, const String& name = String(), PassRefPtr<EntryCallback> successCallback = 0, PassRefPtr<ErrorCallback> errorCallback = 0) const;
     62    virtual void remove(PassRefPtr<VoidCallback> successCallback = 0, PassRefPtr<ErrorCallback> errorCallback = 0) const;
     63    virtual void getParent(PassRefPtr<EntryCallback> successCallback = 0, PassRefPtr<ErrorCallback> errorCallback = 0) const;
    6564
    6665    virtual String toURI(const String& mimeType = String());
    6766
    6867protected:
    69     Entry(PassRefPtr<DOMFileSystem> fileSystem, const String& fullPath);
     68    Entry(DOMFileSystem* fileSystem, const String& fullPath);
    7069
    71     RefPtr<DOMFileSystem> m_fileSystem;
    72     String m_fullPath; // virtual path
     70    DOMFileSystem* m_fileSystem;
     71    String m_fullPath;
    7372    String m_name;
    7473};
  • trunk/WebCore/storage/FileEntry.cpp

    r65474 r66407  
    3636namespace WebCore {
    3737
    38 FileEntry::FileEntry(PassRefPtr<DOMFileSystem> fileSystem, const String& fullPath)
     38FileEntry::FileEntry(DOMFileSystem* fileSystem, const String& fullPath)
    3939    : Entry(fileSystem, fullPath)
    4040{
  • trunk/WebCore/storage/FileEntry.h

    r65474 r66407  
    3535
    3636#include "Entry.h"
    37 #include "PlatformString.h"
    38 #include <wtf/PassRefPtr.h>
    39 #include <wtf/RefCounted.h>
    4037
    4138namespace WebCore {
     
    4542class FileEntry : public Entry {
    4643public:
    47     static PassRefPtr<FileEntry> create(PassRefPtr<DOMFileSystem> fileSystem, const String& fullPath)
     44    static PassRefPtr<FileEntry> create(DOMFileSystem* fileSystem, const String& fullPath)
    4845    {
    4946        return adoptRef(new FileEntry(fileSystem, fullPath));
     
    5249
    5350private:
    54     FileEntry(PassRefPtr<DOMFileSystem> fileSystem, const String& fullPath);
     51    FileEntry(DOMFileSystem* fileSystem, const String& fullPath);
    5552};
    5653
  • trunk/WebCore/storage/LocalFileSystem.cpp

    r66255 r66407  
    3838#if ENABLE(FILE_SYSTEM)
    3939
    40 #include "DOMWindow.h"
     40#include "CrossThreadTask.h"
     41#include "DOMFileSystem.h"
    4142#include "ErrorCallback.h"
    4243#include "ExceptionCode.h"
     
    5556}
    5657
     58static void openFileSystem(ScriptExecutionContext*, const String& basePath, const String& identifier, AsyncFileSystem::Type type, PassOwnPtr<FileSystemCallbacks> callbacks)
     59{
     60    AsyncFileSystem::openFileSystem(basePath, identifier, type, callbacks);
     61}
     62
    5763void LocalFileSystem::requestFileSystem(ScriptExecutionContext* context, AsyncFileSystem::Type type, long long, PassRefPtr<FileSystemCallback> successCallback, PassRefPtr<ErrorCallback> errorCallback)
    5864{
    5965    if (type != AsyncFileSystem::Temporary && type != AsyncFileSystem::Persistent) {
    60         errorCallback->handleEvent(FileError::create(INVALID_MODIFICATION_ERR).get());
     66        DOMFileSystem::scheduleCallback(context, errorCallback, FileError::create(INVALID_MODIFICATION_ERR));
    6167        return;
    6268    }
    6369
    64     AsyncFileSystem::openFileSystem(m_basePath, context->securityOrigin()->databaseIdentifier(), type, new FileSystemCallbacks(successCallback, errorCallback, context));
     70    // AsyncFileSystem::openFileSystem calls callbacks synchronously, so the method needs to be called asynchronously.
     71    context->postTask(createCallbackTask(&openFileSystem, m_basePath, context->securityOrigin()->databaseIdentifier(), type, new FileSystemCallbacks(successCallback, errorCallback, context)));
    6572}
    6673
  • trunk/WebKit/chromium/ChangeLog

    r66376 r66407  
     12010-08-30  Kinuko Yasuda  <kinuko@chromium.osrc>
     2
     3        Reviewed by Darin Fisher.
     4
     5        Add DOMFileSystem implementation to support Entry manipulation operations
     6        https://bugs.webkit.org/show_bug.cgi?id=44732
     7
     8        Fixed virtual-path / platform-path conversion timing. (The conversion needs to be done before calling AsyncFileSystem methods to support cross-filesystem operations.)
     9
     10        * src/AsyncFileSystemChromium.cpp:
     11        (WebCore::AsyncFileSystemChromium::move):
     12        (WebCore::AsyncFileSystemChromium::copy):
     13        (WebCore::AsyncFileSystemChromium::remove):
     14        (WebCore::AsyncFileSystemChromium::readMetadata):
     15        (WebCore::AsyncFileSystemChromium::createFile):
     16        (WebCore::AsyncFileSystemChromium::createDirectory):
     17        (WebCore::AsyncFileSystemChromium::fileExists):
     18        (WebCore::AsyncFileSystemChromium::directoryExists):
     19        (WebCore::AsyncFileSystemChromium::readDirectory):
     20
    1212010-08-30  Sheriff Bot  <webkit.review.bot@gmail.com>
    222
  • trunk/WebKit/chromium/src/AsyncFileSystemChromium.cpp

    r66280 r66407  
    5757void AsyncFileSystemChromium::move(const String& srcPath, const String& destPath, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
    5858{
    59     m_webFileSystem->move(virtualToPlatformPath(srcPath), virtualToPlatformPath(destPath), new WebKit::WebFileSystemCallbacksImpl(callbacks));
     59    m_webFileSystem->move(srcPath, destPath, new WebKit::WebFileSystemCallbacksImpl(callbacks));
    6060}
    6161
    6262void AsyncFileSystemChromium::copy(const String& srcPath, const String& destPath, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
    6363{
    64     m_webFileSystem->copy(virtualToPlatformPath(srcPath), virtualToPlatformPath(destPath), new WebKit::WebFileSystemCallbacksImpl(callbacks));
     64    m_webFileSystem->copy(srcPath, destPath, new WebKit::WebFileSystemCallbacksImpl(callbacks));
    6565}
    6666
    6767void AsyncFileSystemChromium::remove(const String& path, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
    6868{
    69     m_webFileSystem->remove(virtualToPlatformPath(path), new WebKit::WebFileSystemCallbacksImpl(callbacks));
     69    m_webFileSystem->remove(path, new WebKit::WebFileSystemCallbacksImpl(callbacks));
    7070}
    7171
    7272void AsyncFileSystemChromium::readMetadata(const String& path, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
    7373{
    74     m_webFileSystem->readMetadata(virtualToPlatformPath(path), new WebKit::WebFileSystemCallbacksImpl(callbacks));
     74    m_webFileSystem->readMetadata(path, new WebKit::WebFileSystemCallbacksImpl(callbacks));
    7575}
    7676
    7777void AsyncFileSystemChromium::createFile(const String& path, bool exclusive, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
    7878{
    79     m_webFileSystem->createFile(virtualToPlatformPath(path), exclusive, new WebKit::WebFileSystemCallbacksImpl(callbacks));
     79    m_webFileSystem->createFile(path, exclusive, new WebKit::WebFileSystemCallbacksImpl(callbacks));
    8080}
    8181
    8282void AsyncFileSystemChromium::createDirectory(const String& path, bool exclusive, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
    8383{
    84     m_webFileSystem->createDirectory(virtualToPlatformPath(path), exclusive, new WebKit::WebFileSystemCallbacksImpl(callbacks));
     84    m_webFileSystem->createDirectory(path, exclusive, new WebKit::WebFileSystemCallbacksImpl(callbacks));
    8585}
    8686
    8787void AsyncFileSystemChromium::fileExists(const String& path, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
    8888{
    89     m_webFileSystem->fileExists(virtualToPlatformPath(path), new WebKit::WebFileSystemCallbacksImpl(callbacks));
     89    m_webFileSystem->fileExists(path, new WebKit::WebFileSystemCallbacksImpl(callbacks));
    9090}
    9191
    9292void AsyncFileSystemChromium::directoryExists(const String& path, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
    9393{
    94     m_webFileSystem->directoryExists(virtualToPlatformPath(path), new WebKit::WebFileSystemCallbacksImpl(callbacks));
     94    m_webFileSystem->directoryExists(path, new WebKit::WebFileSystemCallbacksImpl(callbacks));
    9595}
    9696
    9797void AsyncFileSystemChromium::readDirectory(const String& path, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
    9898{
    99     m_webFileSystem->readDirectory(virtualToPlatformPath(path), new WebKit::WebFileSystemCallbacksImpl(callbacks));
     99    m_webFileSystem->readDirectory(path, new WebKit::WebFileSystemCallbacksImpl(callbacks));
    100100}
    101101
Note: See TracChangeset for help on using the changeset viewer.