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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 | 46 |
47 PassRefPtr<EntrySync> EntrySync::create(EntryBase* entry) | 47 PassRefPtr<EntrySync> EntrySync::create(EntryBase* entry) |
48 { | 48 { |
49 if (entry->isFile()) | 49 if (entry->isFile()) |
50 return adoptRef(new FileEntrySync(entry->m_fileSystem, entry->m_fullPath
)); | 50 return adoptRef(new FileEntrySync(entry->m_fileSystem, entry->m_fullPath
)); |
51 return adoptRef(new DirectoryEntrySync(entry->m_fileSystem, entry->m_fullPat
h)); | 51 return adoptRef(new DirectoryEntrySync(entry->m_fileSystem, entry->m_fullPat
h)); |
52 } | 52 } |
53 | 53 |
54 PassRefPtr<Metadata> EntrySync::getMetadata(ExceptionState& es) | 54 PassRefPtr<Metadata> EntrySync::getMetadata(ExceptionState& es) |
55 { | 55 { |
56 MetadataSyncCallbackHelper helper(m_fileSystem->asyncFileSystem()); | 56 MetadataSyncCallbackHelper helper; |
57 if (!m_fileSystem->getMetadata(this, helper.successCallback(), helper.errorC
allback(), DOMFileSystemBase::Synchronous)) { | 57 if (!m_fileSystem->getMetadata(this, helper.successCallback(), helper.errorC
allback(), DOMFileSystemBase::Synchronous)) { |
58 es.throwDOMException(InvalidModificationError, ExceptionMessages::failed
ToExecute("getMetadata", "EntrySync")); | 58 es.throwDOMException(InvalidModificationError, ExceptionMessages::failed
ToExecute("getMetadata", "EntrySync")); |
59 return 0; | 59 return 0; |
60 } | 60 } |
61 return helper.getResult(es); | 61 return helper.getResult(es); |
62 } | 62 } |
63 | 63 |
64 PassRefPtr<EntrySync> EntrySync::moveTo(PassRefPtr<DirectoryEntrySync> parent, c
onst String& name, ExceptionState& es) const | 64 PassRefPtr<EntrySync> EntrySync::moveTo(PassRefPtr<DirectoryEntrySync> parent, c
onst String& name, ExceptionState& es) const |
65 { | 65 { |
66 EntrySyncCallbackHelper helper(m_fileSystem->asyncFileSystem()); | 66 EntrySyncCallbackHelper helper; |
67 if (!m_fileSystem->move(this, parent.get(), name, helper.successCallback(),
helper.errorCallback(), DOMFileSystemBase::Synchronous)) { | 67 if (!m_fileSystem->move(this, parent.get(), name, helper.successCallback(),
helper.errorCallback(), DOMFileSystemBase::Synchronous)) { |
68 es.throwDOMException(InvalidModificationError, ExceptionMessages::failed
ToExecute("moveTo", "EntrySync")); | 68 es.throwDOMException(InvalidModificationError, ExceptionMessages::failed
ToExecute("moveTo", "EntrySync")); |
69 return 0; | 69 return 0; |
70 } | 70 } |
71 return helper.getResult(es); | 71 return helper.getResult(es); |
72 } | 72 } |
73 | 73 |
74 PassRefPtr<EntrySync> EntrySync::copyTo(PassRefPtr<DirectoryEntrySync> parent, c
onst String& name, ExceptionState& es) const | 74 PassRefPtr<EntrySync> EntrySync::copyTo(PassRefPtr<DirectoryEntrySync> parent, c
onst String& name, ExceptionState& es) const |
75 { | 75 { |
76 EntrySyncCallbackHelper helper(m_fileSystem->asyncFileSystem()); | 76 EntrySyncCallbackHelper helper; |
77 if (!m_fileSystem->copy(this, parent.get(), name, helper.successCallback(),
helper.errorCallback(), DOMFileSystemBase::Synchronous)) { | 77 if (!m_fileSystem->copy(this, parent.get(), name, helper.successCallback(),
helper.errorCallback(), DOMFileSystemBase::Synchronous)) { |
78 es.throwDOMException(InvalidModificationError, ExceptionMessages::failed
ToExecute("copyTo", "EntrySync")); | 78 es.throwDOMException(InvalidModificationError, ExceptionMessages::failed
ToExecute("copyTo", "EntrySync")); |
79 return 0; | 79 return 0; |
80 } | 80 } |
81 return helper.getResult(es); | 81 return helper.getResult(es); |
82 } | 82 } |
83 | 83 |
84 void EntrySync::remove(ExceptionState& es) const | 84 void EntrySync::remove(ExceptionState& es) const |
85 { | 85 { |
86 VoidSyncCallbackHelper helper(m_fileSystem->asyncFileSystem()); | 86 VoidSyncCallbackHelper helper; |
87 if (!m_fileSystem->remove(this, helper.successCallback(), helper.errorCallba
ck(), DOMFileSystemBase::Synchronous)) { | 87 if (!m_fileSystem->remove(this, helper.successCallback(), helper.errorCallba
ck(), DOMFileSystemBase::Synchronous)) { |
88 es.throwDOMException(InvalidModificationError, ExceptionMessages::failed
ToExecute("remove", "EntrySync")); | 88 es.throwDOMException(InvalidModificationError, ExceptionMessages::failed
ToExecute("remove", "EntrySync")); |
89 return; | 89 return; |
90 } | 90 } |
91 helper.getResult(es); | 91 helper.getResult(es); |
92 } | 92 } |
93 | 93 |
94 PassRefPtr<EntrySync> EntrySync::getParent() const | 94 PassRefPtr<EntrySync> EntrySync::getParent() const |
95 { | 95 { |
96 // Sync verion of getParent doesn't throw exceptions. | 96 // Sync verion of getParent doesn't throw exceptions. |
97 String parentPath = DOMFilePath::getDirectory(fullPath()); | 97 String parentPath = DOMFilePath::getDirectory(fullPath()); |
98 return DirectoryEntrySync::create(m_fileSystem, parentPath); | 98 return DirectoryEntrySync::create(m_fileSystem, parentPath); |
99 } | 99 } |
100 | 100 |
101 EntrySync::EntrySync(PassRefPtr<DOMFileSystemBase> fileSystem, const String& ful
lPath) | 101 EntrySync::EntrySync(PassRefPtr<DOMFileSystemBase> fileSystem, const String& ful
lPath) |
102 : EntryBase(fileSystem, fullPath) | 102 : EntryBase(fileSystem, fullPath) |
103 { | 103 { |
104 ScriptWrappable::init(this); | 104 ScriptWrappable::init(this); |
105 } | 105 } |
106 | 106 |
107 } | 107 } |
OLD | NEW |