OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. | 2 * Copyright (C) 2008 Apple 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 | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
208 { | 208 { |
209 if (hasValidSnapshotMetadata()) { | 209 if (hasValidSnapshotMetadata()) { |
210 snapshotSize = m_snapshotSize; | 210 snapshotSize = m_snapshotSize; |
211 snapshotModificationTime = m_snapshotModificationTime; | 211 snapshotModificationTime = m_snapshotModificationTime; |
212 return; | 212 return; |
213 } | 213 } |
214 | 214 |
215 // Obtains a snapshot of the file by capturing its current size and modifica tion time. This is used when we slice a file for the first time. | 215 // Obtains a snapshot of the file by capturing its current size and modifica tion time. This is used when we slice a file for the first time. |
216 // If we fail to retrieve the size or modification time, probably due to tha t the file has been deleted, 0 size is returned. | 216 // If we fail to retrieve the size or modification time, probably due to tha t the file has been deleted, 0 size is returned. |
217 FileMetadata metadata; | 217 FileMetadata metadata; |
218 if (!getFileMetadata(m_path, metadata)) { | 218 if (!getFileMetadata(m_path, metadata)) { |
michaeln
2014/02/18 18:59:54
Is getFileMetadata() safe to call with an empty pa
sof
2014/02/19 11:47:39
It would be relying on whatever behavior that meth
| |
219 snapshotSize = 0; | 219 snapshotSize = 0; |
220 snapshotModificationTime = invalidFileTime(); | 220 snapshotModificationTime = invalidFileTime(); |
221 return; | 221 return; |
222 } | 222 } |
223 | 223 |
224 snapshotSize = metadata.length; | 224 snapshotSize = metadata.length; |
225 snapshotModificationTime = metadata.modificationTime; | 225 snapshotModificationTime = metadata.modificationTime; |
226 } | 226 } |
227 | 227 |
228 void File::close(ExecutionContext* executionContext) | |
229 { | |
230 if (!hasBeenClosed()) { | |
231 // Reset the File to its closed representation, an empty | |
232 // Blob. The name isn't cleared, as it should still be | |
233 // available. | |
234 m_hasBackingFile = false; | |
235 m_path = String(); | |
236 m_fileSystemURL = KURL(); | |
237 invalidateSnapshotMetadata(); | |
238 m_relativePath = String(); | |
239 Blob::close(executionContext); | |
240 } | |
241 } | |
242 | |
228 void File::appendTo(BlobData& blobData) const | 243 void File::appendTo(BlobData& blobData) const |
229 { | 244 { |
230 if (!m_hasBackingFile) { | 245 if (!m_hasBackingFile) { |
231 Blob::appendTo(blobData); | 246 Blob::appendTo(blobData); |
232 return; | 247 return; |
233 } | 248 } |
234 | 249 |
235 // FIXME: This involves synchronous file operation. We need to figure out ho w to make it asynchronous. | 250 // FIXME: This involves synchronous file operation. We need to figure out ho w to make it asynchronous. |
236 long long size; | 251 long long size; |
237 double modificationTime; | 252 double modificationTime; |
238 captureSnapshot(size, modificationTime); | 253 captureSnapshot(size, modificationTime); |
239 if (!m_fileSystemURL.isEmpty()) { | 254 if (!m_fileSystemURL.isEmpty()) { |
240 blobData.appendFileSystemURL(m_fileSystemURL, 0, size, modificationTime) ; | 255 blobData.appendFileSystemURL(m_fileSystemURL, 0, size, modificationTime) ; |
241 return; | 256 return; |
242 } | 257 } |
243 ASSERT(!m_path.isEmpty()); | 258 ASSERT(!m_path.isEmpty()); |
244 blobData.appendFile(m_path, 0, size, modificationTime); | 259 blobData.appendFile(m_path, 0, size, modificationTime); |
245 } | 260 } |
246 | 261 |
247 } // namespace WebCore | 262 } // namespace WebCore |
OLD | NEW |