| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. | 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. |
| 3 * Copyright (C) 2009, 2011 Google Inc. All Rights Reserved. | 3 * Copyright (C) 2009, 2011 Google Inc. All Rights Reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 DOMFileSystem::scheduleCallback(&worker, errorCallback, FileError::creat
e(FileError::SECURITY_ERR)); | 52 DOMFileSystem::scheduleCallback(&worker, errorCallback, FileError::creat
e(FileError::SECURITY_ERR)); |
| 53 return; | 53 return; |
| 54 } | 54 } |
| 55 | 55 |
| 56 FileSystemType fileSystemType = static_cast<FileSystemType>(type); | 56 FileSystemType fileSystemType = static_cast<FileSystemType>(type); |
| 57 if (!DOMFileSystemBase::isValidType(fileSystemType)) { | 57 if (!DOMFileSystemBase::isValidType(fileSystemType)) { |
| 58 DOMFileSystem::scheduleCallback(&worker, errorCallback, FileError::creat
e(FileError::INVALID_MODIFICATION_ERR)); | 58 DOMFileSystem::scheduleCallback(&worker, errorCallback, FileError::creat
e(FileError::INVALID_MODIFICATION_ERR)); |
| 59 return; | 59 return; |
| 60 } | 60 } |
| 61 | 61 |
| 62 LocalFileSystem::from(worker)->requestFileSystem(&worker, fileSystemType, si
ze, FileSystemCallbacks::create(successCallback, errorCallback, &worker, fileSys
temType)); | 62 LocalFileSystem::from(worker)->requestFileSystemSync(&worker, fileSystemType
, size, FileSystemCallbacks::create(successCallback, errorCallback, &worker, fil
eSystemType)); |
| 63 } | 63 } |
| 64 | 64 |
| 65 PassRefPtrWillBeRawPtr<DOMFileSystemSync> WorkerGlobalScopeFileSystem::webkitReq
uestFileSystemSync(WorkerGlobalScope& worker, int type, long long size, Exceptio
nState& exceptionState) | 65 PassRefPtrWillBeRawPtr<DOMFileSystemSync> WorkerGlobalScopeFileSystem::webkitReq
uestFileSystemSync(WorkerGlobalScope& worker, int type, long long size, Exceptio
nState& exceptionState) |
| 66 { | 66 { |
| 67 ExecutionContext* secureContext = worker.executionContext(); | 67 ExecutionContext* secureContext = worker.executionContext(); |
| 68 if (!secureContext->securityOrigin()->canAccessFileSystem()) { | 68 if (!secureContext->securityOrigin()->canAccessFileSystem()) { |
| 69 exceptionState.throwSecurityError(FileError::securityErrorMessage); | 69 exceptionState.throwSecurityError(FileError::securityErrorMessage); |
| 70 return nullptr; | 70 return nullptr; |
| 71 } | 71 } |
| 72 | 72 |
| 73 FileSystemType fileSystemType = static_cast<FileSystemType>(type); | 73 FileSystemType fileSystemType = static_cast<FileSystemType>(type); |
| 74 if (!DOMFileSystemBase::isValidType(fileSystemType)) { | 74 if (!DOMFileSystemBase::isValidType(fileSystemType)) { |
| 75 exceptionState.throwDOMException(InvalidModificationError, "the type mus
t be TEMPORARY or PERSISTENT."); | 75 exceptionState.throwDOMException(InvalidModificationError, "the type mus
t be TEMPORARY or PERSISTENT."); |
| 76 return nullptr; | 76 return nullptr; |
| 77 } | 77 } |
| 78 | 78 |
| 79 RefPtr<FileSystemSyncCallbackHelper> helper = FileSystemSyncCallbackHelper::
create(); | 79 RefPtr<FileSystemSyncCallbackHelper> helper = FileSystemSyncCallbackHelper::
create(); |
| 80 OwnPtr<AsyncFileSystemCallbacks> callbacks = FileSystemCallbacks::create(hel
per->successCallback(), helper->errorCallback(), &worker, fileSystemType); | 80 OwnPtr<AsyncFileSystemCallbacks> callbacks = FileSystemCallbacks::create(hel
per->successCallback(), helper->errorCallback(), &worker, fileSystemType); |
| 81 callbacks->setShouldBlockUntilCompletion(true); | 81 callbacks->setShouldBlockUntilCompletion(true); |
| 82 | 82 |
| 83 LocalFileSystem::from(worker)->requestFileSystem(&worker, fileSystemType, si
ze, callbacks.release()); | 83 LocalFileSystem::from(worker)->requestFileSystemSync(&worker, fileSystemType
, size, callbacks.release()); |
| 84 return helper->getResult(exceptionState); | 84 return helper->getResult(exceptionState); |
| 85 } | 85 } |
| 86 | 86 |
| 87 void WorkerGlobalScopeFileSystem::webkitResolveLocalFileSystemURL(WorkerGlobalSc
ope& worker, const String& url, PassOwnPtr<EntryCallback> successCallback, PassO
wnPtr<ErrorCallback> errorCallback) | 87 void WorkerGlobalScopeFileSystem::webkitResolveLocalFileSystemURL(WorkerGlobalSc
ope& worker, const String& url, PassOwnPtr<EntryCallback> successCallback, PassO
wnPtr<ErrorCallback> errorCallback) |
| 88 { | 88 { |
| 89 KURL completedURL = worker.completeURL(url); | 89 KURL completedURL = worker.completeURL(url); |
| 90 ExecutionContext* secureContext = worker.executionContext(); | 90 ExecutionContext* secureContext = worker.executionContext(); |
| 91 if (!secureContext->securityOrigin()->canAccessFileSystem() || !secureContex
t->securityOrigin()->canRequest(completedURL)) { | 91 if (!secureContext->securityOrigin()->canAccessFileSystem() || !secureContex
t->securityOrigin()->canRequest(completedURL)) { |
| 92 DOMFileSystem::scheduleCallback(&worker, errorCallback, FileError::creat
e(FileError::SECURITY_ERR)); | 92 DOMFileSystem::scheduleCallback(&worker, errorCallback, FileError::creat
e(FileError::SECURITY_ERR)); |
| 93 return; | 93 return; |
| (...skipping 30 matching lines...) Expand all Loading... |
| 124 RefPtrWillBeRawPtr<EntrySync> entry = resolveURLHelper->getResult(exceptionS
tate); | 124 RefPtrWillBeRawPtr<EntrySync> entry = resolveURLHelper->getResult(exceptionS
tate); |
| 125 if (!entry) | 125 if (!entry) |
| 126 return nullptr; | 126 return nullptr; |
| 127 return entry.release(); | 127 return entry.release(); |
| 128 } | 128 } |
| 129 | 129 |
| 130 COMPILE_ASSERT(static_cast<int>(WorkerGlobalScopeFileSystem::TEMPORARY) == stati
c_cast<int>(FileSystemTypeTemporary), enum_mismatch); | 130 COMPILE_ASSERT(static_cast<int>(WorkerGlobalScopeFileSystem::TEMPORARY) == stati
c_cast<int>(FileSystemTypeTemporary), enum_mismatch); |
| 131 COMPILE_ASSERT(static_cast<int>(WorkerGlobalScopeFileSystem::PERSISTENT) == stat
ic_cast<int>(FileSystemTypePersistent), enum_mismatch); | 131 COMPILE_ASSERT(static_cast<int>(WorkerGlobalScopeFileSystem::PERSISTENT) == stat
ic_cast<int>(FileSystemTypePersistent), enum_mismatch); |
| 132 | 132 |
| 133 } // namespace WebCore | 133 } // namespace WebCore |
| OLD | NEW |