Changeset 69249 in webkit
- Timestamp:
- Oct 6, 2010 4:08:50 PM (14 years ago)
- Location:
- trunk
- Files:
-
- 9 added
- 1 deleted
- 53 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r69247 r69249 1 2010-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 1 20 2010-10-06 Andrei Popescu <andreip@google.com> 2 21 -
trunk/LayoutTests/fast/filesystem/resources/fs-test-util.js
r68735 r69249 1 function 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 1 11 // Usage: 2 12 // var helper = new JoinHelper; … … 56 66 }; 57 67 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 else65 callback.apply(obj, [arg, arg1, arg2, arg3]);66 };67 };68 69 68 this.removeDirectory = function(directory, parentDirectory) 70 69 { 71 70 if (directory.fullPath != '/') { 72 71 // 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)); 74 73 } else 75 74 delete this.removeDirMap[directory.fullPath]; … … 98 97 else { 99 98 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)); 101 100 } 102 101 } 103 102 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)); 105 104 } else { 106 105 var dirInfo = this.removeDirMap[directory.fullPath]; … … 120 119 reader: directoryReader, 121 120 }; 122 directoryReader.readEntries( this.bind(this.removeRecursivelyCallback, directory), this.bind(this.errorCallback));121 directoryReader.readEntries(bindCallback(this, this.removeRecursivelyCallback, directory), bindCallback(this, this.errorCallback)); 123 122 }; 124 123 }; -
trunk/LayoutTests/fast/filesystem/resources/fs-worker-common.js
r69178 r69249 28 28 function shouldBeTrue(_a) { shouldBe(_a, "true"); } 29 29 30 function 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 30 47 if (this.importScripts && !this.requestFileSystem) { 31 48 debug('This test requires FileSystem API.'); 32 49 finishJSTest(); 33 50 } 34 35 onmessage = function(event) {36 importScripts(event.data);37 } -
trunk/LayoutTests/fast/filesystem/resources/fs-worker-test-pre.js
r69178 r69249 10 10 { 11 11 debug('Starting worker: ' + testScriptURL); 12 var worker = new Worker('../resources/fs-worker-common.js'); 13 worker.postMessage(testScriptURL); 12 var worker = new Worker(testScriptURL); 14 13 worker.onmessage = function(event) 15 14 { -
trunk/LayoutTests/fast/filesystem/resources/simple-persistent-sync.js
r69178 r69249 1 if (this.importScripts) { 2 importScripts('../resources/fs-worker-common.js'); 3 importScripts('../resources/fs-test-util.js'); 4 } 5 1 6 description("requestFileSystemSync PERSISTENT test."); 2 7 -
trunk/LayoutTests/fast/filesystem/resources/simple-persistent.js
r69178 r69249 1 if (this.importScripts) { 2 importScripts('../resources/fs-worker-common.js'); 3 importScripts('../resources/fs-test-util.js'); 4 } 5 1 6 description("requestFileSystem PERSISTENT test."); 2 7 -
trunk/LayoutTests/fast/filesystem/resources/simple-temporary-sync.js
r69178 r69249 1 if (this.importScripts) { 2 importScripts('../resources/fs-worker-common.js'); 3 importScripts('../resources/fs-test-util.js'); 4 } 5 1 6 description("requestFileSystemSync TEMPORARY test."); 2 7 -
trunk/LayoutTests/fast/filesystem/resources/simple-temporary.js
r69178 r69249 1 if (this.importScripts) { 2 importScripts('../resources/fs-worker-common.js'); 3 importScripts('../resources/fs-test-util.js'); 4 } 5 1 6 description("requestFileSystem TEMPORARY test."); 2 7 -
trunk/LayoutTests/fast/filesystem/script-tests/flags-passing.js
r69178 r69249 95 95 96 96 if (window.requestFileSystem) { 97 window.jsTestIsAsync = true; 97 98 requestFileSystem(window.TEMPORARY, 100, fileSystemCallback, errorCallback); 98 window.jsTestIsAsync = true;99 99 } else 100 100 debug("This test requires FileSystem API support."); -
trunk/LayoutTests/fast/filesystem/workers/simple-persistent-expected.txt
r69178 r69249 3 3 Starting worker: ../resources/simple-persistent.js 4 4 Description: requestFileSystem PERSISTENT test. 5 Successfully obtained PERSISTENT FileSystem:file__0: Temporary5 Successfully obtained PERSISTENT FileSystem:file__0:Persistent 6 6 PASS: fileSystem.name.length > 0 is true 7 7 PASS: fileSystem.root.fullPath is "/" -
trunk/LayoutTests/fast/filesystem/workers/simple-persistent-sync-expected.txt
r69178 r69249 3 3 Starting worker: ../resources/simple-persistent-sync.js 4 4 Description: requestFileSystemSync PERSISTENT test. 5 Got error from worker: Uncaught ReferenceError: requestFileSystemSync is not defined 5 Successfully obtained PERSISTENT FileSystem:file__0:Persistent 6 PASS: fileSystem.name.length > 0 is true 7 PASS: fileSystem.root.fullPath is "/" 8 DONE 6 9 7 10 TEST COMPLETE -
trunk/LayoutTests/fast/filesystem/workers/simple-temporary-sync-expected.txt
r69178 r69249 3 3 Starting worker: ../resources/simple-temporary-sync.js 4 4 Description: requestFileSystemSync TEMPORARY test. 5 Got error from worker: Uncaught ReferenceError: requestFileSystemSync is not defined 5 Successfully obtained TEMPORARY FileSystem:file__0:Temporary 6 PASS: fileSystem.name.length > 0 is true 7 PASS: fileSystem.root.fullPath is "/" 8 DONE 6 9 7 10 TEST COMPLETE -
trunk/WebCore/ChangeLog
r69247 r69249 926 926 (WebCore::SVGFilter::maxImageSize): 927 927 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=47085934 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 API944 https://bugs.webkit.org/show_bug.cgi?id=46405945 946 Added bunch of *Sync classes, plus refactored some classes:947 Added DOMFileSystemBase as a common base class for DOMFileSystem and948 DOMFileSystemSync.949 Added EntryBase as a common base class for Entry and EntrySync.950 Added DirectoryReaderBase as a common base class for DirectoryReader and951 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=45940997 998 Test: fast/forms/input-placeholder-focus-twice.html999 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 if1004 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 IKeysMapping1013 https://bugs.webkit.org/show_bug.cgi?id=472341014 1015 Brew MP devices have a variey of key configurations and use modifiers to1016 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 ImageLayerChromium1026 https://bugs.webkit.org/show_bug.cgi?id=464931027 1028 Mipmap behaviour can be tested with existing tests.1029 Tests in LayoutTests/compositing/images/ will detect if1030 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 tags1046 https://bugs.webkit.org/show_bug.cgi?id=471901047 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=470301059 1060 Refactored LayerChromium to have a virtual cleanupResources() method1061 that will release textures/other context-dependent resources when a1062 LayerRenderer changes. ContentLayerChromium and VideoLayerChromium now1063 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 1076 928 2010-10-05 Kinuko Yasuda <kinuko@chromium.org> 1077 929 … … 1085 937 * fileapi/FileEntry.cpp: 1086 938 (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=467651094 1095 Render textures in VideoLayerChromium directly if the video frame type1096 is GL texture. In the future VideoLayerChromium will not allocate1097 textures and perform textures upload as those operations will be done1098 in Chromium to minimize memory copy. This patch will help moving toward1099 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 pages1120 https://bugs.webkit.org/show_bug.cgi?id=451311121 1122 When border-collapse: separate property is set on the table, paintObject1123 may skip repainting cells, if the dirty region only touches one row/col of pixels.1124 1125 Test: fast/table/simple_paint_separate_borders.html1126 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=471291137 1138 * html/PluginDocument.cpp:1139 (WebCore::PluginDocumentParser::createDocumentStructure):1140 (WebCore::PluginDocument::pluginWidget):1141 (WebCore::PluginDocument::pluginNode):1142 * html/PluginDocument.h:1143 (WebCore::PluginDocument::setPluginNode):1144 939 1145 940 2010-10-05 Andreas Kling <kling@webkit.org> -
trunk/WebCore/WebCore.gypi
r69183 r69249 1521 1521 'fileapi/Metadata.h', 1522 1522 'fileapi/MetadataCallback.h', 1523 'fileapi/SyncCallbackHelper.h', 1523 1524 'fileapi/ThreadableBlobRegistry.cpp', 1524 1525 'fileapi/ThreadableBlobRegistry.h', -
trunk/WebCore/bindings/generic/RuntimeEnabledFeatures.h
r69099 r69249 151 151 static bool fileSystemEnabled(); 152 152 static void setFileSystemEnabled(bool isEnabled) { isFileSystemEnabled = isEnabled; } 153 static bool requestFileSystemEnabled() { return isFileSystemEnabled; }154 153 #endif 155 154 -
trunk/WebCore/fileapi/DOMFileSystem.cpp
r69178 r69249 37 37 #include "DOMFilePath.h" 38 38 #include "DirectoryEntry.h" 39 #include "EntriesCallback.h"40 #include "Entry.h"41 #include "EntryArray.h"42 #include "EntryCallback.h"43 39 #include "ErrorCallback.h" 44 40 #include "FileEntry.h" 45 #include "FileError.h"46 41 #include "FileSystemCallbacks.h" 47 42 #include "FileWriter.h" … … 49 44 #include "MetadataCallback.h" 50 45 #include "ScriptExecutionContext.h" 51 #include "VoidCallback.h"52 46 #include <wtf/OwnPtr.h> 53 47 … … 81 75 } 82 76 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 else121 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 else139 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 else178 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 else198 m_asyncFileSystem->directoryExists(platformPath, callbacks.release());199 }200 201 77 void DOMFileSystem::createWriter(const FileEntry* file, PassRefPtr<FileWriterCallback> successCallback, PassRefPtr<ErrorCallback> errorCallback) 202 78 { … … 210 86 } 211 87 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 219 88 } // namespace 220 89 -
trunk/WebCore/fileapi/DOMFileSystem.h
r69178 r69249 35 35 36 36 #include "ActiveDOMObject.h" 37 #include "AsyncFileSystem.h"38 37 #include "DOMFileSystemBase.h" 39 #include "Flags.h"40 #include "PlatformString.h"41 38 #include "ScriptExecutionContext.h" 42 #include <wtf/PassRefPtr.h>43 #include <wtf/RefCounted.h>44 39 45 40 namespace WebCore { 46 41 47 42 class DirectoryEntry; 48 class DirectoryReader;49 class Entry;50 class EntryCallback;51 class EntriesCallback;52 class ErrorCallback;53 43 class FileEntry; 54 44 class FileWriterCallback; 55 class MetadataCallback;56 class VoidCallback;57 45 58 46 class DOMFileSystem : public DOMFileSystemBase, public ActiveDOMObject { … … 70 58 virtual void contextDestroyed(); 71 59 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>);81 60 void createWriter(const FileEntry* file, PassRefPtr<FileWriterCallback>, PassRefPtr<ErrorCallback>); 82 61 … … 96 75 97 76 // A helper template to schedule a callback task. 98 // FIXME: move this to a more generic place.99 77 template <typename CB, typename CBArg> 100 78 class DispatchCallbackTask : public ScriptExecutionContext::Task { … … 121 99 { 122 100 ASSERT(scriptExecutionContext->isContextThread()); 101 ASSERT(callback); 123 102 scriptExecutionContext->postTask(new DispatchCallbackTask<CB, CBArg>(callback, arg)); 124 103 } -
trunk/WebCore/fileapi/DOMFileSystemBase.cpp
r69178 r69249 35 35 36 36 #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" 37 47 #include <wtf/OwnPtr.h> 38 48 … … 49 59 } 50 60 61 bool 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 68 static 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 89 bool 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 106 bool 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 123 bool 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 131 bool 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 140 bool 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 159 bool 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 178 bool 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 51 186 } // namespace WebCore 52 187 -
trunk/WebCore/fileapi/DOMFileSystemBase.h
r69178 r69249 35 35 36 36 #include "AsyncFileSystem.h" 37 #include "Flags.h" 37 38 #include "PlatformString.h" 38 39 #include <wtf/PassRefPtr.h> … … 40 41 41 42 namespace WebCore { 43 44 class DirectoryEntry; 45 class DirectoryReaderBase; 46 class EntriesCallback; 47 class EntryBase; 48 class EntryCallback; 49 class ErrorCallback; 50 class MetadataCallback; 51 class VoidCallback; 42 52 43 53 // A common base class for DOMFileSystem and DOMFileSystemSync. … … 52 62 const String& name() const { return m_name; } 53 63 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>); 54 75 55 76 protected: -
trunk/WebCore/fileapi/DOMFileSystemSync.cpp
r69178 r69249 39 39 namespace WebCore { 40 40 41 PassRefPtr<DOMFileSystemSync> DOMFileSystemSync::create(DOMFileSystemBase* fileSystem) 42 { 43 return adoptRef(new DOMFileSystemSync(fileSystem->m_name, fileSystem->m_asyncFileSystem.release())); 44 } 45 41 46 DOMFileSystemSync::DOMFileSystemSync(const String& name, PassOwnPtr<AsyncFileSystem> asyncFileSystem) 42 47 : DOMFileSystemBase(name, asyncFileSystem) -
trunk/WebCore/fileapi/DOMFileSystemSync.h
r69178 r69249 49 49 } 50 50 51 static PassRefPtr<DOMFileSystemSync> create(DOMFileSystemBase*); 52 51 53 virtual ~DOMFileSystemSync(); 52 54 -
trunk/WebCore/fileapi/DirectoryEntry.cpp
r69178 r69249 37 37 #include "EntryCallback.h" 38 38 #include "ErrorCallback.h" 39 #include "FileError.h" 39 40 40 41 namespace WebCore { 41 42 42 DirectoryEntry::DirectoryEntry(DOMFileSystem * fileSystem, const String& fullPath)43 DirectoryEntry::DirectoryEntry(DOMFileSystemBase* fileSystem, const String& fullPath) 43 44 : Entry(fileSystem, fullPath) 44 45 { … … 50 51 } 51 52 52 void DirectoryEntry::getFile(const String& path, PassRefPtr<Flags> flags, PassRefPtr<EntryCallback> successCallback, PassRefPtr<ErrorCallback> errorCallback )53 void DirectoryEntry::getFile(const String& path, PassRefPtr<Flags> flags, PassRefPtr<EntryCallback> successCallback, PassRefPtr<ErrorCallback> errorCallbackRef) 53 54 { 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)); 55 58 } 56 59 57 void DirectoryEntry::getDirectory(const String& path, PassRefPtr<Flags> flags, PassRefPtr<EntryCallback> successCallback, PassRefPtr<ErrorCallback> errorCallback )60 void DirectoryEntry::getDirectory(const String& path, PassRefPtr<Flags> flags, PassRefPtr<EntryCallback> successCallback, PassRefPtr<ErrorCallback> errorCallbackRef) 58 61 { 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)); 60 65 } 61 66 62 } // namespace67 } 63 68 64 69 #endif // ENABLE(FILE_SYSTEM) -
trunk/WebCore/fileapi/DirectoryEntry.h
r67443 r69249 42 42 namespace WebCore { 43 43 44 class DOMFileSystemBase; 44 45 class DirectoryReader; 45 46 class EntryCallback; … … 48 49 class DirectoryEntry : public Entry { 49 50 public: 50 static PassRefPtr<DirectoryEntry> create(DOMFileSystem * fileSystem, const String& fullPath)51 static PassRefPtr<DirectoryEntry> create(DOMFileSystemBase* fileSystem, const String& fullPath) 51 52 { 52 53 return adoptRef(new DirectoryEntry(fileSystem, fullPath)); … … 59 60 60 61 private: 61 DirectoryEntry(DOMFileSystem * fileSystem, const String& fullPath);62 DirectoryEntry(DOMFileSystemBase*, const String& fullPath); 62 63 }; 63 64 -
trunk/WebCore/fileapi/DirectoryEntrySync.cpp
r69178 r69249 37 37 #include "EntrySync.h" 38 38 #include "FileEntrySync.h" 39 #include " NotImplemented.h"39 #include "SyncCallbackHelper.h" 40 40 41 41 namespace WebCore { … … 51 51 } 52 52 53 PassRefPtr<FileEntrySync> DirectoryEntrySync::getFile(const String& , PassRefPtr<Flags>, ExceptionCode&)53 PassRefPtr<FileEntrySync> DirectoryEntrySync::getFile(const String& path, PassRefPtr<Flags> flags, ExceptionCode& ec) 54 54 { 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)); 58 62 } 59 63 60 PassRefPtr<DirectoryEntrySync> DirectoryEntrySync::getDirectory(const String& , PassRefPtr<Flags>, ExceptionCode&)64 PassRefPtr<DirectoryEntrySync> DirectoryEntrySync::getDirectory(const String& path, PassRefPtr<Flags> flags, ExceptionCode& ec) 61 65 { 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)); 65 73 } 66 74 -
trunk/WebCore/fileapi/DirectoryReaderSync.cpp
r69178 r69249 34 34 #if ENABLE(FILE_SYSTEM) 35 35 36 #include "DirectoryEntry.h" 37 #include "DirectoryEntrySync.h" 36 38 #include "EntryArraySync.h" 39 #include "EntrySync.h" 37 40 #include "ExceptionCode.h" 38 #include "NotImplemented.h" 41 #include "FileEntrySync.h" 42 #include "FileError.h" 43 #include "SyncCallbackHelper.h" 39 44 40 45 namespace WebCore { … … 45 50 } 46 51 47 PassRefPtr<EntryArraySync> DirectoryReaderSync::readEntries(ExceptionCode& )52 PassRefPtr<EntryArraySync> DirectoryReaderSync::readEntries(ExceptionCode& ec) 48 53 { 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); 51 65 } 52 66 -
trunk/WebCore/fileapi/Entry.cpp
r69178 r69249 33 33 #if ENABLE(FILE_SYSTEM) 34 34 35 #include "DOMFilePath.h" 36 #include "DOMFileSystem.h" 35 #include "DirectoryEntry.h" 37 36 #include "EntryCallback.h" 38 37 #include "ErrorCallback.h" 39 38 #include "FileError.h" 39 #include "FileSystemCallbacks.h" 40 40 #include "MetadataCallback.h" 41 41 #include "VoidCallback.h" … … 43 43 namespace WebCore { 44 44 45 Entry::Entry(DOMFileSystem * fileSystem, const String& fullPath)45 Entry::Entry(DOMFileSystemBase* fileSystem, const String& fullPath) 46 46 : EntryBase(fileSystem, fullPath) 47 47 { 48 48 } 49 49 50 void Entry::getMetadata(PassRefPtr<MetadataCallback> successCallback, PassRefPtr<ErrorCallback> errorCallback )50 void Entry::getMetadata(PassRefPtr<MetadataCallback> successCallback, PassRefPtr<ErrorCallback> errorCallbackRef) 51 51 { 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)); 53 55 } 54 56 55 void Entry::moveTo(PassRefPtr< Entry> parent, const String& name, PassRefPtr<EntryCallback> successCallback, PassRefPtr<ErrorCallback> errorCallback) const57 void Entry::moveTo(PassRefPtr<DirectoryEntry> parent, const String& name, PassRefPtr<EntryCallback> successCallback, PassRefPtr<ErrorCallback> errorCallbackRef) const 56 58 { 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)); 58 62 } 59 63 60 void Entry::copyTo(PassRefPtr< Entry> parent, const String& name, PassRefPtr<EntryCallback> successCallback, PassRefPtr<ErrorCallback> errorCallback) const64 void Entry::copyTo(PassRefPtr<DirectoryEntry> parent, const String& name, PassRefPtr<EntryCallback> successCallback, PassRefPtr<ErrorCallback> errorCallbackRef) const 61 65 { 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)); 63 69 } 64 70 65 void Entry::remove(PassRefPtr<VoidCallback> successCallback, PassRefPtr<ErrorCallback> errorCallback ) const71 void Entry::remove(PassRefPtr<VoidCallback> successCallback, PassRefPtr<ErrorCallback> errorCallbackRef) const 66 72 { 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)); 68 76 } 69 77 70 void Entry::getParent(PassRefPtr<EntryCallback> successCallback, PassRefPtr<ErrorCallback> errorCallback ) const78 void Entry::getParent(PassRefPtr<EntryCallback> successCallback, PassRefPtr<ErrorCallback> errorCallbackRef) const 71 79 { 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)); 73 83 } 74 84 -
trunk/WebCore/fileapi/Entry.h
r69178 r69249 41 41 namespace WebCore { 42 42 43 class DirectoryEntry; 43 44 class EntryCallback; 45 class EntrySync; 44 46 class ErrorCallback; 45 47 class MetadataCallback; … … 48 50 class Entry : public EntryBase { 49 51 public: 50 virtual ~Entry() { }51 52 52 DOMFileSystem* filesystem() const { return static_cast<DOMFileSystem*>(m_fileSystem); } 53 53 54 54 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; 57 57 virtual void remove(PassRefPtr<VoidCallback> successCallback = 0, PassRefPtr<ErrorCallback> errorCallback = 0) const; 58 58 virtual void getParent(PassRefPtr<EntryCallback> successCallback = 0, PassRefPtr<ErrorCallback> errorCallback = 0) const; … … 61 61 62 62 protected: 63 Entry(DOMFileSystem * fileSystem, const String& fullPath);63 Entry(DOMFileSystemBase*, const String& fullPath); 64 64 }; 65 65 -
trunk/WebCore/fileapi/Entry.idl
r67917 r69249 42 42 43 43 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); 46 46 void remove(in [Optional, Callback] VoidCallback successCallback, in [Optional, Callback] ErrorCallback errorCallback); 47 47 void getParent(in [Optional, Callback] EntryCallback successCallback, in [Optional, Callback] ErrorCallback errorCallback); -
trunk/WebCore/fileapi/EntryArraySync.cpp
r69178 r69249 34 34 #if ENABLE(FILE_SYSTEM) 35 35 36 #include "EntryArray.h" 37 36 38 namespace WebCore { 39 40 PassRefPtr<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 } 37 49 38 50 EntryArraySync::EntryArraySync() -
trunk/WebCore/fileapi/EntryArraySync.h
r69178 r69249 49 49 } 50 50 51 static PassRefPtr<EntryArraySync> create(EntryArray*); 52 51 53 unsigned length() const { return m_entries.size(); } 52 54 EntrySync* item(unsigned index) const; -
trunk/WebCore/fileapi/EntryBase.h
r69178 r69249 49 49 virtual ~EntryBase() { } 50 50 51 DOMFileSystemBase* filesystem() const { return m_fileSystem; } 52 51 53 virtual bool isFile() const { return false; } 52 54 virtual bool isDirectory() const { return false; } -
trunk/WebCore/fileapi/EntrySync.cpp
r69178 r69249 35 35 36 36 #include "DOMFilePath.h" 37 #include "DOMFileSystemSync.h" 38 #include "DirectoryEntry.h" 37 39 #include "DirectoryEntrySync.h" 40 #include "FileEntrySync.h" 38 41 #include "Metadata.h" 39 #include " NotImplemented.h"42 #include "SyncCallbackHelper.h" 40 43 41 44 namespace WebCore { 42 45 43 PassRefPtr< Metadata> EntrySync::getMetadata(ExceptionCode&)46 PassRefPtr<EntrySync> EntrySync::create(EntryBase* entry) 44 47 { 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)); 48 51 } 49 52 50 PassRefPtr< EntrySync> EntrySync::moveTo(PassRefPtr<DirectoryEntrySync>, const String&, ExceptionCode&) const53 PassRefPtr<Metadata> EntrySync::getMetadata(ExceptionCode& ec) 51 54 { 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); 55 62 } 56 63 57 PassRefPtr<EntrySync> EntrySync:: copyTo(PassRefPtr<DirectoryEntrySync>, const String&, ExceptionCode&) const64 PassRefPtr<EntrySync> EntrySync::moveTo(PassRefPtr<DirectoryEntrySync> parent, const String& name, ExceptionCode& ec) const 58 65 { 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); 62 73 } 63 74 64 void EntrySync::remove(ExceptionCode&) const75 PassRefPtr<EntrySync> EntrySync::copyTo(PassRefPtr<DirectoryEntrySync> parent, const String& name, ExceptionCode& ec) const 65 76 { 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 86 void 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); 68 93 } 69 94 -
trunk/WebCore/fileapi/EntrySync.h
r69178 r69249 48 48 class EntrySync : public EntryBase { 49 49 public: 50 static PassRefPtr<EntrySync> create(EntryBase*); 51 50 52 DOMFileSystemSync* filesystem() const { return static_cast<DOMFileSystemSync*>(m_fileSystem); } 51 53 -
trunk/WebCore/fileapi/FileEntry.cpp
r69178 r69249 42 42 namespace WebCore { 43 43 44 FileEntry::FileEntry(DOMFileSystem * fileSystem, const String& fullPath)44 FileEntry::FileEntry(DOMFileSystemBase* fileSystem, const String& fullPath) 45 45 : Entry(fileSystem, fullPath) 46 46 { -
trunk/WebCore/fileapi/FileEntry.h
r67614 r69249 40 40 namespace WebCore { 41 41 42 class DOMFileSystem ;42 class DOMFileSystemBase; 43 43 44 44 class FileEntry : public Entry { 45 45 public: 46 static PassRefPtr<FileEntry> create(DOMFileSystem * fileSystem, const String& fullPath)46 static PassRefPtr<FileEntry> create(DOMFileSystemBase* fileSystem, const String& fullPath) 47 47 { 48 48 return adoptRef(new FileEntry(fileSystem, fullPath)); … … 55 55 56 56 private: 57 FileEntry(DOMFileSystem * fileSystem, const String& fullPath);57 FileEntry(DOMFileSystemBase* fileSystem, const String& fullPath); 58 58 }; 59 59 -
trunk/WebCore/fileapi/FileSystemCallbacks.cpp
r69178 r69249 37 37 #include "AsyncFileWriter.h" 38 38 #include "DOMFilePath.h" 39 #include "DOMFileSystem .h"39 #include "DOMFileSystemBase.h" 40 40 #include "DirectoryEntry.h" 41 41 #include "DirectoryReader.h" … … 112 112 // EntryCallbacks ------------------------------------------------------------- 113 113 114 PassOwnPtr<EntryCallbacks> EntryCallbacks::create(PassRefPtr<EntryCallback> successCallback, PassRefPtr<ErrorCallback> errorCallback, DOMFileSystem * fileSystem, const String& expectedPath, bool isDirectory)114 PassOwnPtr<EntryCallbacks> EntryCallbacks::create(PassRefPtr<EntryCallback> successCallback, PassRefPtr<ErrorCallback> errorCallback, DOMFileSystemBase* fileSystem, const String& expectedPath, bool isDirectory) 115 115 { 116 116 return adoptPtr(new EntryCallbacks(successCallback, errorCallback, fileSystem, expectedPath, isDirectory)); 117 117 } 118 118 119 EntryCallbacks::EntryCallbacks(PassRefPtr<EntryCallback> successCallback, PassRefPtr<ErrorCallback> errorCallback, DOMFileSystem * fileSystem, const String& expectedPath, bool isDirectory)119 EntryCallbacks::EntryCallbacks(PassRefPtr<EntryCallback> successCallback, PassRefPtr<ErrorCallback> errorCallback, DOMFileSystemBase* fileSystem, const String& expectedPath, bool isDirectory) 120 120 : FileSystemCallbacksBase(errorCallback) 121 121 , m_successCallback(successCallback) … … 139 139 // EntriesCallbacks ----------------------------------------------------------- 140 140 141 PassOwnPtr<EntriesCallbacks> EntriesCallbacks::create(PassRefPtr<EntriesCallback> successCallback, PassRefPtr<ErrorCallback> errorCallback, DirectoryReader * directoryReader, const String& basePath)141 PassOwnPtr<EntriesCallbacks> EntriesCallbacks::create(PassRefPtr<EntriesCallback> successCallback, PassRefPtr<ErrorCallback> errorCallback, DirectoryReaderBase* directoryReader, const String& basePath) 142 142 { 143 143 return adoptPtr(new EntriesCallbacks(successCallback, errorCallback, directoryReader, basePath)); 144 144 } 145 145 146 EntriesCallbacks::EntriesCallbacks(PassRefPtr<EntriesCallback> successCallback, PassRefPtr<ErrorCallback> errorCallback, DirectoryReader * directoryReader, const String& basePath)146 EntriesCallbacks::EntriesCallbacks(PassRefPtr<EntriesCallback> successCallback, PassRefPtr<ErrorCallback> errorCallback, DirectoryReaderBase* directoryReader, const String& basePath) 147 147 : FileSystemCallbacksBase(errorCallback) 148 148 , m_successCallback(successCallback) -
trunk/WebCore/fileapi/FileSystemCallbacks.h
r68735 r69249 42 42 43 43 class AsyncFileWriter; 44 class DOMFileSystem ;45 class DirectoryReader ;44 class DOMFileSystemBase; 45 class DirectoryReaderBase; 46 46 class ErrorCallback; 47 47 class EntriesCallback; … … 87 87 class EntryCallbacks : public FileSystemCallbacksBase { 88 88 public: 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); 90 90 virtual void didSucceed(); 91 91 92 92 private: 93 EntryCallbacks(PassRefPtr<EntryCallback>, PassRefPtr<ErrorCallback>, DOMFileSystem *, const String& expectedPath, bool isDirectory);93 EntryCallbacks(PassRefPtr<EntryCallback>, PassRefPtr<ErrorCallback>, DOMFileSystemBase*, const String& expectedPath, bool isDirectory); 94 94 RefPtr<EntryCallback> m_successCallback; 95 DOMFileSystem * m_fileSystem;95 DOMFileSystemBase* m_fileSystem; 96 96 String m_expectedPath; 97 97 bool m_isDirectory; … … 100 100 class EntriesCallbacks : public FileSystemCallbacksBase { 101 101 public: 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); 103 103 virtual void didReadDirectoryEntry(const String& name, bool isDirectory); 104 104 virtual void didReadDirectoryEntries(bool hasMore); 105 105 106 106 private: 107 EntriesCallbacks(PassRefPtr<EntriesCallback>, PassRefPtr<ErrorCallback>, DirectoryReader *, const String& basePath);107 EntriesCallbacks(PassRefPtr<EntriesCallback>, PassRefPtr<ErrorCallback>, DirectoryReaderBase*, const String& basePath); 108 108 RefPtr<EntriesCallback> m_successCallback; 109 DirectoryReader * m_directoryReader;109 DirectoryReaderBase* m_directoryReader; 110 110 String m_basePath; 111 111 RefPtr<EntryArray> m_entries; -
trunk/WebCore/fileapi/LocalFileSystem.cpp
r68411 r69249 82 82 } 83 83 84 void LocalFileSystem::requestFileSystem(ScriptExecutionContext* context, AsyncFileSystem::Type type, long long, PassOwnPtr<AsyncFileSystemCallbacks> callbacks )84 void LocalFileSystem::requestFileSystem(ScriptExecutionContext* context, AsyncFileSystem::Type type, long long, PassOwnPtr<AsyncFileSystemCallbacks> callbacks, bool) 85 85 { 86 86 // AsyncFileSystem::openFileSystem calls callbacks synchronously, so the method needs to be called asynchronously. -
trunk/WebCore/fileapi/LocalFileSystem.h
r68411 r69249 53 53 static LocalFileSystem& localFileSystem(); 54 54 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); 56 56 57 57 #if !PLATFORM(CHROMIUM) -
trunk/WebCore/fileapi/Metadata.h
r66642 r69249 45 45 } 46 46 47 static PassRefPtr<Metadata> create(Metadata* metadata) 48 { 49 return adoptRef(new Metadata(metadata->m_modificationTime)); 50 } 51 47 52 // Needs to return epoch time in milliseconds for Date. 48 53 double modificationTime() const { return m_modificationTime * 1000.0; } -
trunk/WebCore/page/DOMWindow.idl
r68440 r69249 193 193 const unsigned short TEMPORARY = 0; 194 194 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); 196 196 197 197 attribute [EnabledAtRuntime=FileSystem] FlagsConstructor Flags; -
trunk/WebCore/platform/AsyncFileSystem.h
r68222 r69249 59 59 60 60 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; } 61 65 62 66 // Creates and returns a new platform-specific AsyncFileSystem instance if the platform has its own implementation. -
trunk/WebCore/workers/WorkerContext.cpp
r68411 r69249 67 67 #include "AsyncFileSystem.h" 68 68 #include "DOMFileSystem.h" 69 #include "DOMFileSystemSync.h" 69 70 #include "ErrorCallback.h" 70 71 #include "FileError.h" … … 72 73 #include "FileSystemCallbacks.h" 73 74 #include "LocalFileSystem.h" 75 #include "SyncCallbackHelper.h" 74 76 #endif 75 77 … … 367 369 } 368 370 371 PassRefPtr<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 369 390 COMPILE_ASSERT(static_cast<int>(WorkerContext::TEMPORARY) == static_cast<int>(AsyncFileSystem::Temporary), enum_mismatch); 370 391 COMPILE_ASSERT(static_cast<int>(WorkerContext::PERSISTENT) == static_cast<int>(AsyncFileSystem::Persistent), enum_mismatch); -
trunk/WebCore/workers/WorkerContext.h
r68222 r69249 46 46 47 47 class Blob; 48 class DOMFileSystemSync; 48 49 class Database; 49 50 class DatabaseCallback; … … 131 132 }; 132 133 void requestFileSystem(int type, long long size, PassRefPtr<FileSystemCallback>, PassRefPtr<ErrorCallback>); 134 PassRefPtr<DOMFileSystemSync> requestFileSystemSync(int type, long long size, ExceptionCode&); 133 135 #endif 134 136 -
trunk/WebCore/workers/WorkerContext.idl
r68222 r69249 109 109 const unsigned short TEMPORARY = 0; 110 110 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); 112 113 113 114 attribute [EnabledAtRuntime=FileSystem] FlagsConstructor Flags; -
trunk/WebKit/chromium/ChangeLog
r69247 r69249 1 2010-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 1 41 2010-10-06 Andrei Popescu <andreip@google.com> 2 42 -
trunk/WebKit/chromium/src/LocalFileSystemChromium.cpp
r68669 r69249 58 58 } 59 59 60 void LocalFileSystem::requestFileSystem(ScriptExecutionContext* context, AsyncFileSystem::Type type, long long size, PassOwnPtr<AsyncFileSystemCallbacks> callbacks )60 void LocalFileSystem::requestFileSystem(ScriptExecutionContext* context, AsyncFileSystem::Type type, long long size, PassOwnPtr<AsyncFileSystemCallbacks> callbacks, bool synchronous) 61 61 { 62 62 ASSERT(context); … … 69 69 WorkerLoaderProxy* workerLoaderProxy = &workerContext->thread()->workerLoaderProxy(); 70 70 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); 72 72 } 73 73 } -
trunk/WebKit/chromium/src/WebFileSystemCallbacksImpl.cpp
r68735 r69249 46 46 namespace WebKit { 47 47 48 WebFileSystemCallbacksImpl::WebFileSystemCallbacksImpl(PassOwnPtr<AsyncFileSystemCallbacks> callbacks, WebCore::ScriptExecutionContext* context )48 WebFileSystemCallbacksImpl::WebFileSystemCallbacksImpl(PassOwnPtr<AsyncFileSystemCallbacks> callbacks, WebCore::ScriptExecutionContext* context, bool synchronous) 49 49 : m_callbacks(callbacks) 50 50 , m_context(context) 51 , m_synchronous(synchronous) 51 52 { 52 53 ASSERT(m_callbacks); … … 80 81 { 81 82 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)); 83 84 else 84 85 m_callbacks->didOpenFileSystem(name, AsyncFileSystemChromium::create(path)); -
trunk/WebKit/chromium/src/WebFileSystemCallbacksImpl.h
r68669 r69249 50 50 class WebFileSystemCallbacksImpl : public WebFileSystemCallbacks { 51 51 public: 52 WebFileSystemCallbacksImpl(PassOwnPtr<WebCore::AsyncFileSystemCallbacks>, WebCore::ScriptExecutionContext* = 0 );52 WebFileSystemCallbacksImpl(PassOwnPtr<WebCore::AsyncFileSystemCallbacks>, WebCore::ScriptExecutionContext* = 0, bool synchronous = false); 53 53 virtual ~WebFileSystemCallbacksImpl(); 54 54 … … 64 64 // Used for worker's openFileSystem callbacks. 65 65 WebCore::ScriptExecutionContext* m_context; 66 bool m_synchronous; 66 67 }; 67 68 -
trunk/WebKit/chromium/src/WebWorkerBase.cpp
r68669 r69249 238 238 239 239 #if ENABLE(FILE_SYSTEM) 240 void WebWorkerBase::openFileSystem(WebFileSystem::Type type, long long size, WebFileSystemCallbacks* callbacks) 241 { 240 void WebWorkerBase::openFileSystem(WebFileSystem::Type type, long long size, WebFileSystemCallbacks* callbacks, bool synchronous) 241 { 242 WorkerRunLoop& runLoop = m_workerThread->runLoop(); 242 243 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 } 245 257 } 246 258 #endif -
trunk/WebKit/chromium/src/WebWorkerBase.h
r68226 r69249 94 94 #if ENABLE(FILE_SYSTEM) 95 95 // 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); 97 97 #endif 98 98 -
trunk/WebKit/chromium/src/WorkerAsyncFileSystemChromium.cpp
r68672 r69249 54 54 static const char fileSystemOperationsMode[] = "fileSystemOperationsMode"; 55 55 56 WorkerAsyncFileSystemChromium::WorkerAsyncFileSystemChromium(ScriptExecutionContext* context, const String& rootPath )56 WorkerAsyncFileSystemChromium::WorkerAsyncFileSystemChromium(ScriptExecutionContext* context, const String& rootPath, bool synchronous) 57 57 : AsyncFileSystem(rootPath) 58 58 , m_scriptExecutionContext(context) 59 59 , m_webFileSystem(WebKit::webKitClient()->fileSystem()) 60 , m_mode(fileSystemOperationsMode) 60 , m_workerContext(static_cast<WorkerContext*>(context)) 61 , m_synchronous(synchronous) 61 62 { 62 63 ASSERT(m_webFileSystem); 63 64 ASSERT(m_scriptExecutionContext->isWorkerContext()); 64 65 65 WorkerContext* workerContext = static_cast<WorkerContext*>(context); 66 WorkerLoaderProxy* workerLoaderProxy = &workerContext->thread()->workerLoaderProxy(); 66 WorkerLoaderProxy* workerLoaderProxy = &m_workerContext->thread()->workerLoaderProxy(); 67 67 m_worker = static_cast<WebWorkerBase*>(workerLoaderProxy); 68 68 } … … 72 72 } 73 73 74 bool 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 74 87 void WorkerAsyncFileSystemChromium::move(const String& sourcePath, const String& destinationPath, PassOwnPtr<AsyncFileSystemCallbacks> callbacks) 75 88 { 76 createWorkerFileSystemCallbacksBridge(callbacks)->postMoveToMainThread(m_webFileSystem, sourcePath, destinationPath, m_mode );89 createWorkerFileSystemCallbacksBridge(callbacks)->postMoveToMainThread(m_webFileSystem, sourcePath, destinationPath, m_modeForCurrentOperation); 77 90 } 78 91 79 92 void WorkerAsyncFileSystemChromium::copy(const String& sourcePath, const String& destinationPath, PassOwnPtr<AsyncFileSystemCallbacks> callbacks) 80 93 { 81 createWorkerFileSystemCallbacksBridge(callbacks)->postCopyToMainThread(m_webFileSystem, sourcePath, destinationPath, m_mode );94 createWorkerFileSystemCallbacksBridge(callbacks)->postCopyToMainThread(m_webFileSystem, sourcePath, destinationPath, m_modeForCurrentOperation); 82 95 } 83 96 84 97 void WorkerAsyncFileSystemChromium::remove(const String& path, PassOwnPtr<AsyncFileSystemCallbacks> callbacks) 85 98 { 86 createWorkerFileSystemCallbacksBridge(callbacks)->postRemoveToMainThread(m_webFileSystem, path, m_mode );99 createWorkerFileSystemCallbacksBridge(callbacks)->postRemoveToMainThread(m_webFileSystem, path, m_modeForCurrentOperation); 87 100 } 88 101 89 102 void WorkerAsyncFileSystemChromium::readMetadata(const String& path, PassOwnPtr<AsyncFileSystemCallbacks> callbacks) 90 103 { 91 createWorkerFileSystemCallbacksBridge(callbacks)->postReadMetadataToMainThread(m_webFileSystem, path, m_mode );104 createWorkerFileSystemCallbacksBridge(callbacks)->postReadMetadataToMainThread(m_webFileSystem, path, m_modeForCurrentOperation); 92 105 } 93 106 94 107 void WorkerAsyncFileSystemChromium::createFile(const String& path, bool exclusive, PassOwnPtr<AsyncFileSystemCallbacks> callbacks) 95 108 { 96 createWorkerFileSystemCallbacksBridge(callbacks)->postCreateFileToMainThread(m_webFileSystem, path, exclusive, m_mode );109 createWorkerFileSystemCallbacksBridge(callbacks)->postCreateFileToMainThread(m_webFileSystem, path, exclusive, m_modeForCurrentOperation); 97 110 } 98 111 99 112 void WorkerAsyncFileSystemChromium::createDirectory(const String& path, bool exclusive, PassOwnPtr<AsyncFileSystemCallbacks> callbacks) 100 113 { 101 createWorkerFileSystemCallbacksBridge(callbacks)->postCreateDirectoryToMainThread(m_webFileSystem, path, exclusive, m_mode );114 createWorkerFileSystemCallbacksBridge(callbacks)->postCreateDirectoryToMainThread(m_webFileSystem, path, exclusive, m_modeForCurrentOperation); 102 115 } 103 116 104 117 void WorkerAsyncFileSystemChromium::fileExists(const String& path, PassOwnPtr<AsyncFileSystemCallbacks> callbacks) 105 118 { 106 createWorkerFileSystemCallbacksBridge(callbacks)->postFileExistsToMainThread(m_webFileSystem, path, m_mode );119 createWorkerFileSystemCallbacksBridge(callbacks)->postFileExistsToMainThread(m_webFileSystem, path, m_modeForCurrentOperation); 107 120 } 108 121 109 122 void WorkerAsyncFileSystemChromium::directoryExists(const String& path, PassOwnPtr<AsyncFileSystemCallbacks> callbacks) 110 123 { 111 createWorkerFileSystemCallbacksBridge(callbacks)->postDirectoryExistsToMainThread(m_webFileSystem, path, m_mode );124 createWorkerFileSystemCallbacksBridge(callbacks)->postDirectoryExistsToMainThread(m_webFileSystem, path, m_modeForCurrentOperation); 112 125 } 113 126 114 127 void WorkerAsyncFileSystemChromium::readDirectory(const String& path, PassOwnPtr<AsyncFileSystemCallbacks> callbacks) 115 128 { 116 createWorkerFileSystemCallbacksBridge(callbacks)->postReadDirectoryToMainThread(m_webFileSystem, path, m_mode );129 createWorkerFileSystemCallbacksBridge(callbacks)->postReadDirectoryToMainThread(m_webFileSystem, path, m_modeForCurrentOperation); 117 130 } 118 131 … … 124 137 PassRefPtr<WorkerFileSystemCallbacksBridge> WorkerAsyncFileSystemChromium::createWorkerFileSystemCallbacksBridge(PassOwnPtr<AsyncFileSystemCallbacks> callbacks) 125 138 { 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; 127 146 } 128 147 -
trunk/WebKit/chromium/src/WorkerAsyncFileSystemChromium.h
r68672 r69249 49 49 class AsyncFileSystemCallbacks; 50 50 class ScriptExecutionContext; 51 class WorkerContext; 51 52 52 53 class WorkerAsyncFileSystemChromium : public AsyncFileSystem { 53 54 public: 54 static PassOwnPtr<AsyncFileSystem> create(ScriptExecutionContext* context, const String& rootPath )55 static PassOwnPtr<AsyncFileSystem> create(ScriptExecutionContext* context, const String& rootPath, bool synchronous) 55 56 { 56 return adoptPtr(new WorkerAsyncFileSystemChromium(context, rootPath ));57 return adoptPtr(new WorkerAsyncFileSystemChromium(context, rootPath, synchronous)); 57 58 } 58 59 59 60 virtual ~WorkerAsyncFileSystemChromium(); 61 62 // Runs one pending operation (to wait for completion in the sync-mode). 63 virtual bool waitForOperationToComplete(); 60 64 61 65 virtual void move(const String& sourcePath, const String& destinationPath, PassOwnPtr<AsyncFileSystemCallbacks>); … … 71 75 72 76 private: 73 WorkerAsyncFileSystemChromium(ScriptExecutionContext*, const String& rootPath); 77 WorkerAsyncFileSystemChromium(ScriptExecutionContext*, const String& rootPath, bool synchronous); 78 74 79 PassRefPtr<WebKit::WorkerFileSystemCallbacksBridge> createWorkerFileSystemCallbacksBridge(PassOwnPtr<AsyncFileSystemCallbacks>); 75 80 … … 77 82 WebKit::WebFileSystem* m_webFileSystem; 78 83 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; 80 88 }; 81 89
Note: See TracChangeset
for help on using the changeset viewer.