Changeset 81640 in webkit
- Timestamp:
- Mar 21, 2011 8:35:06 PM (13 years ago)
- Location:
- trunk
- Files:
-
- 10 added
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r81639 r81640 1 2011-03-21 Adam Klein <adamk@chromium.org> 2 3 Reviewed by David Levin. 4 5 [fileapi] Add URI resolution support to WorkerContext 6 https://bugs.webkit.org/show_bug.cgi?id=55644 7 8 Note that these tests do not run as part of new-run-webkit-tests, 9 but rather in Chromium's ui_test. I've run them locally and confirmed 10 they pass; a subsequent Chromium change will be submitted to run them 11 on the Chromium build bots. 12 13 * http/tests/filesystem/resources/fs-worker-common.js: Added. 14 * http/tests/filesystem/resources/fs-worker-test-util.js: Added. 15 Copied from fast/filesystem/resources for use by HTTP tests. 16 * http/tests/filesystem/script-tests/resolve-uri.js: 17 Updated to be used either in window or worker context. 18 * http/tests/filesystem/workers/resolve-url-expected.txt: Added. 19 * http/tests/filesystem/workers/resolve-url-sync-expected.txt: Added. 20 * http/tests/filesystem/workers/resolve-url-sync.html: Added. 21 * http/tests/filesystem/workers/resolve-url.html: Added. 22 * http/tests/filesystem/workers/script-tests/TEMPLATE.html: Added. 23 * http/tests/filesystem/workers/script-tests/resolve-url-sync.js: Added. 24 1 25 2011-03-21 David Levin <levin@chromium.org> 2 26 -
trunk/LayoutTests/http/tests/filesystem/script-tests/resolve-uri.js
r81438 r81640 1 if (this.importScripts) { 2 importScripts('../resources/fs-worker-common.js'); 3 importScripts('../resources/fs-test-util.js'); 4 } 5 1 6 description("Tests using resolveLocalFileSystemURL to obtain an Entry from a URL"); 2 7 … … 164 169 } 165 170 166 if ( window.requestFileSystem) {167 window.jsTestIsAsync = true;168 requestFileSystem( window.TEMPORARY, 100, fileSystemCallback, errorCallback);171 if (this.requestFileSystem) { 172 jsTestIsAsync = true; 173 requestFileSystem(this.TEMPORARY, 100, fileSystemCallback, errorCallback); 169 174 } else 170 175 debug("This test requires FileSystem API support."); 171 176 172 window.successfullyParsed = true;177 var successfullyParsed = true; -
trunk/Source/WebCore/ChangeLog
r81639 r81640 1 2011-03-21 Adam Klein <adamk@chromium.org> 2 3 Reviewed by David Levin. 4 5 [fileapi] Add URI resolution support to WorkerContext 6 https://bugs.webkit.org/show_bug.cgi?id=55644 7 8 Tests: http/tests/filesystem/workers/resolve-url-sync.html 9 http/tests/filesystem/workers/resolve-url.html 10 11 * fileapi/LocalFileSystem.cpp: 12 (WebCore::LocalFileSystem::readFileSystem): 13 Add support for workers. 14 * fileapi/LocalFileSystem.h: 15 * workers/WorkerContext.cpp: 16 (WebCore::WorkerContext::resolveLocalFileSystemURL): 17 (WebCore::WorkerContext::resolveLocalFileSystemSyncURL): 18 * workers/WorkerContext.h: 19 * workers/WorkerContext.idl: 20 1 21 2011-03-21 David Levin <levin@chromium.org> 2 22 -
trunk/Source/WebCore/fileapi/LocalFileSystem.cpp
r79917 r81640 82 82 } 83 83 84 void LocalFileSystem::readFileSystem(ScriptExecutionContext* context, AsyncFileSystem::Type type, PassOwnPtr<AsyncFileSystemCallbacks> callbacks )84 void LocalFileSystem::readFileSystem(ScriptExecutionContext* context, AsyncFileSystem::Type type, PassOwnPtr<AsyncFileSystemCallbacks> callbacks, bool) 85 85 { 86 86 // AsyncFileSystem::openFileSystem calls callbacks synchronously, so the method needs to be called asynchronously. -
trunk/Source/WebCore/fileapi/LocalFileSystem.h
r79917 r81640 55 55 56 56 // Does not create the root path for file system, just reads it if available. 57 void readFileSystem(ScriptExecutionContext*, AsyncFileSystem::Type, PassOwnPtr<AsyncFileSystemCallbacks> );57 void readFileSystem(ScriptExecutionContext*, AsyncFileSystem::Type, PassOwnPtr<AsyncFileSystemCallbacks>, bool synchronous = false); 58 58 59 59 void requestFileSystem(ScriptExecutionContext*, AsyncFileSystem::Type, long long size, PassOwnPtr<AsyncFileSystemCallbacks>, bool synchronous = false); -
trunk/Source/WebCore/workers/WorkerContext.cpp
r77563 r81640 68 68 #if ENABLE(FILE_SYSTEM) 69 69 #include "AsyncFileSystem.h" 70 #include "DirectoryEntrySync.h" 70 71 #include "DOMFileSystem.h" 72 #include "DOMFileSystemBase.h" 71 73 #include "DOMFileSystemSync.h" 72 74 #include "ErrorCallback.h" 75 #include "FileEntrySync.h" 73 76 #include "FileError.h" 74 77 #include "FileException.h" … … 378 381 } 379 382 383 void WorkerContext::resolveLocalFileSystemURL(const String& url, PassRefPtr<EntryCallback> successCallback, PassRefPtr<ErrorCallback> errorCallback) 384 { 385 KURL completedURL = completeURL(url); 386 if (!AsyncFileSystem::isAvailable() || !securityOrigin()->canAccessFileSystem() || !securityOrigin()->canRequest(completedURL)) { 387 DOMFileSystem::scheduleCallback(this, errorCallback, FileError::create(FileError::SECURITY_ERR)); 388 return; 389 } 390 391 AsyncFileSystem::Type type; 392 String filePath; 393 if (!completedURL.isValid() || !DOMFileSystemBase::crackFileSystemURL(completedURL, type, filePath)) { 394 DOMFileSystem::scheduleCallback(this, errorCallback, FileError::create(FileError::SYNTAX_ERR)); 395 return; 396 } 397 398 LocalFileSystem::localFileSystem().readFileSystem(this, type, ResolveURICallbacks::create(successCallback, errorCallback, this, filePath)); 399 } 400 401 PassRefPtr<EntrySync> WorkerContext::resolveLocalFileSystemSyncURL(const String& url, ExceptionCode& ec) 402 { 403 ec = 0; 404 KURL completedURL = completeURL(url); 405 if (!AsyncFileSystem::isAvailable() || !securityOrigin()->canAccessFileSystem() || !securityOrigin()->canRequest(completedURL)) { 406 ec = FileException::SECURITY_ERR; 407 return 0; 408 } 409 410 AsyncFileSystem::Type type; 411 String filePath; 412 if (!completedURL.isValid() || !DOMFileSystemBase::crackFileSystemURL(completedURL, type, filePath)) { 413 ec = FileException::SYNTAX_ERR; 414 return 0; 415 } 416 417 FileSystemSyncCallbackHelper readFileSystemHelper; 418 LocalFileSystem::localFileSystem().readFileSystem(this, type, FileSystemCallbacks::create(readFileSystemHelper.successCallback(), readFileSystemHelper.errorCallback(), this), true); 419 RefPtr<DOMFileSystemSync> fileSystem = readFileSystemHelper.getResult(ec); 420 if (!fileSystem) 421 return 0; 422 423 RefPtr<EntrySync> entry = fileSystem->root()->getDirectory(filePath, 0, ec); 424 if (ec == FileException::TYPE_MISMATCH_ERR) 425 return fileSystem->root()->getFile(filePath, 0, ec); 426 427 return entry.release(); 428 } 429 380 430 COMPILE_ASSERT(static_cast<int>(WorkerContext::TEMPORARY) == static_cast<int>(AsyncFileSystem::Temporary), enum_mismatch); 381 431 COMPILE_ASSERT(static_cast<int>(WorkerContext::PERSISTENT) == static_cast<int>(AsyncFileSystem::Persistent), enum_mismatch); -
trunk/Source/WebCore/workers/WorkerContext.h
r76248 r81640 51 51 class DatabaseCallback; 52 52 class DatabaseSync; 53 class EntryCallback; 54 class EntrySync; 53 55 class ErrorCallback; 54 56 class FileSystemCallback; … … 130 132 PERSISTENT, 131 133 }; 132 void requestFileSystem(int type, long long size, PassRefPtr<FileSystemCallback> , PassRefPtr<ErrorCallback>);134 void requestFileSystem(int type, long long size, PassRefPtr<FileSystemCallback> successCallback, PassRefPtr<ErrorCallback>); 133 135 PassRefPtr<DOMFileSystemSync> requestFileSystemSync(int type, long long size, ExceptionCode&); 136 void resolveLocalFileSystemURL(const String& url, PassRefPtr<EntryCallback> successCallback, PassRefPtr<ErrorCallback>); 137 PassRefPtr<EntrySync> resolveLocalFileSystemSyncURL(const String& url, ExceptionCode&); 134 138 #endif 135 139 -
trunk/Source/WebCore/workers/WorkerContext.idl
r78407 r81640 111 111 [EnabledAtRuntime=FileSystem] void requestFileSystem(in unsigned short type, in long long size, in [Callback, Optional] FileSystemCallback successCallback, in [Callback, Optional] ErrorCallback errorCallback); 112 112 [EnabledAtRuntime=FileSystem] DOMFileSystemSync requestFileSystemSync(in unsigned short type, in long long size) raises (FileException); 113 [EnabledAtRuntime=FileSystem] void resolveLocalFileSystemURL(in DOMString url, in [Callback, Optional] EntryCallback successCallback, in [Callback, Optional] ErrorCallback errorCallback); 114 [EnabledAtRuntime=FileSystem] EntrySync resolveLocalFileSystemSyncURL(in DOMString url) raises (FileException); 113 115 114 116 attribute [EnabledAtRuntime=FileSystem] FlagsConstructor Flags; -
trunk/Source/WebKit/chromium/ChangeLog
r81637 r81640 1 2011-03-21 Adam Klein <adamk@chromium.org> 2 3 Reviewed by David Levin. 4 5 [fileapi] Add URI resolution support to WorkerContext 6 https://bugs.webkit.org/show_bug.cgi?id=55644 7 8 Pass "create" bool through to allow opening 9 a filesystem without allowing creation. 10 11 * src/LocalFileSystemChromium.cpp: 12 (WebCore::LocalFileSystem::readFileSystem): 13 (WebCore::LocalFileSystem::requestFileSystem): 14 * src/WebWorkerBase.cpp: 15 (WebKit::WebWorkerBase::openFileSystemForWorker): 16 * src/WebWorkerBase.h: 17 * src/WorkerFileSystemCallbacksBridge.cpp: 18 (WebKit::WorkerFileSystemCallbacksBridge::postOpenFileSystemToMainThread): 19 (WebKit::WorkerFileSystemCallbacksBridge::openFileSystemOnMainThread): 20 * src/WorkerFileSystemCallbacksBridge.h: 21 1 22 2011-03-21 Ilya Sherman <isherman@chromium.org> 2 23 -
trunk/Source/WebKit/chromium/src/LocalFileSystemChromium.cpp
r79917 r81640 58 58 } 59 59 60 void LocalFileSystem::readFileSystem(ScriptExecutionContext* context, AsyncFileSystem::Type type, PassOwnPtr<AsyncFileSystemCallbacks> callbacks) 61 { 62 ASSERT(context && context->isDocument()); 63 Document* document = static_cast<Document*>(context); 64 WebFrameImpl* webFrame = WebFrameImpl::fromFrame(document->frame()); 65 webFrame->client()->openFileSystem(webFrame, static_cast<WebFileSystem::Type>(type), 0, false, new WebFileSystemCallbacksImpl(callbacks, type)); 66 } 60 namespace { 67 61 68 void LocalFileSystem::requestFileSystem(ScriptExecutionContext* context, AsyncFileSystem::Type type, long long size, PassOwnPtr<AsyncFileSystemCallbacks> callbacks, bool synchronous) 62 enum CreationFlag { 63 OpenExisting, 64 CreateIfNotPresent 65 }; 66 67 } // namespace 68 69 static void openFileSystemHelper(ScriptExecutionContext* context, AsyncFileSystem::Type type, PassOwnPtr<AsyncFileSystemCallbacks> callbacks, bool synchronous, long long size, CreationFlag create) 69 70 { 70 71 ASSERT(context); … … 72 73 Document* document = static_cast<Document*>(context); 73 74 WebFrameImpl* webFrame = WebFrameImpl::fromFrame(document->frame()); 74 webFrame->client()->openFileSystem(webFrame, static_cast<WebFileSystem::Type>(type), size, true, new WebFileSystemCallbacksImpl(callbacks, type));75 webFrame->client()->openFileSystem(webFrame, static_cast<WebFileSystem::Type>(type), size, create == CreateIfNotPresent, new WebFileSystemCallbacksImpl(callbacks, type)); 75 76 } else { 76 77 WorkerContext* workerContext = static_cast<WorkerContext*>(context); 77 78 WorkerLoaderProxy* workerLoaderProxy = &workerContext->thread()->workerLoaderProxy(); 78 79 WebWorkerBase* webWorker = static_cast<WebWorkerBase*>(workerLoaderProxy); 79 webWorker->openFileSystemForWorker(static_cast<WebFileSystem::Type>(type), size, new WebFileSystemCallbacksImpl(callbacks, type, context, synchronous), synchronous);80 webWorker->openFileSystemForWorker(static_cast<WebFileSystem::Type>(type), size, create == CreateIfNotPresent, new WebFileSystemCallbacksImpl(callbacks, type, context, synchronous), synchronous); 80 81 } 82 } 83 84 void LocalFileSystem::readFileSystem(ScriptExecutionContext* context, AsyncFileSystem::Type type, PassOwnPtr<AsyncFileSystemCallbacks> callbacks, bool synchronous) 85 { 86 openFileSystemHelper(context, type, callbacks, synchronous, 0, OpenExisting); 87 } 88 89 void LocalFileSystem::requestFileSystem(ScriptExecutionContext* context, AsyncFileSystem::Type type, long long size, PassOwnPtr<AsyncFileSystemCallbacks> callbacks, bool synchronous) 90 { 91 openFileSystemHelper(context, type, callbacks, synchronous, size, CreateIfNotPresent); 81 92 } 82 93 -
trunk/Source/WebKit/chromium/src/WebWorkerBase.cpp
r81567 r81640 238 238 239 239 #if ENABLE(FILE_SYSTEM) 240 void WebWorkerBase::openFileSystemForWorker(WebFileSystem::Type type, long long size, WebFileSystemCallbacks* callbacks, bool synchronous)240 void WebWorkerBase::openFileSystemForWorker(WebFileSystem::Type type, long long size, bool create, WebFileSystemCallbacks* callbacks, bool synchronous) 241 241 { 242 242 WorkerRunLoop& runLoop = m_workerThread->runLoop(); … … 249 249 250 250 RefPtr<WorkerFileSystemCallbacksBridge> bridge = WorkerFileSystemCallbacksBridge::create(this, workerContext, callbacks); 251 bridge->postOpenFileSystemToMainThread(commonClient(), type, size, mode);251 bridge->postOpenFileSystemToMainThread(commonClient(), type, size, create, mode); 252 252 253 253 if (synchronous) { -
trunk/Source/WebKit/chromium/src/WebWorkerBase.h
r79354 r81640 93 93 94 94 #if ENABLE(FILE_SYSTEM) 95 void openFileSystemForWorker(WebFileSystem::Type, long long size, WebFileSystemCallbacks*, bool synchronous);95 void openFileSystemForWorker(WebFileSystem::Type, long long size, bool create, WebFileSystemCallbacks*, bool synchronous); 96 96 #endif 97 97 -
trunk/Source/WebKit/chromium/src/WorkerFileSystemCallbacksBridge.cpp
r81599 r81640 152 152 } 153 153 154 void WorkerFileSystemCallbacksBridge::postOpenFileSystemToMainThread(WebCommonWorkerClient* commonClient, WebFileSystem::Type type, long long size, const String& mode)155 { 156 dispatchTaskToMainThread(createCallbackTask(&openFileSystemOnMainThread, commonClient, type, size, this, mode));154 void WorkerFileSystemCallbacksBridge::postOpenFileSystemToMainThread(WebCommonWorkerClient* commonClient, WebFileSystem::Type type, long long size, bool create, const String& mode) 155 { 156 dispatchTaskToMainThread(createCallbackTask(&openFileSystemOnMainThread, commonClient, type, size, create, this, mode)); 157 157 } 158 158 … … 214 214 } 215 215 216 void WorkerFileSystemCallbacksBridge::openFileSystemOnMainThread(ScriptExecutionContext*, WebCommonWorkerClient* commonClient, WebFileSystem::Type type, long long size, WorkerFileSystemCallbacksBridge* bridge, const String& mode)216 void WorkerFileSystemCallbacksBridge::openFileSystemOnMainThread(ScriptExecutionContext*, WebCommonWorkerClient* commonClient, WebFileSystem::Type type, long long size, bool create, WorkerFileSystemCallbacksBridge* bridge, const String& mode) 217 217 { 218 218 if (!commonClient) 219 219 bridge->didFailOnMainThread(WebFileErrorAbort, mode); 220 220 else { 221 commonClient->openFileSystem(type, size, MainThreadFileSystemCallbacks::createLeakedPtr(bridge, mode));221 commonClient->openFileSystem(type, size, create, MainThreadFileSystemCallbacks::createLeakedPtr(bridge, mode)); 222 222 } 223 223 } -
trunk/Source/WebKit/chromium/src/WorkerFileSystemCallbacksBridge.h
r81567 r81640 85 85 86 86 // Methods that create an instance and post an initial request task to the main thread. They must be called on the worker thread. 87 void postOpenFileSystemToMainThread(WebCommonWorkerClient*, WebFileSystem::Type, long long size, const String& mode);87 void postOpenFileSystemToMainThread(WebCommonWorkerClient*, WebFileSystem::Type, long long size, bool create, const String& mode); 88 88 void postMoveToMainThread(WebFileSystem*, const String& srcPath, const String& destPath, const String& mode); 89 89 void postCopyToMainThread(WebFileSystem*, const String& srcPath, const String& destPath, const String& mode); … … 108 108 109 109 // Methods that are to be called on the main thread. 110 static void openFileSystemOnMainThread(WebCore::ScriptExecutionContext*, WebCommonWorkerClient*, WebFileSystem::Type, long long size, WorkerFileSystemCallbacksBridge*, const String& mode);110 static void openFileSystemOnMainThread(WebCore::ScriptExecutionContext*, WebCommonWorkerClient*, WebFileSystem::Type, long long size, bool create, WorkerFileSystemCallbacksBridge*, const String& mode); 111 111 static void moveOnMainThread(WebCore::ScriptExecutionContext*, WebFileSystem*, const String& srcPath, const String& destPath, WorkerFileSystemCallbacksBridge*, const String& mode); 112 112 static void copyOnMainThread(WebCore::ScriptExecutionContext*, WebFileSystem*, const String& srcPath, const String& destPath, WorkerFileSystemCallbacksBridge*, const String& mode);
Note: See TracChangeset
for help on using the changeset viewer.