| 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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 | 56 |
| 57 FileSystemType fileSystemType = static_cast<FileSystemType>(type); | 57 FileSystemType fileSystemType = static_cast<FileSystemType>(type); |
| 58 if (!DOMFileSystemBase::isValidType(fileSystemType)) { | 58 if (!DOMFileSystemBase::isValidType(fileSystemType)) { |
| 59 DOMFileSystem::scheduleCallback(worker, errorCallback, FileError::create
(FileError::INVALID_MODIFICATION_ERR)); | 59 DOMFileSystem::scheduleCallback(worker, errorCallback, FileError::create
(FileError::INVALID_MODIFICATION_ERR)); |
| 60 return; | 60 return; |
| 61 } | 61 } |
| 62 | 62 |
| 63 LocalFileSystem::from(worker)->requestFileSystem(worker, fileSystemType, siz
e, FileSystemCallbacks::create(successCallback, errorCallback, worker, fileSyste
mType)); | 63 LocalFileSystem::from(worker)->requestFileSystem(worker, fileSystemType, siz
e, FileSystemCallbacks::create(successCallback, errorCallback, worker, fileSyste
mType)); |
| 64 } | 64 } |
| 65 | 65 |
| 66 PassRefPtr<DOMFileSystemSync> WorkerGlobalScopeFileSystem::webkitRequestFileSyst
emSync(WorkerGlobalScope* worker, int type, long long size, ExceptionState& es) | 66 PassRefPtr<DOMFileSystemSync> WorkerGlobalScopeFileSystem::webkitRequestFileSyst
emSync(WorkerGlobalScope* worker, int type, long long size, ExceptionState& exce
ptionState) |
| 67 { | 67 { |
| 68 ExecutionContext* secureContext = worker->executionContext(); | 68 ExecutionContext* secureContext = worker->executionContext(); |
| 69 if (!secureContext->securityOrigin()->canAccessFileSystem()) { | 69 if (!secureContext->securityOrigin()->canAccessFileSystem()) { |
| 70 es.throwSecurityError(ExceptionMessages::failedToExecute("webkitRequestF
ileSystemSync", "WorkerGlobalScopeFileSystem", FileError::securityErrorMessage))
; | 70 exceptionState.throwSecurityError(ExceptionMessages::failedToExecute("we
bkitRequestFileSystemSync", "WorkerGlobalScopeFileSystem", FileError::securityEr
rorMessage)); |
| 71 return 0; | 71 return 0; |
| 72 } | 72 } |
| 73 | 73 |
| 74 FileSystemType fileSystemType = static_cast<FileSystemType>(type); | 74 FileSystemType fileSystemType = static_cast<FileSystemType>(type); |
| 75 if (!DOMFileSystemBase::isValidType(fileSystemType)) { | 75 if (!DOMFileSystemBase::isValidType(fileSystemType)) { |
| 76 es.throwDOMException(InvalidModificationError, ExceptionMessages::failed
ToExecute("webkitRequestFileSystemSync", "WorkerGlobalScopeFileSystem", "the typ
e must be TEMPORARY or PERSISTENT.")); | 76 exceptionState.throwDOMException(InvalidModificationError, ExceptionMess
ages::failedToExecute("webkitRequestFileSystemSync", "WorkerGlobalScopeFileSyste
m", "the type must be TEMPORARY or PERSISTENT.")); |
| 77 return 0; | 77 return 0; |
| 78 } | 78 } |
| 79 | 79 |
| 80 FileSystemSyncCallbackHelper helper; | 80 FileSystemSyncCallbackHelper helper; |
| 81 OwnPtr<AsyncFileSystemCallbacks> callbacks = FileSystemCallbacks::create(hel
per.successCallback(), helper.errorCallback(), worker, fileSystemType); | 81 OwnPtr<AsyncFileSystemCallbacks> callbacks = FileSystemCallbacks::create(hel
per.successCallback(), helper.errorCallback(), worker, fileSystemType); |
| 82 callbacks->setShouldBlockUntilCompletion(true); | 82 callbacks->setShouldBlockUntilCompletion(true); |
| 83 | 83 |
| 84 LocalFileSystem::from(worker)->requestFileSystem(worker, fileSystemType, siz
e, callbacks.release()); | 84 LocalFileSystem::from(worker)->requestFileSystem(worker, fileSystemType, siz
e, callbacks.release()); |
| 85 return helper.getResult(es); | 85 return helper.getResult(exceptionState); |
| 86 } | 86 } |
| 87 | 87 |
| 88 void WorkerGlobalScopeFileSystem::webkitResolveLocalFileSystemURL(WorkerGlobalSc
ope* worker, const String& url, PassRefPtr<EntryCallback> successCallback, PassR
efPtr<ErrorCallback> errorCallback) | 88 void WorkerGlobalScopeFileSystem::webkitResolveLocalFileSystemURL(WorkerGlobalSc
ope* worker, const String& url, PassRefPtr<EntryCallback> successCallback, PassR
efPtr<ErrorCallback> errorCallback) |
| 89 { | 89 { |
| 90 KURL completedURL = worker->completeURL(url); | 90 KURL completedURL = worker->completeURL(url); |
| 91 ExecutionContext* secureContext = worker->executionContext(); | 91 ExecutionContext* secureContext = worker->executionContext(); |
| 92 if (!secureContext->securityOrigin()->canAccessFileSystem() || !secureContex
t->securityOrigin()->canRequest(completedURL)) { | 92 if (!secureContext->securityOrigin()->canAccessFileSystem() || !secureContex
t->securityOrigin()->canRequest(completedURL)) { |
| 93 DOMFileSystem::scheduleCallback(worker, errorCallback, FileError::create
(FileError::SECURITY_ERR)); | 93 DOMFileSystem::scheduleCallback(worker, errorCallback, FileError::create
(FileError::SECURITY_ERR)); |
| 94 return; | 94 return; |
| 95 } | 95 } |
| 96 | 96 |
| 97 if (!completedURL.isValid()) { | 97 if (!completedURL.isValid()) { |
| 98 DOMFileSystem::scheduleCallback(worker, errorCallback, FileError::create
(FileError::ENCODING_ERR)); | 98 DOMFileSystem::scheduleCallback(worker, errorCallback, FileError::create
(FileError::ENCODING_ERR)); |
| 99 return; | 99 return; |
| 100 } | 100 } |
| 101 | 101 |
| 102 LocalFileSystem::from(worker)->resolveURL(worker, completedURL, ResolveURICa
llbacks::create(successCallback, errorCallback, worker)); | 102 LocalFileSystem::from(worker)->resolveURL(worker, completedURL, ResolveURICa
llbacks::create(successCallback, errorCallback, worker)); |
| 103 } | 103 } |
| 104 | 104 |
| 105 PassRefPtr<EntrySync> WorkerGlobalScopeFileSystem::webkitResolveLocalFileSystemS
yncURL(WorkerGlobalScope* worker, const String& url, ExceptionState& es) | 105 PassRefPtr<EntrySync> WorkerGlobalScopeFileSystem::webkitResolveLocalFileSystemS
yncURL(WorkerGlobalScope* worker, const String& url, ExceptionState& exceptionSt
ate) |
| 106 { | 106 { |
| 107 KURL completedURL = worker->completeURL(url); | 107 KURL completedURL = worker->completeURL(url); |
| 108 ExecutionContext* secureContext = worker->executionContext(); | 108 ExecutionContext* secureContext = worker->executionContext(); |
| 109 if (!secureContext->securityOrigin()->canAccessFileSystem() || !secureContex
t->securityOrigin()->canRequest(completedURL)) { | 109 if (!secureContext->securityOrigin()->canAccessFileSystem() || !secureContex
t->securityOrigin()->canRequest(completedURL)) { |
| 110 es.throwSecurityError(ExceptionMessages::failedToExecute("webkitResolveL
ocalFileSystemSyncURL", "WorkerGlobalScopeFileSystem", FileError::securityErrorM
essage)); | 110 exceptionState.throwSecurityError(ExceptionMessages::failedToExecute("we
bkitResolveLocalFileSystemSyncURL", "WorkerGlobalScopeFileSystem", FileError::se
curityErrorMessage)); |
| 111 return 0; | 111 return 0; |
| 112 } | 112 } |
| 113 | 113 |
| 114 if (!completedURL.isValid()) { | 114 if (!completedURL.isValid()) { |
| 115 es.throwDOMException(EncodingError, ExceptionMessages::failedToExecute("
webkitResolveLocalFileSystemSyncURL", "WorkerGlobalScopeFileSystem", "the URL '"
+ url + "' is invalid.")); | 115 exceptionState.throwDOMException(EncodingError, ExceptionMessages::faile
dToExecute("webkitResolveLocalFileSystemSyncURL", "WorkerGlobalScopeFileSystem",
"the URL '" + url + "' is invalid.")); |
| 116 return 0; | 116 return 0; |
| 117 } | 117 } |
| 118 | 118 |
| 119 EntrySyncCallbackHelper resolveURLHelper; | 119 EntrySyncCallbackHelper resolveURLHelper; |
| 120 OwnPtr<AsyncFileSystemCallbacks> callbacks = ResolveURICallbacks::create(res
olveURLHelper.successCallback(), resolveURLHelper.errorCallback(), worker); | 120 OwnPtr<AsyncFileSystemCallbacks> callbacks = ResolveURICallbacks::create(res
olveURLHelper.successCallback(), resolveURLHelper.errorCallback(), worker); |
| 121 callbacks->setShouldBlockUntilCompletion(true); | 121 callbacks->setShouldBlockUntilCompletion(true); |
| 122 | 122 |
| 123 LocalFileSystem::from(worker)->resolveURL(worker, completedURL, callbacks.re
lease()); | 123 LocalFileSystem::from(worker)->resolveURL(worker, completedURL, callbacks.re
lease()); |
| 124 | 124 |
| 125 RefPtr<EntrySync> entry = resolveURLHelper.getResult(es); | 125 RefPtr<EntrySync> entry = resolveURLHelper.getResult(exceptionState); |
| 126 if (!entry) | 126 if (!entry) |
| 127 return 0; | 127 return 0; |
| 128 return entry.release(); | 128 return entry.release(); |
| 129 } | 129 } |
| 130 | 130 |
| 131 COMPILE_ASSERT(static_cast<int>(WorkerGlobalScopeFileSystem::TEMPORARY) == stati
c_cast<int>(FileSystemTypeTemporary), enum_mismatch); | 131 COMPILE_ASSERT(static_cast<int>(WorkerGlobalScopeFileSystem::TEMPORARY) == stati
c_cast<int>(FileSystemTypeTemporary), enum_mismatch); |
| 132 COMPILE_ASSERT(static_cast<int>(WorkerGlobalScopeFileSystem::PERSISTENT) == stat
ic_cast<int>(FileSystemTypePersistent), enum_mismatch); | 132 COMPILE_ASSERT(static_cast<int>(WorkerGlobalScopeFileSystem::PERSISTENT) == stat
ic_cast<int>(FileSystemTypePersistent), enum_mismatch); |
| 133 | 133 |
| 134 } // namespace WebCore | 134 } // namespace WebCore |
| OLD | NEW |