| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * 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 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #include "config.h" | 31 #include "config.h" |
| 32 #include "modules/filesystem/DOMFileSystemSync.h" | 32 #include "modules/filesystem/DOMFileSystemSync.h" |
| 33 | 33 |
| 34 #include "core/dom/ExceptionCode.h" |
| 34 #include "core/fileapi/File.h" | 35 #include "core/fileapi/File.h" |
| 35 #include "core/fileapi/FileError.h" | 36 #include "core/fileapi/FileError.h" |
| 36 #include "core/fileapi/FileException.h" | |
| 37 #include "core/platform/AsyncFileSystem.h" | 37 #include "core/platform/AsyncFileSystem.h" |
| 38 #include "core/platform/FileMetadata.h" | 38 #include "core/platform/FileMetadata.h" |
| 39 #include "modules/filesystem/AsyncFileWriter.h" | 39 #include "modules/filesystem/AsyncFileWriter.h" |
| 40 #include "modules/filesystem/DOMFilePath.h" | 40 #include "modules/filesystem/DOMFilePath.h" |
| 41 #include "modules/filesystem/DirectoryEntrySync.h" | 41 #include "modules/filesystem/DirectoryEntrySync.h" |
| 42 #include "modules/filesystem/ErrorCallback.h" | 42 #include "modules/filesystem/ErrorCallback.h" |
| 43 #include "modules/filesystem/FileEntrySync.h" | 43 #include "modules/filesystem/FileEntrySync.h" |
| 44 #include "modules/filesystem/FileSystemCallbacks.h" | 44 #include "modules/filesystem/FileSystemCallbacks.h" |
| 45 #include "modules/filesystem/FileWriterBaseCallback.h" | 45 #include "modules/filesystem/FileWriterBaseCallback.h" |
| 46 #include "modules/filesystem/FileWriterSync.h" | 46 #include "modules/filesystem/FileWriterSync.h" |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 | 151 |
| 152 } // namespace | 152 } // namespace |
| 153 | 153 |
| 154 PassRefPtr<File> DOMFileSystemSync::createFile(const FileEntrySync* fileEntry, E
xceptionCode& ec) | 154 PassRefPtr<File> DOMFileSystemSync::createFile(const FileEntrySync* fileEntry, E
xceptionCode& ec) |
| 155 { | 155 { |
| 156 ec = 0; | 156 ec = 0; |
| 157 KURL fileSystemURL = createFileSystemURL(fileEntry); | 157 KURL fileSystemURL = createFileSystemURL(fileEntry); |
| 158 RefPtr<CreateFileHelper::CreateFileResult> result(CreateFileHelper::CreateFi
leResult::create()); | 158 RefPtr<CreateFileHelper::CreateFileResult> result(CreateFileHelper::CreateFi
leResult::create()); |
| 159 m_asyncFileSystem->createSnapshotFileAndReadMetadata(fileSystemURL, CreateFi
leHelper::create(result, fileEntry->name(), fileSystemURL, type())); | 159 m_asyncFileSystem->createSnapshotFileAndReadMetadata(fileSystemURL, CreateFi
leHelper::create(result, fileEntry->name(), fileSystemURL, type())); |
| 160 if (!m_asyncFileSystem->waitForOperationToComplete()) { | 160 if (!m_asyncFileSystem->waitForOperationToComplete()) { |
| 161 ec = FileException::ABORT_ERR; | 161 ec = FSAbortError; |
| 162 return 0; | 162 return 0; |
| 163 } | 163 } |
| 164 if (result->m_failed) { | 164 if (result->m_failed) { |
| 165 ec = result->m_code; | 165 ec = result->m_code; |
| 166 return 0; | 166 return 0; |
| 167 } | 167 } |
| 168 return result->m_file; | 168 return result->m_file; |
| 169 } | 169 } |
| 170 | 170 |
| 171 namespace { | 171 namespace { |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 240 ec = 0; | 240 ec = 0; |
| 241 | 241 |
| 242 | 242 |
| 243 RefPtr<FileWriterSync> fileWriter = FileWriterSync::create(); | 243 RefPtr<FileWriterSync> fileWriter = FileWriterSync::create(); |
| 244 RefPtr<ReceiveFileWriterCallback> successCallback = ReceiveFileWriterCallbac
k::create(); | 244 RefPtr<ReceiveFileWriterCallback> successCallback = ReceiveFileWriterCallbac
k::create(); |
| 245 RefPtr<LocalErrorCallback> errorCallback = LocalErrorCallback::create(); | 245 RefPtr<LocalErrorCallback> errorCallback = LocalErrorCallback::create(); |
| 246 | 246 |
| 247 OwnPtr<FileWriterBaseCallbacks> callbacks = FileWriterBaseCallbacks::create(
fileWriter, successCallback, errorCallback); | 247 OwnPtr<FileWriterBaseCallbacks> callbacks = FileWriterBaseCallbacks::create(
fileWriter, successCallback, errorCallback); |
| 248 m_asyncFileSystem->createWriter(fileWriter.get(), createFileSystemURL(fileEn
try), callbacks.release()); | 248 m_asyncFileSystem->createWriter(fileWriter.get(), createFileSystemURL(fileEn
try), callbacks.release()); |
| 249 if (!m_asyncFileSystem->waitForOperationToComplete()) { | 249 if (!m_asyncFileSystem->waitForOperationToComplete()) { |
| 250 ec = FileException::ABORT_ERR; | 250 ec = FSAbortError; |
| 251 return 0; | 251 return 0; |
| 252 } | 252 } |
| 253 if (errorCallback->error()) { | 253 if (errorCallback->error()) { |
| 254 ASSERT(!successCallback->fileWriterBase()); | 254 ASSERT(!successCallback->fileWriterBase()); |
| 255 ec = FileException::ErrorCodeToExceptionCode(errorCallback->error()->cod
e()); | 255 ec = FileError::ErrorCodeToExceptionCode(errorCallback->error()->code())
; |
| 256 return 0; | 256 return 0; |
| 257 } | 257 } |
| 258 ASSERT(successCallback->fileWriterBase()); | 258 ASSERT(successCallback->fileWriterBase()); |
| 259 ASSERT(static_cast<FileWriterSync*>(successCallback->fileWriterBase()) == fi
leWriter.get()); | 259 ASSERT(static_cast<FileWriterSync*>(successCallback->fileWriterBase()) == fi
leWriter.get()); |
| 260 return fileWriter; | 260 return fileWriter; |
| 261 } | 261 } |
| 262 | 262 |
| 263 } | 263 } |
| OLD | NEW |