| 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/EntrySync.h" | 32 #include "modules/filesystem/EntrySync.h" |
| 33 | 33 |
| 34 #include "core/fileapi/FileException.h" | 34 #include "core/dom/ExceptionCode.h" |
| 35 #include "modules/filesystem/DOMFilePath.h" | 35 #include "modules/filesystem/DOMFilePath.h" |
| 36 #include "modules/filesystem/DOMFileSystemSync.h" | 36 #include "modules/filesystem/DOMFileSystemSync.h" |
| 37 #include "modules/filesystem/DirectoryEntry.h" | 37 #include "modules/filesystem/DirectoryEntry.h" |
| 38 #include "modules/filesystem/DirectoryEntrySync.h" | 38 #include "modules/filesystem/DirectoryEntrySync.h" |
| 39 #include "modules/filesystem/FileEntrySync.h" | 39 #include "modules/filesystem/FileEntrySync.h" |
| 40 #include "modules/filesystem/Metadata.h" | 40 #include "modules/filesystem/Metadata.h" |
| 41 #include "modules/filesystem/SyncCallbackHelper.h" | 41 #include "modules/filesystem/SyncCallbackHelper.h" |
| 42 | 42 |
| 43 namespace WebCore { | 43 namespace WebCore { |
| 44 | 44 |
| 45 PassRefPtr<EntrySync> EntrySync::create(EntryBase* entry) | 45 PassRefPtr<EntrySync> EntrySync::create(EntryBase* entry) |
| 46 { | 46 { |
| 47 if (entry->isFile()) | 47 if (entry->isFile()) |
| 48 return adoptRef(new FileEntrySync(entry->m_fileSystem, entry->m_fullPath
)); | 48 return adoptRef(new FileEntrySync(entry->m_fileSystem, entry->m_fullPath
)); |
| 49 return adoptRef(new DirectoryEntrySync(entry->m_fileSystem, entry->m_fullPat
h)); | 49 return adoptRef(new DirectoryEntrySync(entry->m_fileSystem, entry->m_fullPat
h)); |
| 50 } | 50 } |
| 51 | 51 |
| 52 PassRefPtr<Metadata> EntrySync::getMetadata(ExceptionCode& ec) | 52 PassRefPtr<Metadata> EntrySync::getMetadata(ExceptionCode& ec) |
| 53 { | 53 { |
| 54 ec = 0; | 54 ec = 0; |
| 55 MetadataSyncCallbackHelper helper(m_fileSystem->asyncFileSystem()); | 55 MetadataSyncCallbackHelper helper(m_fileSystem->asyncFileSystem()); |
| 56 if (!m_fileSystem->getMetadata(this, helper.successCallback(), helper.errorC
allback())) { | 56 if (!m_fileSystem->getMetadata(this, helper.successCallback(), helper.errorC
allback())) { |
| 57 ec = FileException::INVALID_MODIFICATION_ERR; | 57 ec = FSInvalidModificationError; |
| 58 return 0; | 58 return 0; |
| 59 } | 59 } |
| 60 return helper.getResult(ec); | 60 return helper.getResult(ec); |
| 61 } | 61 } |
| 62 | 62 |
| 63 PassRefPtr<EntrySync> EntrySync::moveTo(PassRefPtr<DirectoryEntrySync> parent, c
onst String& name, ExceptionCode& ec) const | 63 PassRefPtr<EntrySync> EntrySync::moveTo(PassRefPtr<DirectoryEntrySync> parent, c
onst String& name, ExceptionCode& ec) const |
| 64 { | 64 { |
| 65 ec = 0; | 65 ec = 0; |
| 66 EntrySyncCallbackHelper helper(m_fileSystem->asyncFileSystem()); | 66 EntrySyncCallbackHelper helper(m_fileSystem->asyncFileSystem()); |
| 67 if (!m_fileSystem->move(this, parent.get(), name, helper.successCallback(),
helper.errorCallback())) { | 67 if (!m_fileSystem->move(this, parent.get(), name, helper.successCallback(),
helper.errorCallback())) { |
| 68 ec = FileException::INVALID_MODIFICATION_ERR; | 68 ec = FSInvalidModificationError; |
| 69 return 0; | 69 return 0; |
| 70 } | 70 } |
| 71 return helper.getResult(ec); | 71 return helper.getResult(ec); |
| 72 } | 72 } |
| 73 | 73 |
| 74 PassRefPtr<EntrySync> EntrySync::copyTo(PassRefPtr<DirectoryEntrySync> parent, c
onst String& name, ExceptionCode& ec) const | 74 PassRefPtr<EntrySync> EntrySync::copyTo(PassRefPtr<DirectoryEntrySync> parent, c
onst String& name, ExceptionCode& ec) const |
| 75 { | 75 { |
| 76 ec = 0; | 76 ec = 0; |
| 77 EntrySyncCallbackHelper helper(m_fileSystem->asyncFileSystem()); | 77 EntrySyncCallbackHelper helper(m_fileSystem->asyncFileSystem()); |
| 78 if (!m_fileSystem->copy(this, parent.get(), name, helper.successCallback(),
helper.errorCallback())) { | 78 if (!m_fileSystem->copy(this, parent.get(), name, helper.successCallback(),
helper.errorCallback())) { |
| 79 ec = FileException::INVALID_MODIFICATION_ERR; | 79 ec = FSInvalidModificationError; |
| 80 return 0; | 80 return 0; |
| 81 } | 81 } |
| 82 return helper.getResult(ec); | 82 return helper.getResult(ec); |
| 83 } | 83 } |
| 84 | 84 |
| 85 void EntrySync::remove(ExceptionCode& ec) const | 85 void EntrySync::remove(ExceptionCode& ec) const |
| 86 { | 86 { |
| 87 ec = 0; | 87 ec = 0; |
| 88 VoidSyncCallbackHelper helper(m_fileSystem->asyncFileSystem()); | 88 VoidSyncCallbackHelper helper(m_fileSystem->asyncFileSystem()); |
| 89 if (!m_fileSystem->remove(this, helper.successCallback(), helper.errorCallba
ck())) { | 89 if (!m_fileSystem->remove(this, helper.successCallback(), helper.errorCallba
ck())) { |
| 90 ec = FileException::INVALID_MODIFICATION_ERR; | 90 ec = FSInvalidModificationError; |
| 91 return; | 91 return; |
| 92 } | 92 } |
| 93 helper.getResult(ec); | 93 helper.getResult(ec); |
| 94 } | 94 } |
| 95 | 95 |
| 96 PassRefPtr<EntrySync> EntrySync::getParent() const | 96 PassRefPtr<EntrySync> EntrySync::getParent() const |
| 97 { | 97 { |
| 98 // Sync verion of getParent doesn't throw exceptions. | 98 // Sync verion of getParent doesn't throw exceptions. |
| 99 String parentPath = DOMFilePath::getDirectory(fullPath()); | 99 String parentPath = DOMFilePath::getDirectory(fullPath()); |
| 100 return DirectoryEntrySync::create(m_fileSystem, parentPath); | 100 return DirectoryEntrySync::create(m_fileSystem, parentPath); |
| 101 } | 101 } |
| 102 | 102 |
| 103 EntrySync::EntrySync(PassRefPtr<DOMFileSystemBase> fileSystem, const String& ful
lPath) | 103 EntrySync::EntrySync(PassRefPtr<DOMFileSystemBase> fileSystem, const String& ful
lPath) |
| 104 : EntryBase(fileSystem, fullPath) | 104 : EntryBase(fileSystem, fullPath) |
| 105 { | 105 { |
| 106 ScriptWrappable::init(this); | 106 ScriptWrappable::init(this); |
| 107 } | 107 } |
| 108 | 108 |
| 109 } | 109 } |
| OLD | NEW |