Changeset 69249 in webkit


Ignore:
Timestamp:
Oct 6, 2010 4:08:50 PM (14 years ago)
Author:
kinuko@chromium.org
Message:

2010-10-06 Kinuko Yasuda <kinuko@chromium.org>

Reviewed by David Levin.

Add FileSystemSync implementation for Worker
https://bugs.webkit.org/show_bug.cgi?id=47044

  • src/LocalFileSystemChromium.cpp: (WebCore::LocalFileSystem::requestFileSystem): Added a new parameter for synchronous mode.
  • src/WebFileSystemCallbacksImpl.cpp: (WebKit::WebFileSystemCallbacksImpl::WebFileSystemCallbacksImpl): Added a parameter for synchronous mode. (WebKit::WebFileSystemCallbacksImpl::didOpenFileSystem): Changed to creates WorkerAsyncFileSystemChromium with synchronous flag.
  • src/WebFileSystemCallbacksImpl.h:
  • src/WebWorkerBase.cpp: (WebKit::WebWorkerBase::openFileSystem): Added a parameter for synchronous mode.
  • src/WebWorkerBase.h:
  • src/WorkerAsyncFileSystemChromium.cpp: (WebCore::WorkerAsyncFileSystemChromium::WorkerAsyncFileSystemChromium): (WebCore::WorkerAsyncFileSystemChromium::waitForOperationToComplete): Added. (WebCore::WorkerAsyncFileSystemChromium::move): (WebCore::WorkerAsyncFileSystemChromium::copy): (WebCore::WorkerAsyncFileSystemChromium::remove): (WebCore::WorkerAsyncFileSystemChromium::readMetadata): (WebCore::WorkerAsyncFileSystemChromium::createFile): (WebCore::WorkerAsyncFileSystemChromium::createDirectory): (WebCore::WorkerAsyncFileSystemChromium::fileExists): (WebCore::WorkerAsyncFileSystemChromium::directoryExists): (WebCore::WorkerAsyncFileSystemChromium::readDirectory): (WebCore::WorkerAsyncFileSystemChromium::createWorkerFileSystemCallbacksBridge): Updated to store the created bridge in a member variable so that we can call bridge->stop() later when the RunLoop is terminating.
  • src/WorkerAsyncFileSystemChromium.h: (WebCore::WorkerAsyncFileSystemChromium::create): Added a new parameter for synchronous mode.

2010-10-06 Andrei Popescu <andreip@google.com>

Reviewed by Jeremy Orlow.

IDBDatabase and IDBObjectStore metadata is not recovered correctly when the setVersion transactions aborts.
https://bugs.webkit.org/show_bug.cgi?id=47245

Recover metadata properly by adding abort tasks that
are run when a transaction aborts.


  • storage/IDBDatabase.cpp: (WebCore::IDBDatabase::createObjectStore): (WebCore::IDBDatabase::removeObjectStore):
  • storage/IDBDatabaseBackendImpl.cpp: (WebCore::IDBDatabaseBackendImpl::createObjectStore): (WebCore::IDBDatabaseBackendImpl::removeObjectStore): (WebCore::IDBDatabaseBackendImpl::setVersion): (WebCore::IDBDatabaseBackendImpl::removeObjectStoreFromMap): (WebCore::IDBDatabaseBackendImpl::addObjectStoreToMap): (WebCore::IDBDatabaseBackendImpl::resetVersion):
  • storage/IDBDatabaseBackendImpl.h:
  • storage/IDBObjectStoreBackendImpl.cpp: (WebCore::IDBObjectStoreBackendImpl::createIndex): (WebCore::IDBObjectStoreBackendImpl::removeIndex): (WebCore::IDBObjectStoreBackendImpl::removeIndexFromMap): (WebCore::IDBObjectStoreBackendImpl::addIndexToMap):
  • storage/IDBObjectStoreBackendImpl.h:
  • storage/IDBTransactionBackendImpl.cpp: (WebCore::IDBTransactionBackendImpl::scheduleTask): (WebCore::IDBTransactionBackendImpl::abort):
  • storage/IDBTransactionBackendImpl.h:
  • storage/IDBTransactionBackendInterface.h:
  • storage/IDBTransactionCoordinator.h:

2010-10-06 Kinuko Yasuda <kinuko@chromium.org>

Reviewed by David Levin.

Add FileSystemSync implementation for Worker
https://bugs.webkit.org/show_bug.cgi?id=47044

  • fast/filesystem/async-operations.html: Added.
  • fast/filesystem/resources/async-operations.js: Added.
  • fast/filesystem/resources/fs-worker-test-pre.js:
  • fast/filesystem/resources/sync-operations.js: Added.
  • fast/filesystem/script-tests/flags-passing.js:
  • fast/filesystem/workers/async-operations-expected.txt: Added.
  • fast/filesystem/workers/async-operations.html: Added.
  • fast/filesystem/workers/simple-persistent-sync-expected.txt:
  • fast/filesystem/workers/simple-temporary-sync-expected.txt:
  • fast/filesystem/workers/sync-operations-expected.txt: Added.
  • fast/filesystem/workers/sync-operations.html: Added.
Location:
trunk
Files:
9 added
1 deleted
53 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r69247 r69249  
     12010-10-06  Kinuko Yasuda  <kinuko@chromium.org>
     2
     3        Reviewed by David Levin.
     4
     5        Add FileSystemSync implementation for Worker
     6        https://bugs.webkit.org/show_bug.cgi?id=47044
     7
     8        * fast/filesystem/async-operations.html: Added.
     9        * fast/filesystem/resources/async-operations.js: Added.
     10        * fast/filesystem/resources/fs-worker-test-pre.js:
     11        * fast/filesystem/resources/sync-operations.js: Added.
     12        * fast/filesystem/script-tests/flags-passing.js:
     13        * fast/filesystem/workers/async-operations-expected.txt: Added.
     14        * fast/filesystem/workers/async-operations.html: Added.
     15        * fast/filesystem/workers/simple-persistent-sync-expected.txt:
     16        * fast/filesystem/workers/simple-temporary-sync-expected.txt:
     17        * fast/filesystem/workers/sync-operations-expected.txt: Added.
     18        * fast/filesystem/workers/sync-operations.html: Added.
     19
    1202010-10-06  Andrei Popescu  <andreip@google.com>
    221
  • trunk/LayoutTests/fast/filesystem/resources/fs-test-util.js

    r68735 r69249  
     1function bindCallback(obj, callback, arg1, arg2, arg3)
     2{
     3    return function(arg) {
     4        if (arg == undefined)
     5            callback.apply(obj, [arg1, arg2, arg3]);
     6        else
     7            callback.apply(obj, [arg, arg1, arg2, arg3]);
     8    };
     9}
     10
    111// Usage:
    212//   var helper = new JoinHelper;
     
    5666        };
    5767
    58         this.bind = function(callback, arg1, arg2, arg3)
    59         {
    60             var obj = this;
    61             return function(arg) {
    62                 if (arg == undefined)
    63                     callback.apply(obj, [arg1, arg2, arg3]);
    64                 else
    65                     callback.apply(obj, [arg, arg1, arg2, arg3]);
    66             };
    67         };
    68 
    6968        this.removeDirectory = function(directory, parentDirectory)
    7069        {
    7170            if (directory.fullPath != '/') {
    7271                // Ok to remove the parent directory.
    73                 directory.remove(this.bind(this.entryRemovedCallback, parentDirectory, directory), this.bind(this.ErrorCallback));
     72                directory.remove(bindCallback(this, this.entryRemovedCallback, parentDirectory, directory), bindCallback(this, this.ErrorCallback));
    7473            } else
    7574                delete this.removeDirMap[directory.fullPath];
     
    9897                else {
    9998                    var entry = entries[i];
    100                     entry.remove(this.bind(this.entryRemovedCallback, directory, entry), this.bind(this.errorCallback));
     99                    entry.remove(bindCallback(this, this.entryRemovedCallback, directory, entry), bindCallback(this, this.errorCallback));
    101100                }
    102101            }
    103102            if (entries.length) {
    104                 this.removeDirMap[directory.fullPath].reader.readEntries(this.bind(this.removeRecursivelyCallback, directory), this.bind(this.errorCallback));
     103                this.removeDirMap[directory.fullPath].reader.readEntries(bindCallback(this, this.removeRecursivelyCallback, directory), bindCallback(this, this.errorCallback));
    105104            } else {
    106105                var dirInfo = this.removeDirMap[directory.fullPath];
     
    120119                reader: directoryReader,
    121120            };
    122             directoryReader.readEntries(this.bind(this.removeRecursivelyCallback, directory), this.bind(this.errorCallback));
     121            directoryReader.readEntries(bindCallback(this, this.removeRecursivelyCallback, directory), bindCallback(this, this.errorCallback));
    123122        };
    124123    };
  • trunk/LayoutTests/fast/filesystem/resources/fs-worker-common.js

    r69178 r69249  
    2828function shouldBeTrue(_a) { shouldBe(_a, "true"); }
    2929
     30function removeRecursivelySync(directory) {
     31    if (!directory)
     32        return;
     33    var reader = directory.createReader();
     34    do {
     35        var entries = reader.readEntries();
     36        for (var i = 0; i < entries.length; ++i) {
     37            if (entries[i].isDirectory)
     38                removeRecursivelySync(entries[i]);
     39            else
     40                entries[i].remove();
     41        }
     42    } while (entries.length);
     43    if (directory.fullPath != '/')
     44        directory.remove();
     45}
     46
    3047if (this.importScripts && !this.requestFileSystem) {
    3148    debug('This test requires FileSystem API.');
    3249    finishJSTest();
    3350}
    34 
    35 onmessage = function(event) {
    36     importScripts(event.data);
    37 }
  • trunk/LayoutTests/fast/filesystem/resources/fs-worker-test-pre.js

    r69178 r69249  
    1010{
    1111    debug('Starting worker: ' + testScriptURL);
    12     var worker = new Worker('../resources/fs-worker-common.js');
    13     worker.postMessage(testScriptURL);
     12    var worker = new Worker(testScriptURL);
    1413    worker.onmessage = function(event)
    1514    {
  • trunk/LayoutTests/fast/filesystem/resources/simple-persistent-sync.js

    r69178 r69249  
     1if (this.importScripts) {
     2    importScripts('../resources/fs-worker-common.js');
     3    importScripts('../resources/fs-test-util.js');
     4}
     5
    16description("requestFileSystemSync PERSISTENT test.");
    27
  • trunk/LayoutTests/fast/filesystem/resources/simple-persistent.js

    r69178 r69249  
     1if (this.importScripts) {
     2    importScripts('../resources/fs-worker-common.js');
     3    importScripts('../resources/fs-test-util.js');
     4}
     5
    16description("requestFileSystem PERSISTENT test.");
    27
  • trunk/LayoutTests/fast/filesystem/resources/simple-temporary-sync.js

    r69178 r69249  
     1if (this.importScripts) {
     2    importScripts('../resources/fs-worker-common.js');
     3    importScripts('../resources/fs-test-util.js');
     4}
     5
    16description("requestFileSystemSync TEMPORARY test.");
    27
  • trunk/LayoutTests/fast/filesystem/resources/simple-temporary.js

    r69178 r69249  
     1if (this.importScripts) {
     2    importScripts('../resources/fs-worker-common.js');
     3    importScripts('../resources/fs-test-util.js');
     4}
     5
    16description("requestFileSystem TEMPORARY test.");
    27
  • trunk/LayoutTests/fast/filesystem/script-tests/flags-passing.js

    r69178 r69249  
    9595
    9696if (window.requestFileSystem) {
     97    window.jsTestIsAsync = true;
    9798    requestFileSystem(window.TEMPORARY, 100, fileSystemCallback, errorCallback);
    98     window.jsTestIsAsync = true;
    9999} else
    100100    debug("This test requires FileSystem API support.");
  • trunk/LayoutTests/fast/filesystem/workers/simple-persistent-expected.txt

    r69178 r69249  
    33Starting worker: ../resources/simple-persistent.js
    44Description: requestFileSystem PERSISTENT test.
    5 Successfully obtained PERSISTENT FileSystem:file__0:Temporary
     5Successfully obtained PERSISTENT FileSystem:file__0:Persistent
    66PASS: fileSystem.name.length > 0 is true
    77PASS: fileSystem.root.fullPath is "/"
  • trunk/LayoutTests/fast/filesystem/workers/simple-persistent-sync-expected.txt

    r69178 r69249  
    33Starting worker: ../resources/simple-persistent-sync.js
    44Description: requestFileSystemSync PERSISTENT test.
    5 Got error from worker: Uncaught ReferenceError: requestFileSystemSync is not defined
     5Successfully obtained PERSISTENT FileSystem:file__0:Persistent
     6PASS: fileSystem.name.length > 0 is true
     7PASS: fileSystem.root.fullPath is "/"
     8DONE
    69
    710TEST COMPLETE
  • trunk/LayoutTests/fast/filesystem/workers/simple-temporary-sync-expected.txt

    r69178 r69249  
    33Starting worker: ../resources/simple-temporary-sync.js
    44Description: requestFileSystemSync TEMPORARY test.
    5 Got error from worker: Uncaught ReferenceError: requestFileSystemSync is not defined
     5Successfully obtained TEMPORARY FileSystem:file__0:Temporary
     6PASS: fileSystem.name.length > 0 is true
     7PASS: fileSystem.root.fullPath is "/"
     8DONE
    69
    710TEST COMPLETE
  • trunk/WebCore/ChangeLog

    r69247 r69249  
    926926        (WebCore::SVGFilter::maxImageSize):
    927927
    928 2010-10-06  Pavel Podivilov  <podivilov@chromium.org>
    929 
    930         Reviewed by Yury Semikhatsky.
    931 
    932         Web Inspector: add "Set Breakpoint" item to XHR resource context menu.
    933         https://bugs.webkit.org/show_bug.cgi?id=47085
    934 
    935         * English.lproj/localizedStrings.js:
    936         * inspector/front-end/ResourcesPanel.js:
    937         (WebInspector.ResourcesPanel.prototype._contextMenu):
    938 
    939 2010-10-05  Kinuko Yasuda  <kinuko@chromium.org>
    940 
    941         Reviewed by David Levin.
    942 
    943         Add idl and mock classes for FileSystemSync for FileSystem API
    944         https://bugs.webkit.org/show_bug.cgi?id=46405
    945 
    946         Added bunch of *Sync classes, plus refactored some classes:
    947         Added DOMFileSystemBase as a common base class for DOMFileSystem and
    948         DOMFileSystemSync.
    949         Added EntryBase as a common base class for Entry and EntrySync.
    950         Added DirectoryReaderBase as a common base class for DirectoryReader and
    951         DirectoryReaderSync.
    952 
    953         Test: fast/filesystem/workers/
    954 
    955         * CMakeLists.txt: Added new files.
    956         * DerivedSources.cpp: Added new files.
    957         * DerivedSources.make: Added new files.
    958         * GNUmakefile.am: Added new files.
    959         * WebCore.gypi: Added new files.
    960         * WebCore.pri: Added new files.
    961         * WebCore.pro: Added new files.
    962         * WebCore.vcproj/WebCore.vcproj: Added new files. Also removed the duplicated fileapi\FileEntry.cpp entry.
    963         * WebCore.xcodeproj/project.pbxproj: Added new files.
    964         * bindings/js/JSDirectoryEntrySyncCustom.cpp: Added.
    965         * bindings/js/JSEntrySyncCustom.cpp: Added.
    966         * bindings/v8/custom/V8DirectoryEntrySyncCustom.cpp: Added.
    967         * bindings/v8/custom/V8EntrySyncCustom.cpp: Added.
    968         * fileapi/DOMFileSystemBase.cpp: Added.
    969         * fileapi/DOMFileSystemBase.h: Added.
    970         * fileapi/DOMFileSystemSync.cpp: Added.
    971         * fileapi/DOMFileSystemSync.h: Added.
    972         * fileapi/DOMFileSystemSync.idl: Added.
    973         * fileapi/DirectoryEntrySync.cpp: Added.
    974         * fileapi/DirectoryEntrySync.h: Added.
    975         * fileapi/DirectoryEntrySync.idl: Added.
    976         * fileapi/DirectoryReaderBase.h: Added.
    977         * fileapi/DirectoryReaderSync.cpp: Added.
    978         * fileapi/DirectoryReaderSync.h: Added.
    979         * fileapi/DirectoryReaderSync.idl: Added.
    980         * fileapi/EntryArraySync.cpp: Added.
    981         * fileapi/EntryArraySync.h: Added.
    982         * fileapi/EntryArraySync.idl: Added.
    983         * fileapi/EntryBase.h: Added.
    984         * fileapi/EntrySync.cpp: Added.
    985         * fileapi/EntrySync.h: Added.
    986         * fileapi/EntrySync.idl: Added.
    987         * fileapi/FileEntrySync.cpp: Added.
    988         * fileapi/FileEntrySync.h: Added.
    989         * fileapi/FileEntrySync.idl: Added.
    990 
    991 2010-10-05  Kent Tamura  <tkent@chromium.org>
    992 
    993         Reviewed by Dimitri Glazkov.
    994 
    995         REGRESSION (r67166): "Placeholder" text remains in input box after 2nd focus()
    996         https://bugs.webkit.org/show_bug.cgi?id=45940
    997 
    998         Test: fast/forms/input-placeholder-focus-twice.html
    999 
    1000         * html/HTMLFormControlElement.h: Make supportsPlaceholder() public.
    1001         * rendering/RenderTextControlSingleLine.cpp:
    1002         (WebCore::RenderTextControlSingleLine::updateFromElement):
    1003          We always need to update the renderer value with the DOM value if
    1004          the element supports the placeholder feature.
    1005          Note: the placeholder feature and "unacceptable renderer value"
    1006          are exclusive.
    1007 
    1008 2010-10-05  Kyusun Kim  <maniagoon@company100.net>
    1009 
    1010         Reviewed by Kent Tamura.
    1011 
    1012         [BREWMP] Translate key code in PlatformKeyboardEvent with IKeysMapping
    1013         https://bugs.webkit.org/show_bug.cgi?id=47234
    1014 
    1015         Brew MP devices have a variey of key configurations and use modifiers to
    1016         input capital letters, symbols and special characters. Use IKeysMapping to translate key code.
    1017 
    1018         * platform/brew/PlatformKeyboardEventBrew.cpp:
    1019         (WebCore::PlatformKeyboardEvent::PlatformKeyboardEvent):
    1020 
    1021 2010-10-05  W. James MacLean  <wjmaclean@chromium.org>
    1022 
    1023         Reviewed by James Robinson.
    1024 
    1025         [chromium] Add mipmap support for ImageLayerChromium
    1026         https://bugs.webkit.org/show_bug.cgi?id=46493
    1027 
    1028         Mipmap behaviour can be tested with existing tests.
    1029         Tests in LayoutTests/compositing/images/ will detect if
    1030         mipmaps fail.
    1031 
    1032         * platform/graphics/chromium/ContentLayerChromium.cpp:
    1033         (WebCore::ContentLayerChromium::SharedValues::SharedValues):
    1034         (WebCore::isPowerOfTwo):
    1035         (WebCore::ContentLayerChromium::updateTextureRect):
    1036         * platform/graphics/chromium/ContentLayerChromium.h:
    1037         (WebCore::ContentLayerChromium::SharedValues::npotSupported):
    1038         * platform/graphics/chromium/ImageLayerChromium.cpp:
    1039         (WebCore::ImageLayerChromium::updateContents):
    1040 
    1041 2010-10-05  Adam Barth  <abarth@webkit.org>
    1042 
    1043         Reviewed by Darin Adler.
    1044 
    1045         Issue in treebuilder parsing related to table tags
    1046         https://bugs.webkit.org/show_bug.cgi?id=47190
    1047 
    1048         Update ASSERT to match the spec and our behavior.
    1049 
    1050         * html/parser/HTMLTreeBuilder.cpp:
    1051         (WebCore::HTMLTreeBuilder::processEndTagForInCell):
    1052 
    1053 2010-10-05  Victoria Kirst  <vrk@google.com>
    1054 
    1055         Reviewed by James Robinson.
    1056 
    1057         VideoLayerChromium releases old resources if the LayerRenderer changes.
    1058         https://bugs.webkit.org/show_bug.cgi?id=47030
    1059 
    1060         Refactored LayerChromium to have a virtual cleanupResources() method
    1061         that will release textures/other context-dependent resources when a
    1062         LayerRenderer changes. ContentLayerChromium and VideoLayerChromium now
    1063         override this method to perform cleanup.
    1064 
    1065         * platform/graphics/chromium/ContentLayerChromium.cpp:
    1066         * platform/graphics/chromium/ContentLayerChromium.h:
    1067         * platform/graphics/chromium/LayerChromium.cpp:
    1068         (WebCore::LayerChromium::setLayerRenderer):
    1069         * platform/graphics/chromium/LayerChromium.h:
    1070         (WebCore::LayerChromium::cleanupResources):
    1071         * platform/graphics/chromium/VideoLayerChromium.cpp:
    1072         (WebCore::VideoLayerChromium::~VideoLayerChromium):
    1073         (WebCore::VideoLayerChromium::cleanupResources):
    1074         * platform/graphics/chromium/VideoLayerChromium.h:
    1075 
    10769282010-10-05  Kinuko Yasuda  <kinuko@chromium.org>
    1077929
     
    1085937        * fileapi/FileEntry.cpp:
    1086938        (WebCore::FileEntry::file): Implemented.
    1087 
    1088 2010-09-29  Alpha Lam  <hclam@chromium.org>
    1089 
    1090         Reviewed by James Robinson.
    1091 
    1092         Render textures in video frame directly.
    1093         https://bugs.webkit.org/show_bug.cgi?id=46765
    1094 
    1095         Render textures in VideoLayerChromium directly if the video frame type
    1096         is GL texture. In the future VideoLayerChromium will not allocate
    1097         textures and perform textures upload as those operations will be done
    1098         in Chromium to minimize memory copy. This patch will help moving toward
    1099         this direction and facilitate hardware video decoding.
    1100 
    1101         * platform/graphics/chromium/VideoFrameChromium.h:
    1102         * platform/graphics/chromium/VideoFrameProvider.h:
    1103         (WebCore::VideoFrameProvider::~VideoFrameProvider):
    1104         * platform/graphics/chromium/VideoLayerChromium.cpp:
    1105         (WebCore::VideoLayerChromium::VideoLayerChromium):
    1106         (WebCore::VideoLayerChromium::~VideoLayerChromium):
    1107         (WebCore::VideoLayerChromium::updateContents):
    1108         (WebCore::VideoLayerChromium::draw):
    1109         (WebCore::VideoLayerChromium::releaseCurrentFrame):
    1110         (WebCore::VideoLayerChromium::resetFrameParameters):
    1111         (WebCore::VideoLayerChromium::saveCurrentFrame):
    1112         * platform/graphics/chromium/VideoLayerChromium.h:
    1113         (WebCore::VideoLayerChromium::SharedValues::initialized):
    1114 
    1115 2010-10-05  Fady Samuel  <fsamuel@chromium.org>
    1116 
    1117         Reviewed by Darin Adler.
    1118 
    1119         REGRESSION (r65539): One pixel white gaps when scrolling Trac changeset pages
    1120         https://bugs.webkit.org/show_bug.cgi?id=45131
    1121 
    1122         When border-collapse: separate property is set on the table, paintObject
    1123         may skip repainting cells, if the dirty region only touches one row/col of pixels.
    1124 
    1125         Test: fast/table/simple_paint_separate_borders.html
    1126 
    1127         * rendering/RenderTableSection.cpp:
    1128         (WebCore::RenderTableSection::paintObject): 
    1129             Don't subtract one from the right and bottom of the dirty paint rect.
    1130 
    1131 2010-10-05  Sanjeev Radhakrishnan  <sanjeevr@chromium.org>
    1132 
    1133         Reviewed by Darin Fisher.
    1134 
    1135         PluginDocument now holds on to the created plugin node so that the pluginNode() and pluginWidget() methods can return the correct node.
    1136         https://bugs.webkit.org/show_bug.cgi?id=47129
    1137 
    1138         * html/PluginDocument.cpp:
    1139         (WebCore::PluginDocumentParser::createDocumentStructure):
    1140         (WebCore::PluginDocument::pluginWidget):
    1141         (WebCore::PluginDocument::pluginNode):
    1142         * html/PluginDocument.h:
    1143         (WebCore::PluginDocument::setPluginNode):
    1144939
    11459402010-10-05  Andreas Kling  <kling@webkit.org>
  • trunk/WebCore/WebCore.gypi

    r69183 r69249  
    15211521            'fileapi/Metadata.h',
    15221522            'fileapi/MetadataCallback.h',
     1523            'fileapi/SyncCallbackHelper.h',
    15231524            'fileapi/ThreadableBlobRegistry.cpp',
    15241525            'fileapi/ThreadableBlobRegistry.h',
  • trunk/WebCore/bindings/generic/RuntimeEnabledFeatures.h

    r69099 r69249  
    151151    static bool fileSystemEnabled();
    152152    static void setFileSystemEnabled(bool isEnabled) { isFileSystemEnabled = isEnabled; }
    153     static bool requestFileSystemEnabled() { return isFileSystemEnabled; }
    154153#endif
    155154
  • trunk/WebCore/fileapi/DOMFileSystem.cpp

    r69178 r69249  
    3737#include "DOMFilePath.h"
    3838#include "DirectoryEntry.h"
    39 #include "EntriesCallback.h"
    40 #include "Entry.h"
    41 #include "EntryArray.h"
    42 #include "EntryCallback.h"
    4339#include "ErrorCallback.h"
    4440#include "FileEntry.h"
    45 #include "FileError.h"
    4641#include "FileSystemCallbacks.h"
    4742#include "FileWriter.h"
     
    4944#include "MetadataCallback.h"
    5045#include "ScriptExecutionContext.h"
    51 #include "VoidCallback.h"
    5246#include <wtf/OwnPtr.h>
    5347
     
    8175}
    8276
    83 void 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, MetadataCallbacks::create(successCallback, errorCallback));
    87 }
    88 
    89 static 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 
    110 void 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, EntryCallbacks::create(successCallback, errorCallback, this, destPath, src->isDirectory()));
    126 }
    127 
    128 void 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, EntryCallbacks::create(successCallback, errorCallback, this, destPath, src->isDirectory()));
    144 }
    145 
    146 void 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, VoidCallbacks::create(successCallback, errorCallback));
    151 }
    152 
    153 void 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, EntryCallbacks::create(successCallback, errorCallback, this, path, true));
    159 }
    160 
    161 void 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 = EntryCallbacks::create(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 
    181 void 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 = EntryCallbacks::create(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 
    20177void DOMFileSystem::createWriter(const FileEntry* file, PassRefPtr<FileWriterCallback> successCallback, PassRefPtr<ErrorCallback> errorCallback)
    20278{
     
    21086}
    21187
    212 void DOMFileSystem::readDirectory(DirectoryReader* reader, const String& path, PassRefPtr<EntriesCallback> successCallback, PassRefPtr<ErrorCallback> errorCallback)
    213 {
    214     ASSERT(DOMFilePath::isAbsolute(path));
    215     String platformPath = m_asyncFileSystem->virtualToPlatformPath(path);
    216     m_asyncFileSystem->readDirectory(platformPath, EntriesCallbacks::create(successCallback, errorCallback, reader, path));
    217 }
    218 
    21988} // namespace
    22089
  • trunk/WebCore/fileapi/DOMFileSystem.h

    r69178 r69249  
    3535
    3636#include "ActiveDOMObject.h"
    37 #include "AsyncFileSystem.h"
    3837#include "DOMFileSystemBase.h"
    39 #include "Flags.h"
    40 #include "PlatformString.h"
    4138#include "ScriptExecutionContext.h"
    42 #include <wtf/PassRefPtr.h>
    43 #include <wtf/RefCounted.h>
    4439
    4540namespace WebCore {
    4641
    4742class DirectoryEntry;
    48 class DirectoryReader;
    49 class Entry;
    50 class EntryCallback;
    51 class EntriesCallback;
    52 class ErrorCallback;
    5343class FileEntry;
    5444class FileWriterCallback;
    55 class MetadataCallback;
    56 class VoidCallback;
    5745
    5846class DOMFileSystem : public DOMFileSystemBase, public ActiveDOMObject {
     
    7058    virtual void contextDestroyed();
    7159
    72     // Actual FileSystem API implementations.  All the validity checks on virtual paths are done at DOMFileSystem level.
    73     void getMetadata(const Entry* entry, PassRefPtr<MetadataCallback> successCallback, PassRefPtr<ErrorCallback> errorCallback);
    74     void move(const Entry* src, PassRefPtr<Entry> parent, const String& name, PassRefPtr<EntryCallback>, PassRefPtr<ErrorCallback>);
    75     void copy(const Entry* src, PassRefPtr<Entry> parent, const String& name, PassRefPtr<EntryCallback>, PassRefPtr<ErrorCallback>);
    76     void remove(const Entry* entry, PassRefPtr<VoidCallback>, PassRefPtr<ErrorCallback>);
    77     void getParent(const Entry* entry, PassRefPtr<EntryCallback>, PassRefPtr<ErrorCallback>);
    78     void getFile(const Entry* base, const String& path, PassRefPtr<Flags>, PassRefPtr<EntryCallback>, PassRefPtr<ErrorCallback>);
    79     void getDirectory(const Entry* base, const String& path, PassRefPtr<Flags>, PassRefPtr<EntryCallback>, PassRefPtr<ErrorCallback>);
    80     void readDirectory(DirectoryReader* reader, const String& path, PassRefPtr<EntriesCallback>, PassRefPtr<ErrorCallback>);
    8160    void createWriter(const FileEntry* file, PassRefPtr<FileWriterCallback>, PassRefPtr<ErrorCallback>);
    8261
     
    9675
    9776    // A helper template to schedule a callback task.
    98     // FIXME: move this to a more generic place.
    9977    template <typename CB, typename CBArg>
    10078    class DispatchCallbackTask : public ScriptExecutionContext::Task {
     
    12199{
    122100    ASSERT(scriptExecutionContext->isContextThread());
     101    ASSERT(callback);
    123102    scriptExecutionContext->postTask(new DispatchCallbackTask<CB, CBArg>(callback, arg));
    124103}
  • trunk/WebCore/fileapi/DOMFileSystemBase.cpp

    r69178 r69249  
    3535
    3636#include "DOMFilePath.h"
     37#include "DirectoryEntry.h"
     38#include "EntriesCallback.h"
     39#include "EntryArray.h"
     40#include "EntryBase.h"
     41#include "EntryCallback.h"
     42#include "ErrorCallback.h"
     43#include "FileError.h"
     44#include "FileSystemCallbacks.h"
     45#include "MetadataCallback.h"
     46#include "VoidCallback.h"
    3747#include <wtf/OwnPtr.h>
    3848
     
    4959}
    5060
     61bool DOMFileSystemBase::getMetadata(const EntryBase* entry, PassRefPtr<MetadataCallback> successCallback, PassRefPtr<ErrorCallback> errorCallback)
     62{
     63    String platformPath = m_asyncFileSystem->virtualToPlatformPath(entry->fullPath());
     64    m_asyncFileSystem->readMetadata(platformPath, MetadataCallbacks::create(successCallback, errorCallback));
     65    return true;
     66}
     67
     68static bool checkValidityForForCopyOrMove(const EntryBase* source, EntryBase* parent, const String& newName)
     69{
     70    ASSERT(source);
     71
     72    if (!parent || !parent->isDirectory())
     73        return false;
     74
     75    if (!newName.isEmpty() && !DOMFilePath::isValidName(newName))
     76        return false;
     77
     78    // It is an error to try to copy or move an entry inside itself at any depth if it is a directory.
     79    if (source->isDirectory() && DOMFilePath::isParentOf(source->fullPath(), parent->fullPath()))
     80        return false;
     81
     82    // It is an error to copy or move an entry into its parent if a name different from its current one isn't provided.
     83    if ((newName.isEmpty() || source->name() == newName) && DOMFilePath::getDirectory(source->fullPath()) == parent->fullPath())
     84        return false;
     85
     86    return true;
     87}
     88
     89bool DOMFileSystemBase::move(const EntryBase* source, EntryBase* parent, const String& newName, PassRefPtr<EntryCallback> successCallback, PassRefPtr<ErrorCallback> errorCallback)
     90{
     91    if (!checkValidityForForCopyOrMove(source, parent, newName))
     92        return false;
     93
     94    String destinationPath = parent->fullPath();
     95    if (!newName.isEmpty())
     96        destinationPath = DOMFilePath::append(destinationPath, newName);
     97    else
     98        destinationPath = DOMFilePath::append(destinationPath, source->name());
     99
     100    String sourcePlatformPath = m_asyncFileSystem->virtualToPlatformPath(source->fullPath());
     101    String destinationPlatformPath = parent->filesystem()->asyncFileSystem()->virtualToPlatformPath(destinationPath);
     102    m_asyncFileSystem->move(sourcePlatformPath, destinationPlatformPath, EntryCallbacks::create(successCallback, errorCallback, this, destinationPath, source->isDirectory()));
     103    return true;
     104}
     105
     106bool DOMFileSystemBase::copy(const EntryBase* source, EntryBase* parent, const String& newName, PassRefPtr<EntryCallback> successCallback, PassRefPtr<ErrorCallback> errorCallback)
     107{
     108    if (!checkValidityForForCopyOrMove(source, parent, newName))
     109        return false;
     110
     111    String destinationPath = parent->fullPath();
     112    if (!newName.isEmpty())
     113        destinationPath = DOMFilePath::append(destinationPath, newName);
     114    else
     115        destinationPath = DOMFilePath::append(destinationPath, source->name());
     116
     117    String sourcePlatformPath = m_asyncFileSystem->virtualToPlatformPath(source->fullPath());
     118    String destinationPlatformPath = parent->filesystem()->asyncFileSystem()->virtualToPlatformPath(destinationPath);
     119    m_asyncFileSystem->copy(sourcePlatformPath, destinationPlatformPath, EntryCallbacks::create(successCallback, errorCallback, this, destinationPath, source->isDirectory()));
     120    return true;
     121}
     122
     123bool DOMFileSystemBase::remove(const EntryBase* entry, PassRefPtr<VoidCallback> successCallback, PassRefPtr<ErrorCallback> errorCallback)
     124{
     125    ASSERT(entry);
     126    String platformPath = m_asyncFileSystem->virtualToPlatformPath(entry->fullPath());
     127    m_asyncFileSystem->remove(platformPath, VoidCallbacks::create(successCallback, errorCallback));
     128    return true;
     129}
     130
     131bool DOMFileSystemBase::getParent(const EntryBase* entry, PassRefPtr<EntryCallback> successCallback, PassRefPtr<ErrorCallback> errorCallback)
     132{
     133    ASSERT(entry);
     134    String path = DOMFilePath::getDirectory(entry->fullPath());
     135    String platformPath = m_asyncFileSystem->virtualToPlatformPath(path);
     136    m_asyncFileSystem->directoryExists(platformPath, EntryCallbacks::create(successCallback, errorCallback, this, path, true));
     137    return true;
     138}
     139
     140bool DOMFileSystemBase::getFile(const EntryBase* base, const String& path, PassRefPtr<Flags> flags, PassRefPtr<EntryCallback> successCallback, PassRefPtr<ErrorCallback> errorCallback)
     141{
     142    ASSERT(base);
     143    if (!DOMFilePath::isValidPath(path))
     144        return false;
     145
     146    String absolutePath = path;
     147    if (!DOMFilePath::isAbsolute(path))
     148        absolutePath = DOMFilePath::removeExtraParentReferences(DOMFilePath::append(base->fullPath(), path));
     149    String platformPath = m_asyncFileSystem->virtualToPlatformPath(absolutePath);
     150
     151    OwnPtr<EntryCallbacks> callbacks = EntryCallbacks::create(successCallback, errorCallback, this, absolutePath, false);
     152    if (flags && flags->isCreate())
     153        m_asyncFileSystem->createFile(platformPath, flags->isExclusive(), callbacks.release());
     154    else
     155        m_asyncFileSystem->fileExists(platformPath, callbacks.release());
     156    return true;
     157}
     158
     159bool DOMFileSystemBase::getDirectory(const EntryBase* base, const String& path, PassRefPtr<Flags> flags, PassRefPtr<EntryCallback> successCallback, PassRefPtr<ErrorCallback> errorCallback)
     160{
     161    ASSERT(base);
     162    if (!DOMFilePath::isValidPath(path))
     163        return false;
     164
     165    String absolutePath = path;
     166    if (!DOMFilePath::isAbsolute(path))
     167        absolutePath = DOMFilePath::removeExtraParentReferences(DOMFilePath::append(base->fullPath(), path));
     168    String platformPath = m_asyncFileSystem->virtualToPlatformPath(absolutePath);
     169
     170    OwnPtr<EntryCallbacks> callbacks = EntryCallbacks::create(successCallback, errorCallback, this, absolutePath, true);
     171    if (flags && flags->isCreate())
     172        m_asyncFileSystem->createDirectory(platformPath, flags->isExclusive(), callbacks.release());
     173    else
     174        m_asyncFileSystem->directoryExists(platformPath, callbacks.release());
     175    return true;
     176}
     177
     178bool DOMFileSystemBase::readDirectory(DirectoryReaderBase* reader, const String& path, PassRefPtr<EntriesCallback> successCallback, PassRefPtr<ErrorCallback> errorCallback)
     179{
     180    ASSERT(DOMFilePath::isAbsolute(path));
     181    String platformPath = m_asyncFileSystem->virtualToPlatformPath(path);
     182    m_asyncFileSystem->readDirectory(platformPath, EntriesCallbacks::create(successCallback, errorCallback, reader, path));
     183    return true;
     184}
     185
    51186} // namespace WebCore
    52187
  • trunk/WebCore/fileapi/DOMFileSystemBase.h

    r69178 r69249  
    3535
    3636#include "AsyncFileSystem.h"
     37#include "Flags.h"
    3738#include "PlatformString.h"
    3839#include <wtf/PassRefPtr.h>
     
    4041
    4142namespace WebCore {
     43
     44class DirectoryEntry;
     45class DirectoryReaderBase;
     46class EntriesCallback;
     47class EntryBase;
     48class EntryCallback;
     49class ErrorCallback;
     50class MetadataCallback;
     51class VoidCallback;
    4252
    4353// A common base class for DOMFileSystem and DOMFileSystemSync.
     
    5262    const String& name() const { return m_name; }
    5363    AsyncFileSystem* asyncFileSystem() const { return m_asyncFileSystem.get(); }
     64
     65    // Actual FileSystem API implementations.  All the validity checks on virtual paths are done at this level.
     66    // They return false for immediate errors that don't involve lower AsyncFileSystem layer (e.g. for name validation errors).  Otherwise they return true (but later may call back with an runtime error).
     67    bool getMetadata(const EntryBase*, PassRefPtr<MetadataCallback>, PassRefPtr<ErrorCallback>);
     68    bool move(const EntryBase* source, EntryBase* parent, const String& name, PassRefPtr<EntryCallback>, PassRefPtr<ErrorCallback>);
     69    bool copy(const EntryBase* source, EntryBase* parent, const String& name, PassRefPtr<EntryCallback>, PassRefPtr<ErrorCallback>);
     70    bool remove(const EntryBase*, PassRefPtr<VoidCallback>, PassRefPtr<ErrorCallback>);
     71    bool getParent(const EntryBase*, PassRefPtr<EntryCallback>, PassRefPtr<ErrorCallback>);
     72    bool getFile(const EntryBase*, const String& path, PassRefPtr<Flags>, PassRefPtr<EntryCallback>, PassRefPtr<ErrorCallback>);
     73    bool getDirectory(const EntryBase*, const String& path, PassRefPtr<Flags>, PassRefPtr<EntryCallback>, PassRefPtr<ErrorCallback>);
     74    bool readDirectory(DirectoryReaderBase*, const String& path, PassRefPtr<EntriesCallback>, PassRefPtr<ErrorCallback>);
    5475
    5576protected:
  • trunk/WebCore/fileapi/DOMFileSystemSync.cpp

    r69178 r69249  
    3939namespace WebCore {
    4040
     41PassRefPtr<DOMFileSystemSync> DOMFileSystemSync::create(DOMFileSystemBase* fileSystem)
     42{
     43    return adoptRef(new DOMFileSystemSync(fileSystem->m_name, fileSystem->m_asyncFileSystem.release()));
     44}
     45
    4146DOMFileSystemSync::DOMFileSystemSync(const String& name, PassOwnPtr<AsyncFileSystem> asyncFileSystem)
    4247    : DOMFileSystemBase(name, asyncFileSystem)
  • trunk/WebCore/fileapi/DOMFileSystemSync.h

    r69178 r69249  
    4949    }
    5050
     51    static PassRefPtr<DOMFileSystemSync> create(DOMFileSystemBase*);
     52
    5153    virtual ~DOMFileSystemSync();
    5254
  • trunk/WebCore/fileapi/DirectoryEntry.cpp

    r69178 r69249  
    3737#include "EntryCallback.h"
    3838#include "ErrorCallback.h"
     39#include "FileError.h"
    3940
    4041namespace WebCore {
    4142
    42 DirectoryEntry::DirectoryEntry(DOMFileSystem* fileSystem, const String& fullPath)
     43DirectoryEntry::DirectoryEntry(DOMFileSystemBase* fileSystem, const String& fullPath)
    4344    : Entry(fileSystem, fullPath)
    4445{
     
    5051}
    5152
    52 void DirectoryEntry::getFile(const String& path, PassRefPtr<Flags> flags, PassRefPtr<EntryCallback> successCallback, PassRefPtr<ErrorCallback> errorCallback)
     53void DirectoryEntry::getFile(const String& path, PassRefPtr<Flags> flags, PassRefPtr<EntryCallback> successCallback, PassRefPtr<ErrorCallback> errorCallbackRef)
    5354{
    54     filesystem()->getFile(this, path, flags, successCallback, errorCallback);
     55    RefPtr<ErrorCallback> errorCallback(errorCallbackRef);
     56    if (!m_fileSystem->getFile(this, path, flags, successCallback, errorCallback))
     57        filesystem()->scheduleCallback(errorCallback.release(), FileError::create(INVALID_MODIFICATION_ERR));
    5558}
    5659
    57 void DirectoryEntry::getDirectory(const String& path, PassRefPtr<Flags> flags, PassRefPtr<EntryCallback> successCallback, PassRefPtr<ErrorCallback> errorCallback)
     60void DirectoryEntry::getDirectory(const String& path, PassRefPtr<Flags> flags, PassRefPtr<EntryCallback> successCallback, PassRefPtr<ErrorCallback> errorCallbackRef)
    5861{
    59     filesystem()->getDirectory(this, path, flags, successCallback, errorCallback);
     62    RefPtr<ErrorCallback> errorCallback(errorCallbackRef);
     63    if (!m_fileSystem->getDirectory(this, path, flags, successCallback, errorCallback))
     64        filesystem()->scheduleCallback(errorCallback.release(), FileError::create(INVALID_MODIFICATION_ERR));
    6065}
    6166
    62 } // namespace
     67}
    6368
    6469#endif // ENABLE(FILE_SYSTEM)
  • trunk/WebCore/fileapi/DirectoryEntry.h

    r67443 r69249  
    4242namespace WebCore {
    4343
     44class DOMFileSystemBase;
    4445class DirectoryReader;
    4546class EntryCallback;
     
    4849class DirectoryEntry : public Entry {
    4950public:
    50     static PassRefPtr<DirectoryEntry> create(DOMFileSystem* fileSystem, const String& fullPath)
     51    static PassRefPtr<DirectoryEntry> create(DOMFileSystemBase* fileSystem, const String& fullPath)
    5152    {
    5253        return adoptRef(new DirectoryEntry(fileSystem, fullPath));
     
    5960
    6061private:
    61     DirectoryEntry(DOMFileSystem* fileSystem, const String& fullPath);
     62    DirectoryEntry(DOMFileSystemBase*, const String& fullPath);
    6263};
    6364
  • trunk/WebCore/fileapi/DirectoryEntrySync.cpp

    r69178 r69249  
    3737#include "EntrySync.h"
    3838#include "FileEntrySync.h"
    39 #include "NotImplemented.h"
     39#include "SyncCallbackHelper.h"
    4040
    4141namespace WebCore {
     
    5151}
    5252
    53 PassRefPtr<FileEntrySync> DirectoryEntrySync::getFile(const String&, PassRefPtr<Flags>, ExceptionCode&)
     53PassRefPtr<FileEntrySync> DirectoryEntrySync::getFile(const String& path, PassRefPtr<Flags> flags, ExceptionCode& ec)
    5454{
    55     // FIXME: to be implemented.
    56     notImplemented();
    57     return 0;
     55    ec = 0;
     56    EntrySyncCallbackHelper helper(m_fileSystem->asyncFileSystem());
     57    if (!m_fileSystem->getFile(this, path, flags, helper.successCallback(), helper.errorCallback())) {
     58        ec = INVALID_MODIFICATION_ERR;
     59        return 0;
     60    }
     61    return static_pointer_cast<FileEntrySync>(helper.getResult(ec));
    5862}
    5963
    60 PassRefPtr<DirectoryEntrySync> DirectoryEntrySync::getDirectory(const String&, PassRefPtr<Flags>, ExceptionCode&)
     64PassRefPtr<DirectoryEntrySync> DirectoryEntrySync::getDirectory(const String& path, PassRefPtr<Flags> flags, ExceptionCode& ec)
    6165{
    62     // FIXME: to be implemented.
    63     notImplemented();
    64     return 0;
     66    ec = 0;
     67    EntrySyncCallbackHelper helper(m_fileSystem->asyncFileSystem());
     68    if (!m_fileSystem->getDirectory(this, path, flags, helper.successCallback(), helper.errorCallback())) {
     69        ec = INVALID_MODIFICATION_ERR;
     70        return 0;
     71    }
     72    return static_pointer_cast<DirectoryEntrySync>(helper.getResult(ec));
    6573}
    6674
  • trunk/WebCore/fileapi/DirectoryReaderSync.cpp

    r69178 r69249  
    3434#if ENABLE(FILE_SYSTEM)
    3535
     36#include "DirectoryEntry.h"
     37#include "DirectoryEntrySync.h"
    3638#include "EntryArraySync.h"
     39#include "EntrySync.h"
    3740#include "ExceptionCode.h"
    38 #include "NotImplemented.h"
     41#include "FileEntrySync.h"
     42#include "FileError.h"
     43#include "SyncCallbackHelper.h"
    3944
    4045namespace WebCore {
     
    4550}
    4651
    47 PassRefPtr<EntryArraySync> DirectoryReaderSync::readEntries(ExceptionCode&)
     52PassRefPtr<EntryArraySync> DirectoryReaderSync::readEntries(ExceptionCode& ec)
    4853{
    49     notImplemented();
    50     return 0;
     54    ec = 0;
     55    if (!m_hasMoreEntries)
     56        return EntryArraySync::create();
     57
     58    EntriesSyncCallbackHelper helper(m_fileSystem->asyncFileSystem());
     59    if (!m_fileSystem->readDirectory(this, m_fullPath, helper.successCallback(), helper.errorCallback())) {
     60        ec = INVALID_MODIFICATION_ERR;
     61        setHasMoreEntries(false);
     62        return 0;
     63    }
     64    return helper.getResult(ec);
    5165}
    5266
  • trunk/WebCore/fileapi/Entry.cpp

    r69178 r69249  
    3333#if ENABLE(FILE_SYSTEM)
    3434
    35 #include "DOMFilePath.h"
    36 #include "DOMFileSystem.h"
     35#include "DirectoryEntry.h"
    3736#include "EntryCallback.h"
    3837#include "ErrorCallback.h"
    3938#include "FileError.h"
     39#include "FileSystemCallbacks.h"
    4040#include "MetadataCallback.h"
    4141#include "VoidCallback.h"
     
    4343namespace WebCore {
    4444
    45 Entry::Entry(DOMFileSystem* fileSystem, const String& fullPath)
     45Entry::Entry(DOMFileSystemBase* fileSystem, const String& fullPath)
    4646    : EntryBase(fileSystem, fullPath)
    4747{
    4848}
    4949
    50 void Entry::getMetadata(PassRefPtr<MetadataCallback> successCallback, PassRefPtr<ErrorCallback> errorCallback)
     50void Entry::getMetadata(PassRefPtr<MetadataCallback> successCallback, PassRefPtr<ErrorCallback> errorCallbackRef)
    5151{
    52     filesystem()->getMetadata(this, successCallback, errorCallback);
     52    RefPtr<ErrorCallback> errorCallback(errorCallbackRef);
     53    if (!m_fileSystem->getMetadata(this, successCallback, errorCallback))
     54        filesystem()->scheduleCallback(errorCallback.release(), FileError::create(INVALID_MODIFICATION_ERR));
    5355}
    5456
    55 void Entry::moveTo(PassRefPtr<Entry> parent, const String& name, PassRefPtr<EntryCallback> successCallback, PassRefPtr<ErrorCallback> errorCallback) const
     57void Entry::moveTo(PassRefPtr<DirectoryEntry> parent, const String& name, PassRefPtr<EntryCallback> successCallback, PassRefPtr<ErrorCallback> errorCallbackRef) const
    5658{
    57     filesystem()->move(this, parent, name, successCallback, errorCallback);
     59    RefPtr<ErrorCallback> errorCallback(errorCallbackRef);
     60    if (!m_fileSystem->move(this, parent.get(), name, successCallback, errorCallback))
     61        filesystem()->scheduleCallback(errorCallback.release(), FileError::create(INVALID_MODIFICATION_ERR));
    5862}
    5963
    60 void Entry::copyTo(PassRefPtr<Entry> parent, const String& name, PassRefPtr<EntryCallback> successCallback, PassRefPtr<ErrorCallback> errorCallback) const
     64void Entry::copyTo(PassRefPtr<DirectoryEntry> parent, const String& name, PassRefPtr<EntryCallback> successCallback, PassRefPtr<ErrorCallback> errorCallbackRef) const
    6165{
    62     filesystem()->copy(this, parent, name, successCallback, errorCallback);
     66    RefPtr<ErrorCallback> errorCallback(errorCallbackRef);
     67    if (!m_fileSystem->copy(this, parent.get(), name, successCallback, errorCallback))
     68        filesystem()->scheduleCallback(errorCallback.release(), FileError::create(INVALID_MODIFICATION_ERR));
    6369}
    6470
    65 void Entry::remove(PassRefPtr<VoidCallback> successCallback, PassRefPtr<ErrorCallback> errorCallback) const
     71void Entry::remove(PassRefPtr<VoidCallback> successCallback, PassRefPtr<ErrorCallback> errorCallbackRef) const
    6672{
    67     filesystem()->remove(this, successCallback, errorCallback);
     73    RefPtr<ErrorCallback> errorCallback(errorCallbackRef);
     74    if (!m_fileSystem->remove(this, successCallback, errorCallback))
     75        filesystem()->scheduleCallback(errorCallback.release(), FileError::create(INVALID_MODIFICATION_ERR));
    6876}
    6977
    70 void Entry::getParent(PassRefPtr<EntryCallback> successCallback, PassRefPtr<ErrorCallback> errorCallback) const
     78void Entry::getParent(PassRefPtr<EntryCallback> successCallback, PassRefPtr<ErrorCallback> errorCallbackRef) const
    7179{
    72     filesystem()->getParent(this, successCallback, errorCallback);
     80    RefPtr<ErrorCallback> errorCallback(errorCallbackRef);
     81    if (!m_fileSystem->getParent(this, successCallback, errorCallback))
     82        filesystem()->scheduleCallback(errorCallback.release(), FileError::create(INVALID_MODIFICATION_ERR));
    7383}
    7484
  • trunk/WebCore/fileapi/Entry.h

    r69178 r69249  
    4141namespace WebCore {
    4242
     43class DirectoryEntry;
    4344class EntryCallback;
     45class EntrySync;
    4446class ErrorCallback;
    4547class MetadataCallback;
     
    4850class Entry : public EntryBase {
    4951public:
    50     virtual ~Entry() { }
    51 
    5252    DOMFileSystem* filesystem() const { return static_cast<DOMFileSystem*>(m_fileSystem); }
    5353
    5454    virtual void getMetadata(PassRefPtr<MetadataCallback> successCallback = 0, PassRefPtr<ErrorCallback> errorCallback = 0);
    55     virtual void moveTo(PassRefPtr<Entry> parent, const String& name = String(), PassRefPtr<EntryCallback> successCallback = 0, PassRefPtr<ErrorCallback> errorCallback = 0) const;
    56     virtual void copyTo(PassRefPtr<Entry> parent, const String& name = String(), PassRefPtr<EntryCallback> successCallback = 0, PassRefPtr<ErrorCallback> errorCallback = 0) const;
     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;
    5757    virtual void remove(PassRefPtr<VoidCallback> successCallback = 0, PassRefPtr<ErrorCallback> errorCallback = 0) const;
    5858    virtual void getParent(PassRefPtr<EntryCallback> successCallback = 0, PassRefPtr<ErrorCallback> errorCallback = 0) const;
     
    6161
    6262protected:
    63     Entry(DOMFileSystem* fileSystem, const String& fullPath);
     63    Entry(DOMFileSystemBase*, const String& fullPath);
    6464};
    6565
  • trunk/WebCore/fileapi/Entry.idl

    r67917 r69249  
    4242
    4343        void getMetadata(in [Optional, Callback] MetadataCallback successCallback, in [Optional, Callback] ErrorCallback errorCallback);
    44         void moveTo(in Entry parent, in [Optional, ConvertUndefinedOrNullToNullString] DOMString name, in [Optional, Callback] EntryCallback successCallback, in [Optional, Callback] ErrorCallback errorCallback);
    45         void copyTo(in Entry parent, in [Optional, ConvertUndefinedOrNullToNullString] DOMString name, in [Optional, Callback] EntryCallback successCallback, in [Optional, Callback] ErrorCallback errorCallback);
     44        void moveTo(in DirectoryEntry parent, in [Optional, ConvertUndefinedOrNullToNullString] DOMString name, in [Optional, Callback] EntryCallback successCallback, in [Optional, Callback] ErrorCallback errorCallback);
     45        void copyTo(in DirectoryEntry parent, in [Optional, ConvertUndefinedOrNullToNullString] DOMString name, in [Optional, Callback] EntryCallback successCallback, in [Optional, Callback] ErrorCallback errorCallback);
    4646        void remove(in [Optional, Callback] VoidCallback successCallback, in [Optional, Callback] ErrorCallback errorCallback);
    4747        void getParent(in [Optional, Callback] EntryCallback successCallback, in [Optional, Callback] ErrorCallback errorCallback);
  • trunk/WebCore/fileapi/EntryArraySync.cpp

    r69178 r69249  
    3434#if ENABLE(FILE_SYSTEM)
    3535
     36#include "EntryArray.h"
     37
    3638namespace WebCore {
     39
     40PassRefPtr<EntryArraySync> EntryArraySync::create(EntryArray* entries)
     41{
     42    RefPtr<EntryArraySync> entriesSync = adoptRef(new EntryArraySync());
     43    if (entries) {
     44        for (unsigned i = 0; i < entries->length(); ++i)
     45            entriesSync->append(EntrySync::create(entries->item(i)));
     46    }
     47    return entriesSync.release();
     48}
    3749
    3850EntryArraySync::EntryArraySync()
  • trunk/WebCore/fileapi/EntryArraySync.h

    r69178 r69249  
    4949    }
    5050
     51    static PassRefPtr<EntryArraySync> create(EntryArray*);
     52
    5153    unsigned length() const { return m_entries.size(); }
    5254    EntrySync* item(unsigned index) const;
  • trunk/WebCore/fileapi/EntryBase.h

    r69178 r69249  
    4949    virtual ~EntryBase() { }
    5050
     51    DOMFileSystemBase* filesystem() const { return m_fileSystem; }
     52
    5153    virtual bool isFile() const { return false; }
    5254    virtual bool isDirectory() const { return false; }
  • trunk/WebCore/fileapi/EntrySync.cpp

    r69178 r69249  
    3535
    3636#include "DOMFilePath.h"
     37#include "DOMFileSystemSync.h"
     38#include "DirectoryEntry.h"
    3739#include "DirectoryEntrySync.h"
     40#include "FileEntrySync.h"
    3841#include "Metadata.h"
    39 #include "NotImplemented.h"
     42#include "SyncCallbackHelper.h"
    4043
    4144namespace WebCore {
    4245
    43 PassRefPtr<Metadata> EntrySync::getMetadata(ExceptionCode&)
     46PassRefPtr<EntrySync> EntrySync::create(EntryBase* entry)
    4447{
    45     // FIXME: to be implemented.
    46     notImplemented();
    47     return 0;
     48    if (entry->isFile())
     49        return adoptRef(new FileEntrySync(entry->m_fileSystem, entry->m_fullPath));
     50    return adoptRef(new DirectoryEntrySync(entry->m_fileSystem, entry->m_fullPath));
    4851}
    4952
    50 PassRefPtr<EntrySync> EntrySync::moveTo(PassRefPtr<DirectoryEntrySync>, const String&, ExceptionCode&) const
     53PassRefPtr<Metadata> EntrySync::getMetadata(ExceptionCode& ec)
    5154{
    52     // FIXME: to be implemented.
    53     notImplemented();
    54     return 0;
     55    ec = 0;
     56    MetadataSyncCallbackHelper helper(m_fileSystem->asyncFileSystem());
     57    if (!m_fileSystem->getMetadata(this, helper.successCallback(), helper.errorCallback())) {
     58        ec = INVALID_MODIFICATION_ERR;
     59        return 0;
     60    }
     61    return helper.getResult(ec);
    5562}
    5663
    57 PassRefPtr<EntrySync> EntrySync::copyTo(PassRefPtr<DirectoryEntrySync>, const String&, ExceptionCode&) const
     64PassRefPtr<EntrySync> EntrySync::moveTo(PassRefPtr<DirectoryEntrySync> parent, const String& name, ExceptionCode& ec) const
    5865{
    59     // FIXME: to be implemented.
    60     notImplemented();
    61     return 0;
     66    ec = 0;
     67    EntrySyncCallbackHelper helper(m_fileSystem->asyncFileSystem());
     68    if (!m_fileSystem->move(this, parent.get(), name, helper.successCallback(), helper.errorCallback())) {
     69        ec = INVALID_MODIFICATION_ERR;
     70        return 0;
     71    }
     72    return helper.getResult(ec);
    6273}
    6374
    64 void EntrySync::remove(ExceptionCode&) const
     75PassRefPtr<EntrySync> EntrySync::copyTo(PassRefPtr<DirectoryEntrySync> parent, const String& name, ExceptionCode& ec) const
    6576{
    66     // FIXME: to be implemented.
    67     notImplemented();
     77    ec = 0;
     78    EntrySyncCallbackHelper helper(m_fileSystem->asyncFileSystem());
     79    if (!m_fileSystem->copy(this, parent.get(), name, helper.successCallback(), helper.errorCallback())) {
     80        ec = INVALID_MODIFICATION_ERR;
     81        return 0;
     82    }
     83    return helper.getResult(ec);
     84}
     85
     86void EntrySync::remove(ExceptionCode& ec) const
     87{
     88    ec = 0;
     89    VoidSyncCallbackHelper helper(m_fileSystem->asyncFileSystem());
     90    if (!m_fileSystem->remove(this, helper.successCallback(), helper.errorCallback()))
     91        ec = INVALID_MODIFICATION_ERR;
     92    helper.getResult(ec);
    6893}
    6994
  • trunk/WebCore/fileapi/EntrySync.h

    r69178 r69249  
    4848class EntrySync : public EntryBase {
    4949public:
     50    static PassRefPtr<EntrySync> create(EntryBase*);
     51
    5052    DOMFileSystemSync* filesystem() const { return static_cast<DOMFileSystemSync*>(m_fileSystem); }
    5153
  • trunk/WebCore/fileapi/FileEntry.cpp

    r69178 r69249  
    4242namespace WebCore {
    4343
    44 FileEntry::FileEntry(DOMFileSystem* fileSystem, const String& fullPath)
     44FileEntry::FileEntry(DOMFileSystemBase* fileSystem, const String& fullPath)
    4545    : Entry(fileSystem, fullPath)
    4646{
  • trunk/WebCore/fileapi/FileEntry.h

    r67614 r69249  
    4040namespace WebCore {
    4141
    42 class DOMFileSystem;
     42class DOMFileSystemBase;
    4343
    4444class FileEntry : public Entry {
    4545public:
    46     static PassRefPtr<FileEntry> create(DOMFileSystem* fileSystem, const String& fullPath)
     46    static PassRefPtr<FileEntry> create(DOMFileSystemBase* fileSystem, const String& fullPath)
    4747    {
    4848        return adoptRef(new FileEntry(fileSystem, fullPath));
     
    5555
    5656private:
    57     FileEntry(DOMFileSystem* fileSystem, const String& fullPath);
     57    FileEntry(DOMFileSystemBase* fileSystem, const String& fullPath);
    5858};
    5959
  • trunk/WebCore/fileapi/FileSystemCallbacks.cpp

    r69178 r69249  
    3737#include "AsyncFileWriter.h"
    3838#include "DOMFilePath.h"
    39 #include "DOMFileSystem.h"
     39#include "DOMFileSystemBase.h"
    4040#include "DirectoryEntry.h"
    4141#include "DirectoryReader.h"
     
    112112// EntryCallbacks -------------------------------------------------------------
    113113
    114 PassOwnPtr<EntryCallbacks> EntryCallbacks::create(PassRefPtr<EntryCallback> successCallback, PassRefPtr<ErrorCallback> errorCallback, DOMFileSystem* fileSystem, const String& expectedPath, bool isDirectory)
     114PassOwnPtr<EntryCallbacks> EntryCallbacks::create(PassRefPtr<EntryCallback> successCallback, PassRefPtr<ErrorCallback> errorCallback, DOMFileSystemBase* fileSystem, const String& expectedPath, bool isDirectory)
    115115{
    116116    return adoptPtr(new EntryCallbacks(successCallback, errorCallback, fileSystem, expectedPath, isDirectory));
    117117}
    118118
    119 EntryCallbacks::EntryCallbacks(PassRefPtr<EntryCallback> successCallback, PassRefPtr<ErrorCallback> errorCallback, DOMFileSystem* fileSystem, const String& expectedPath, bool isDirectory)
     119EntryCallbacks::EntryCallbacks(PassRefPtr<EntryCallback> successCallback, PassRefPtr<ErrorCallback> errorCallback, DOMFileSystemBase* fileSystem, const String& expectedPath, bool isDirectory)
    120120    : FileSystemCallbacksBase(errorCallback)
    121121    , m_successCallback(successCallback)
     
    139139// EntriesCallbacks -----------------------------------------------------------
    140140
    141 PassOwnPtr<EntriesCallbacks> EntriesCallbacks::create(PassRefPtr<EntriesCallback> successCallback, PassRefPtr<ErrorCallback> errorCallback, DirectoryReader* directoryReader, const String& basePath)
     141PassOwnPtr<EntriesCallbacks> EntriesCallbacks::create(PassRefPtr<EntriesCallback> successCallback, PassRefPtr<ErrorCallback> errorCallback, DirectoryReaderBase* directoryReader, const String& basePath)
    142142{
    143143    return adoptPtr(new EntriesCallbacks(successCallback, errorCallback, directoryReader, basePath));
    144144}
    145145
    146 EntriesCallbacks::EntriesCallbacks(PassRefPtr<EntriesCallback> successCallback, PassRefPtr<ErrorCallback> errorCallback, DirectoryReader* directoryReader, const String& basePath)
     146EntriesCallbacks::EntriesCallbacks(PassRefPtr<EntriesCallback> successCallback, PassRefPtr<ErrorCallback> errorCallback, DirectoryReaderBase* directoryReader, const String& basePath)
    147147    : FileSystemCallbacksBase(errorCallback)
    148148    , m_successCallback(successCallback)
  • trunk/WebCore/fileapi/FileSystemCallbacks.h

    r68735 r69249  
    4242
    4343class AsyncFileWriter;
    44 class DOMFileSystem;
    45 class DirectoryReader;
     44class DOMFileSystemBase;
     45class DirectoryReaderBase;
    4646class ErrorCallback;
    4747class EntriesCallback;
     
    8787class EntryCallbacks : public FileSystemCallbacksBase {
    8888public:
    89     static PassOwnPtr<EntryCallbacks> create(PassRefPtr<EntryCallback>, PassRefPtr<ErrorCallback>, DOMFileSystem*, const String& expectedPath, bool isDirectory);
     89    static PassOwnPtr<EntryCallbacks> create(PassRefPtr<EntryCallback>, PassRefPtr<ErrorCallback>, DOMFileSystemBase*, const String& expectedPath, bool isDirectory);
    9090    virtual void didSucceed();
    9191
    9292private:
    93     EntryCallbacks(PassRefPtr<EntryCallback>, PassRefPtr<ErrorCallback>, DOMFileSystem*, const String& expectedPath, bool isDirectory);
     93    EntryCallbacks(PassRefPtr<EntryCallback>, PassRefPtr<ErrorCallback>, DOMFileSystemBase*, const String& expectedPath, bool isDirectory);
    9494    RefPtr<EntryCallback> m_successCallback;
    95     DOMFileSystem* m_fileSystem;
     95    DOMFileSystemBase* m_fileSystem;
    9696    String m_expectedPath;
    9797    bool m_isDirectory;
     
    100100class EntriesCallbacks : public FileSystemCallbacksBase {
    101101public:
    102     static PassOwnPtr<EntriesCallbacks> create(PassRefPtr<EntriesCallback>, PassRefPtr<ErrorCallback>, DirectoryReader*, const String& basePath);
     102    static PassOwnPtr<EntriesCallbacks> create(PassRefPtr<EntriesCallback>, PassRefPtr<ErrorCallback>, DirectoryReaderBase*, const String& basePath);
    103103    virtual void didReadDirectoryEntry(const String& name, bool isDirectory);
    104104    virtual void didReadDirectoryEntries(bool hasMore);
    105105
    106106private:
    107     EntriesCallbacks(PassRefPtr<EntriesCallback>, PassRefPtr<ErrorCallback>, DirectoryReader*, const String& basePath);
     107    EntriesCallbacks(PassRefPtr<EntriesCallback>, PassRefPtr<ErrorCallback>, DirectoryReaderBase*, const String& basePath);
    108108    RefPtr<EntriesCallback> m_successCallback;
    109     DirectoryReader* m_directoryReader;
     109    DirectoryReaderBase* m_directoryReader;
    110110    String m_basePath;
    111111    RefPtr<EntryArray> m_entries;
  • trunk/WebCore/fileapi/LocalFileSystem.cpp

    r68411 r69249  
    8282}
    8383
    84 void LocalFileSystem::requestFileSystem(ScriptExecutionContext* context, AsyncFileSystem::Type type, long long, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
     84void LocalFileSystem::requestFileSystem(ScriptExecutionContext* context, AsyncFileSystem::Type type, long long, PassOwnPtr<AsyncFileSystemCallbacks> callbacks, bool)
    8585{
    8686    // AsyncFileSystem::openFileSystem calls callbacks synchronously, so the method needs to be called asynchronously.
  • trunk/WebCore/fileapi/LocalFileSystem.h

    r68411 r69249  
    5353    static LocalFileSystem& localFileSystem();
    5454
    55     void requestFileSystem(ScriptExecutionContext*, AsyncFileSystem::Type, long long size, PassOwnPtr<AsyncFileSystemCallbacks>);
     55    void requestFileSystem(ScriptExecutionContext*, AsyncFileSystem::Type, long long size, PassOwnPtr<AsyncFileSystemCallbacks>, bool synchronous = false);
    5656
    5757#if !PLATFORM(CHROMIUM)
  • trunk/WebCore/fileapi/Metadata.h

    r66642 r69249  
    4545    }
    4646
     47    static PassRefPtr<Metadata> create(Metadata* metadata)
     48    {
     49        return adoptRef(new Metadata(metadata->m_modificationTime));
     50    }
     51
    4752    // Needs to return epoch time in milliseconds for Date.
    4853    double modificationTime() const { return m_modificationTime * 1000.0; }
  • trunk/WebCore/page/DOMWindow.idl

    r68440 r69249  
    193193        const unsigned short TEMPORARY = 0;
    194194        const unsigned short PERSISTENT = 1;
    195         [EnabledAtRuntime] void requestFileSystem(in unsigned short type, in long long size, in [Callback, Optional] FileSystemCallback successCallback, in [Callback, Optional] ErrorCallback errorCallback);
     195        [EnabledAtRuntime=FileSystem] void requestFileSystem(in unsigned short type, in long long size, in [Callback, Optional] FileSystemCallback successCallback, in [Callback, Optional] ErrorCallback errorCallback);
    196196
    197197        attribute [EnabledAtRuntime=FileSystem] FlagsConstructor Flags;
  • trunk/WebCore/platform/AsyncFileSystem.h

    r68222 r69249  
    5959
    6060    static bool isAvailable();
     61
     62    // Subclass must implement this if it supports synchronous operations.
     63    // This should return false if there are no pending operations.
     64    virtual bool waitForOperationToComplete() { return false; }
    6165
    6266    // Creates and returns a new platform-specific AsyncFileSystem instance if the platform has its own implementation.
  • trunk/WebCore/workers/WorkerContext.cpp

    r68411 r69249  
    6767#include "AsyncFileSystem.h"
    6868#include "DOMFileSystem.h"
     69#include "DOMFileSystemSync.h"
    6970#include "ErrorCallback.h"
    7071#include "FileError.h"
     
    7273#include "FileSystemCallbacks.h"
    7374#include "LocalFileSystem.h"
     75#include "SyncCallbackHelper.h"
    7476#endif
    7577
     
    367369}
    368370
     371PassRefPtr<DOMFileSystemSync> WorkerContext::requestFileSystemSync(int type, long long size, ExceptionCode& ec)
     372{
     373    ec = 0;
     374    if (!AsyncFileSystem::isAvailable() || !securityOrigin()->canAccessFileSystem()) {
     375        ec = SECURITY_ERR;
     376        return 0;
     377    }
     378
     379    AsyncFileSystem::Type fileSystemType = static_cast<AsyncFileSystem::Type>(type);
     380    if (fileSystemType != AsyncFileSystem::Temporary && fileSystemType != AsyncFileSystem::Persistent) {
     381        ec = INVALID_MODIFICATION_ERR;
     382        return 0;
     383    }
     384
     385    FileSystemSyncCallbackHelper helper;
     386    LocalFileSystem::localFileSystem().requestFileSystem(this, fileSystemType, size, FileSystemCallbacks::create(helper.successCallback(), helper.errorCallback(), this), true);
     387    return helper.getResult(ec);
     388}
     389
    369390COMPILE_ASSERT(static_cast<int>(WorkerContext::TEMPORARY) == static_cast<int>(AsyncFileSystem::Temporary), enum_mismatch);
    370391COMPILE_ASSERT(static_cast<int>(WorkerContext::PERSISTENT) == static_cast<int>(AsyncFileSystem::Persistent), enum_mismatch);
  • trunk/WebCore/workers/WorkerContext.h

    r68222 r69249  
    4646
    4747    class Blob;
     48    class DOMFileSystemSync;
    4849    class Database;
    4950    class DatabaseCallback;
     
    131132        };
    132133        void requestFileSystem(int type, long long size, PassRefPtr<FileSystemCallback>, PassRefPtr<ErrorCallback>);
     134        PassRefPtr<DOMFileSystemSync> requestFileSystemSync(int type, long long size, ExceptionCode&);
    133135#endif
    134136
  • trunk/WebCore/workers/WorkerContext.idl

    r68222 r69249  
    109109        const unsigned short TEMPORARY = 0;
    110110        const unsigned short PERSISTENT = 1;
    111         [EnabledAtRuntime] void requestFileSystem(in unsigned short type, in long long size, in [Callback, Optional] FileSystemCallback successCallback, in [Callback, Optional] ErrorCallback errorCallback);
     111        [EnabledAtRuntime=FileSystem] void requestFileSystem(in unsigned short type, in long long size, in [Callback, Optional] FileSystemCallback successCallback, in [Callback, Optional] ErrorCallback errorCallback);
     112        [EnabledAtRuntime=FileSystem] DOMFileSystemSync requestFileSystemSync(in unsigned short type, in long long size) raises (FileException);
    112113
    113114                 attribute [EnabledAtRuntime=FileSystem] FlagsConstructor Flags;
  • trunk/WebKit/chromium/ChangeLog

    r69247 r69249  
     12010-10-06  Kinuko Yasuda  <kinuko@chromium.org>
     2
     3        Reviewed by David Levin.
     4
     5        Add FileSystemSync implementation for Worker
     6        https://bugs.webkit.org/show_bug.cgi?id=47044
     7
     8        * src/LocalFileSystemChromium.cpp:
     9        (WebCore::LocalFileSystem::requestFileSystem): Added a new parameter
     10        for synchronous mode.
     11        * src/WebFileSystemCallbacksImpl.cpp:
     12        (WebKit::WebFileSystemCallbacksImpl::WebFileSystemCallbacksImpl): Added
     13        a parameter for synchronous mode.
     14        (WebKit::WebFileSystemCallbacksImpl::didOpenFileSystem): Changed to
     15        creates WorkerAsyncFileSystemChromium with synchronous flag.
     16        * src/WebFileSystemCallbacksImpl.h:
     17        * src/WebWorkerBase.cpp:
     18        (WebKit::WebWorkerBase::openFileSystem): Added a parameter for
     19        synchronous mode.
     20        * src/WebWorkerBase.h:
     21        * src/WorkerAsyncFileSystemChromium.cpp:
     22        (WebCore::WorkerAsyncFileSystemChromium::WorkerAsyncFileSystemChromium):
     23        (WebCore::WorkerAsyncFileSystemChromium::waitForOperationToComplete):
     24        Added.
     25        (WebCore::WorkerAsyncFileSystemChromium::move):
     26        (WebCore::WorkerAsyncFileSystemChromium::copy):
     27        (WebCore::WorkerAsyncFileSystemChromium::remove):
     28        (WebCore::WorkerAsyncFileSystemChromium::readMetadata):
     29        (WebCore::WorkerAsyncFileSystemChromium::createFile):
     30        (WebCore::WorkerAsyncFileSystemChromium::createDirectory):
     31        (WebCore::WorkerAsyncFileSystemChromium::fileExists):
     32        (WebCore::WorkerAsyncFileSystemChromium::directoryExists):
     33        (WebCore::WorkerAsyncFileSystemChromium::readDirectory):
     34        (WebCore::WorkerAsyncFileSystemChromium::createWorkerFileSystemCallbacksBridge):
     35        Updated to store the created bridge in a member variable so that
     36        we can call bridge->stop() later when the RunLoop is terminating.
     37        * src/WorkerAsyncFileSystemChromium.h:
     38        (WebCore::WorkerAsyncFileSystemChromium::create): Added a new
     39        parameter for synchronous mode.
     40
    1412010-10-06  Andrei Popescu  <andreip@google.com>
    242
  • trunk/WebKit/chromium/src/LocalFileSystemChromium.cpp

    r68669 r69249  
    5858}
    5959
    60 void LocalFileSystem::requestFileSystem(ScriptExecutionContext* context, AsyncFileSystem::Type type, long long size, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
     60void LocalFileSystem::requestFileSystem(ScriptExecutionContext* context, AsyncFileSystem::Type type, long long size, PassOwnPtr<AsyncFileSystemCallbacks> callbacks, bool synchronous)
    6161{
    6262    ASSERT(context);
     
    6969        WorkerLoaderProxy* workerLoaderProxy = &workerContext->thread()->workerLoaderProxy();
    7070        WebWorkerBase* webWorker = static_cast<WebWorkerBase*>(workerLoaderProxy);
    71         webWorker->openFileSystem(static_cast<WebFileSystem::Type>(type), size, new WebFileSystemCallbacksImpl(callbacks, context));
     71        webWorker->openFileSystem(static_cast<WebFileSystem::Type>(type), size, new WebFileSystemCallbacksImpl(callbacks, context, synchronous), synchronous);
    7272    }
    7373}
  • trunk/WebKit/chromium/src/WebFileSystemCallbacksImpl.cpp

    r68735 r69249  
    4646namespace WebKit {
    4747
    48 WebFileSystemCallbacksImpl::WebFileSystemCallbacksImpl(PassOwnPtr<AsyncFileSystemCallbacks> callbacks, WebCore::ScriptExecutionContext* context)
     48WebFileSystemCallbacksImpl::WebFileSystemCallbacksImpl(PassOwnPtr<AsyncFileSystemCallbacks> callbacks, WebCore::ScriptExecutionContext* context, bool synchronous)
    4949    : m_callbacks(callbacks)
    5050    , m_context(context)
     51    , m_synchronous(synchronous)
    5152{
    5253    ASSERT(m_callbacks);
     
    8081{
    8182    if (m_context && m_context->isWorkerContext())
    82         m_callbacks->didOpenFileSystem(name, WorkerAsyncFileSystemChromium::create(m_context, path));
     83        m_callbacks->didOpenFileSystem(name, WorkerAsyncFileSystemChromium::create(m_context, path, m_synchronous));
    8384    else
    8485        m_callbacks->didOpenFileSystem(name, AsyncFileSystemChromium::create(path));
  • trunk/WebKit/chromium/src/WebFileSystemCallbacksImpl.h

    r68669 r69249  
    5050class WebFileSystemCallbacksImpl : public WebFileSystemCallbacks {
    5151public:
    52     WebFileSystemCallbacksImpl(PassOwnPtr<WebCore::AsyncFileSystemCallbacks>, WebCore::ScriptExecutionContext* = 0);
     52    WebFileSystemCallbacksImpl(PassOwnPtr<WebCore::AsyncFileSystemCallbacks>, WebCore::ScriptExecutionContext* = 0, bool synchronous = false);
    5353    virtual ~WebFileSystemCallbacksImpl();
    5454
     
    6464    // Used for worker's openFileSystem callbacks.
    6565    WebCore::ScriptExecutionContext* m_context;
     66    bool m_synchronous;
    6667};
    6768
  • trunk/WebKit/chromium/src/WebWorkerBase.cpp

    r68669 r69249  
    238238
    239239#if ENABLE(FILE_SYSTEM)
    240 void WebWorkerBase::openFileSystem(WebFileSystem::Type type, long long size, WebFileSystemCallbacks* callbacks)
    241 {
     240void WebWorkerBase::openFileSystem(WebFileSystem::Type type, long long size, WebFileSystemCallbacks* callbacks, bool synchronous)
     241{
     242    WorkerRunLoop& runLoop = m_workerThread->runLoop();
    242243    WorkerScriptController* controller = WorkerScriptController::controllerForContext();
    243     RefPtr<WorkerFileSystemCallbacksBridge> bridge = WorkerFileSystemCallbacksBridge::create(this, controller->workerContext(), callbacks);
    244     bridge->postOpenFileSystemToMainThread(commonClient(), type, size, openFileSystemMode);
     244    WorkerContext* workerContext = controller->workerContext();
     245
     246    // Create a unique mode for this openFileSystem call.
     247    String mode = openFileSystemMode;
     248    mode.append(String::number(runLoop.createUniqueId()));
     249
     250    RefPtr<WorkerFileSystemCallbacksBridge> bridge = WorkerFileSystemCallbacksBridge::create(this, workerContext, callbacks);
     251    bridge->postOpenFileSystemToMainThread(commonClient(), type, size, mode);
     252
     253    if (synchronous) {
     254        if (runLoop.runInMode(workerContext, mode) == MessageQueueTerminated)
     255            bridge->stop();
     256    }
    245257}
    246258#endif
  • trunk/WebKit/chromium/src/WebWorkerBase.h

    r68226 r69249  
    9494#if ENABLE(FILE_SYSTEM)
    9595    // Requests to open a file system for this worker. (Note that this is not the implementation for WebFrameClient::openFileSystem.)
    96     void openFileSystem(WebFileSystem::Type, long long size, WebFileSystemCallbacks*);
     96    void openFileSystem(WebFileSystem::Type, long long size, WebFileSystemCallbacks*, bool synchronous);
    9797#endif
    9898
  • trunk/WebKit/chromium/src/WorkerAsyncFileSystemChromium.cpp

    r68672 r69249  
    5454static const char fileSystemOperationsMode[] = "fileSystemOperationsMode";
    5555
    56 WorkerAsyncFileSystemChromium::WorkerAsyncFileSystemChromium(ScriptExecutionContext* context, const String& rootPath)
     56WorkerAsyncFileSystemChromium::WorkerAsyncFileSystemChromium(ScriptExecutionContext* context, const String& rootPath, bool synchronous)
    5757    : AsyncFileSystem(rootPath)
    5858    , m_scriptExecutionContext(context)
    5959    , m_webFileSystem(WebKit::webKitClient()->fileSystem())
    60     , m_mode(fileSystemOperationsMode)
     60    , m_workerContext(static_cast<WorkerContext*>(context))
     61    , m_synchronous(synchronous)
    6162{
    6263    ASSERT(m_webFileSystem);
    6364    ASSERT(m_scriptExecutionContext->isWorkerContext());
    6465
    65     WorkerContext* workerContext = static_cast<WorkerContext*>(context);
    66     WorkerLoaderProxy* workerLoaderProxy = &workerContext->thread()->workerLoaderProxy();
     66    WorkerLoaderProxy* workerLoaderProxy = &m_workerContext->thread()->workerLoaderProxy();
    6767    m_worker = static_cast<WebWorkerBase*>(workerLoaderProxy);
    6868}
     
    7272}
    7373
     74bool WorkerAsyncFileSystemChromium::waitForOperationToComplete()
     75{
     76    if (!m_bridgeForCurrentOperation.get())
     77        return false;
     78
     79    RefPtr<WorkerFileSystemCallbacksBridge> bridge = m_bridgeForCurrentOperation.release();
     80    if (m_workerContext->thread()->runLoop().runInMode(m_workerContext, m_modeForCurrentOperation) == MessageQueueTerminated) {
     81        bridge->stop();
     82        return false;
     83    }
     84    return true;
     85}
     86
    7487void WorkerAsyncFileSystemChromium::move(const String& sourcePath, const String& destinationPath, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
    7588{
    76     createWorkerFileSystemCallbacksBridge(callbacks)->postMoveToMainThread(m_webFileSystem, sourcePath, destinationPath, m_mode);
     89    createWorkerFileSystemCallbacksBridge(callbacks)->postMoveToMainThread(m_webFileSystem, sourcePath, destinationPath, m_modeForCurrentOperation);
    7790}
    7891
    7992void WorkerAsyncFileSystemChromium::copy(const String& sourcePath, const String& destinationPath, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
    8093{
    81     createWorkerFileSystemCallbacksBridge(callbacks)->postCopyToMainThread(m_webFileSystem, sourcePath, destinationPath, m_mode);
     94    createWorkerFileSystemCallbacksBridge(callbacks)->postCopyToMainThread(m_webFileSystem, sourcePath, destinationPath, m_modeForCurrentOperation);
    8295}
    8396
    8497void WorkerAsyncFileSystemChromium::remove(const String& path, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
    8598{
    86     createWorkerFileSystemCallbacksBridge(callbacks)->postRemoveToMainThread(m_webFileSystem, path, m_mode);
     99    createWorkerFileSystemCallbacksBridge(callbacks)->postRemoveToMainThread(m_webFileSystem, path, m_modeForCurrentOperation);
    87100}
    88101
    89102void WorkerAsyncFileSystemChromium::readMetadata(const String& path, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
    90103{
    91     createWorkerFileSystemCallbacksBridge(callbacks)->postReadMetadataToMainThread(m_webFileSystem, path, m_mode);
     104    createWorkerFileSystemCallbacksBridge(callbacks)->postReadMetadataToMainThread(m_webFileSystem, path, m_modeForCurrentOperation);
    92105}
    93106
    94107void WorkerAsyncFileSystemChromium::createFile(const String& path, bool exclusive, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
    95108{
    96     createWorkerFileSystemCallbacksBridge(callbacks)->postCreateFileToMainThread(m_webFileSystem, path, exclusive, m_mode);
     109    createWorkerFileSystemCallbacksBridge(callbacks)->postCreateFileToMainThread(m_webFileSystem, path, exclusive, m_modeForCurrentOperation);
    97110}
    98111
    99112void WorkerAsyncFileSystemChromium::createDirectory(const String& path, bool exclusive, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
    100113{
    101     createWorkerFileSystemCallbacksBridge(callbacks)->postCreateDirectoryToMainThread(m_webFileSystem, path, exclusive, m_mode);
     114    createWorkerFileSystemCallbacksBridge(callbacks)->postCreateDirectoryToMainThread(m_webFileSystem, path, exclusive, m_modeForCurrentOperation);
    102115}
    103116
    104117void WorkerAsyncFileSystemChromium::fileExists(const String& path, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
    105118{
    106     createWorkerFileSystemCallbacksBridge(callbacks)->postFileExistsToMainThread(m_webFileSystem, path, m_mode);
     119    createWorkerFileSystemCallbacksBridge(callbacks)->postFileExistsToMainThread(m_webFileSystem, path, m_modeForCurrentOperation);
    107120}
    108121
    109122void WorkerAsyncFileSystemChromium::directoryExists(const String& path, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
    110123{
    111     createWorkerFileSystemCallbacksBridge(callbacks)->postDirectoryExistsToMainThread(m_webFileSystem, path, m_mode);
     124    createWorkerFileSystemCallbacksBridge(callbacks)->postDirectoryExistsToMainThread(m_webFileSystem, path, m_modeForCurrentOperation);
    112125}
    113126
    114127void WorkerAsyncFileSystemChromium::readDirectory(const String& path, PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
    115128{
    116     createWorkerFileSystemCallbacksBridge(callbacks)->postReadDirectoryToMainThread(m_webFileSystem, path, m_mode);
     129    createWorkerFileSystemCallbacksBridge(callbacks)->postReadDirectoryToMainThread(m_webFileSystem, path, m_modeForCurrentOperation);
    117130}
    118131
     
    124137PassRefPtr<WorkerFileSystemCallbacksBridge> WorkerAsyncFileSystemChromium::createWorkerFileSystemCallbacksBridge(PassOwnPtr<AsyncFileSystemCallbacks> callbacks)
    125138{
    126     return WorkerFileSystemCallbacksBridge::create(m_worker, m_scriptExecutionContext, new WebFileSystemCallbacksImpl(callbacks));
     139    ASSERT(!m_synchronous || !m_bridgeForCurrentOperation.get());
     140
     141    m_modeForCurrentOperation = fileSystemOperationsMode;
     142    m_modeForCurrentOperation.append(String::number(m_workerContext->thread()->runLoop().createUniqueId()));
     143
     144    m_bridgeForCurrentOperation = WorkerFileSystemCallbacksBridge::create(m_worker, m_scriptExecutionContext, new WebKit::WebFileSystemCallbacksImpl(callbacks));
     145    return m_bridgeForCurrentOperation;
    127146}
    128147
  • trunk/WebKit/chromium/src/WorkerAsyncFileSystemChromium.h

    r68672 r69249  
    4949class AsyncFileSystemCallbacks;
    5050class ScriptExecutionContext;
     51class WorkerContext;
    5152
    5253class WorkerAsyncFileSystemChromium : public AsyncFileSystem {
    5354public:
    54     static PassOwnPtr<AsyncFileSystem> create(ScriptExecutionContext* context, const String& rootPath)
     55    static PassOwnPtr<AsyncFileSystem> create(ScriptExecutionContext* context, const String& rootPath, bool synchronous)
    5556    {
    56         return adoptPtr(new WorkerAsyncFileSystemChromium(context, rootPath));
     57        return adoptPtr(new WorkerAsyncFileSystemChromium(context, rootPath, synchronous));
    5758    }
    5859
    5960    virtual ~WorkerAsyncFileSystemChromium();
     61
     62    // Runs one pending operation (to wait for completion in the sync-mode).
     63    virtual bool waitForOperationToComplete();
    6064
    6165    virtual void move(const String& sourcePath, const String& destinationPath, PassOwnPtr<AsyncFileSystemCallbacks>);
     
    7175
    7276private:
    73     WorkerAsyncFileSystemChromium(ScriptExecutionContext*, const String& rootPath);
     77    WorkerAsyncFileSystemChromium(ScriptExecutionContext*, const String& rootPath, bool synchronous);
     78
    7479    PassRefPtr<WebKit::WorkerFileSystemCallbacksBridge> createWorkerFileSystemCallbacksBridge(PassOwnPtr<AsyncFileSystemCallbacks>);
    7580
     
    7782    WebKit::WebFileSystem* m_webFileSystem;
    7883    WebKit::WebWorkerBase* m_worker;
    79     String m_mode;
     84    WorkerContext* m_workerContext;
     85    RefPtr<WebKit::WorkerFileSystemCallbacksBridge> m_bridgeForCurrentOperation;
     86    String m_modeForCurrentOperation;
     87    bool m_synchronous;
    8088};
    8189
Note: See TracChangeset for help on using the changeset viewer.